Merge "Create message variables for exceptions"

This commit is contained in:
Jenkins 2014-08-24 20:20:08 +00:00 committed by Gerrit Code Review
commit 97d1bbdafd
3 changed files with 15 additions and 10 deletions

View File

@ -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,

View File

@ -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):

View File

@ -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