diff --git a/openstackclient/compute/v2/keypair.py b/openstackclient/compute/v2/keypair.py index 74cf4372f5..22c07ef7f3 100644 --- a/openstackclient/compute/v2/keypair.py +++ b/openstackclient/compute/v2/keypair.py @@ -57,8 +57,9 @@ class CreateKeypair(show.ShowOne): with open(os.path.expanduser(parsed_args.public_key)) as p: public_key = p.read() except IOError as e: - raise exceptions.CommandError( - "Key file %s not found: %s" % (parsed_args.public_key, e)) + msg = "Key file %s not found: %s" + raise exceptions.CommandError(msg + % (parsed_args.public_key, e)) keypair = compute_client.keypairs.create( parsed_args.name, diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index a4ed6fa47a..cb12a6ffb1 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -300,19 +300,22 @@ class CreateServer(show.ShowOne): raise exceptions.CommandError("Can't open '%s': %s" % (src, e)) if parsed_args.min > parsed_args.max: - raise exceptions.CommandError("min instances should be <= " - "max instances") + msg = "min instances should be <= max instances" + raise exceptions.CommandError(msg) if parsed_args.min < 1: - raise exceptions.CommandError("min instances should be > 0") + msg = "min instances should be > 0" + raise exceptions.CommandError(msg) if parsed_args.max < 1: - raise exceptions.CommandError("max instances should be > 0") + msg = "max instances should be > 0" + raise exceptions.CommandError(msg) userdata = None if parsed_args.user_data: try: userdata = open(parsed_args.user_data) except IOError as e: - raise exceptions.CommandError("Can't open '%s': %s" % + msg = "Can't open '%s': %s" + raise exceptions.CommandError(msg % (parsed_args.user_data, e)) block_device_mapping = dict(v.split('=', 1) @@ -1082,8 +1085,8 @@ class SetServer(command.Command): if p1 == p2: server.change_password(p1) else: - raise exceptions.CommandError( - "Passwords do not match, password unchanged") + msg = "Passwords do not match, password unchanged" + raise exceptions.CommandError(msg) class ShowServer(show.ShowOne): diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py index 24d7197619..4ee37e26f9 100644 --- a/openstackclient/network/v2/network.py +++ b/openstackclient/network/v2/network.py @@ -208,7 +208,8 @@ class SetNetwork(command.Command): if parsed_args.shared is not None: body['shared'] = parsed_args.shared if body == {}: - raise exceptions.CommandError("Nothing specified to be set") + msg = "Nothing specified to be set" + raise exceptions.CommandError(msg) update_method = getattr(client, "update_network") update_method(_id, {'network': body}) return