Add metadata support for volume type
rebase added set and unset metadata Change-Id: I8d969e1de305975d7c71a0bad3a62b15f423c3e0
This commit is contained in:
parent
2a39a70ff8
commit
5377da3406
@ -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='<type>',
|
||||
help='Type ID to update',
|
||||
)
|
||||
parser.add_argument(
|
||||
'meta_data',
|
||||
metavar='<key=value>',
|
||||
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='<type>',
|
||||
help='Type ID to update',
|
||||
)
|
||||
parser.add_argument(
|
||||
'meta_data',
|
||||
metavar='<key>',
|
||||
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
|
||||
|
2
setup.py
2
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',
|
||||
|
Loading…
Reference in New Issue
Block a user