diff --git a/openstackclient/volume/v1/type.py b/openstackclient/volume/v1/type.py index 124f67d844..9f4d3df445 100644 --- a/openstackclient/volume/v1/type.py +++ b/openstackclient/volume/v1/type.py @@ -90,3 +90,70 @@ class ListType(lister.Lister): s, columns, formatters={}, ) for s in data)) + + +class SetType(command.Command): + """Set type command""" + + api = 'volume' + log = logging.getLogger(__name__ + '.SetType') + + def get_parser(self, prog_name): + parser = super(SetType, self).get_parser(prog_name) + parser.add_argument( + 'type', + metavar='', + help='Type ID to update', + ) + parser.add_argument( + 'meta_data', + metavar='', + help='meta-data to add to volume type', + ) + return parser + + def take_action(self, parsed_args): + self.log.debug('take_action(%s)' % parsed_args) + + meta = dict(v.split('=') for v in parsed_args.meta_data.split(' ')) + volume_client = self.app.client_manager.volume + volume_type = volume_client.volume_types.get( + parsed_args.type + ) + + volume_type.set_keys(meta) + + return + + +class UnsetType(command.Command): + """Unset type command""" + + api = 'volume' + log = logging.getLogger(__name__ + '.UnsetType') + + def get_parser(self, prog_name): + parser = super(UnsetType, self).get_parser(prog_name) + parser.add_argument( + 'type', + metavar='', + help='Type ID to update', + ) + parser.add_argument( + 'meta_data', + metavar='', + help='meta-data to remove from volume type (key only)', + ) + return parser + + def take_action(self, parsed_args): + self.log.debug('take_action(%s)' % parsed_args) + volume_client = self.app.client_manager.volume + volume_type = volume_client.volume_types.get( + parsed_args.type + ) + key_list = [] + key_list.append(parsed_args.meta_data) + volume_type.unset_keys(key_list) + + return diff --git a/setup.py b/setup.py index 15a41eb7eb..e4ea3f93d3 100644 --- a/setup.py +++ b/setup.py @@ -151,6 +151,8 @@ setuptools.setup( 'create_type=openstackclient.volume.v1.type:CreateType', 'delete_type=openstackclient.volume.v1.type:DeleteType', 'list_type=openstackclient.volume.v1.type:ListType', + 'set_type=openstackclient.volume.v1.type:SetType', + 'unset_type=openstackclient.volume.v1.type:UnsetType', 'show_quota=openstackclient.volume.v1.quota:ShowQuota', 'list_quota=openstackclient.volume.v1.quota:ListQuota', 'set_quota=openstackclient.volume.v1.quota:SetQuota',