Create message variables for exceptions
Instead of inline messages, let's create variables instead, as it's easier to find strings, and mark them for translation. Change-Id: Ibbcfdbc59d12a0cb4af50f73043d3ff7f3c76f99
This commit is contained in:
		@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
@@ -1077,8 +1080,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):
 | 
			
		||||
 
 | 
			
		||||
@@ -206,7 +206,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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user