volume: Add alias for volume type AZs
Another quality of life improvements. The key for this one is weird and the whole thing is a little more involved, hence why it's kept separate. Change-Id: I75aa85f27905104dc84fffe823c01b4c90a6a822 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
e0c7cef434
commit
a3410cd4f7
@ -132,6 +132,8 @@ class TestTypeCreate(TestType):
|
||||
'--multiattach',
|
||||
'--cacheable',
|
||||
'--replicated',
|
||||
'--availability-zone',
|
||||
'az1',
|
||||
self.new_volume_type.name,
|
||||
]
|
||||
verifylist = [
|
||||
@ -139,6 +141,7 @@ class TestTypeCreate(TestType):
|
||||
('multiattach', True),
|
||||
('cacheable', True),
|
||||
('replicated', True),
|
||||
('availability_zones', ['az1']),
|
||||
('name', self.new_volume_type.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -153,6 +156,7 @@ class TestTypeCreate(TestType):
|
||||
'multiattach': '<is> True',
|
||||
'cacheable': '<is> True',
|
||||
'replication_enabled': '<is> True',
|
||||
'RESKEY:availability_zones': 'az1',
|
||||
}
|
||||
)
|
||||
|
||||
@ -442,6 +446,8 @@ class TestTypeList(TestType):
|
||||
"--multiattach",
|
||||
"--cacheable",
|
||||
"--replicated",
|
||||
"--availability-zone",
|
||||
"az1",
|
||||
]
|
||||
verifylist = [
|
||||
("encryption_type", False),
|
||||
@ -452,6 +458,7 @@ class TestTypeList(TestType):
|
||||
("multiattach", True),
|
||||
("cacheable", True),
|
||||
("replicated", True),
|
||||
("availability_zones", ["az1"]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -463,6 +470,7 @@ class TestTypeList(TestType):
|
||||
"multiattach": "<is> True",
|
||||
"cacheable": "<is> True",
|
||||
"replication_enabled": "<is> True",
|
||||
"RESKEY:availability_zones": "az1",
|
||||
}
|
||||
},
|
||||
is_public=None,
|
||||
@ -607,6 +615,8 @@ class TestTypeSet(TestType):
|
||||
'--multiattach',
|
||||
'--cacheable',
|
||||
'--replicated',
|
||||
'--availability-zone',
|
||||
'az1',
|
||||
self.volume_type.id,
|
||||
]
|
||||
verifylist = [
|
||||
@ -616,6 +626,7 @@ class TestTypeSet(TestType):
|
||||
('multiattach', True),
|
||||
('cacheable', True),
|
||||
('replicated', True),
|
||||
('availability_zones', ['az1']),
|
||||
('volume_type', self.volume_type.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -629,6 +640,7 @@ class TestTypeSet(TestType):
|
||||
'multiattach': '<is> True',
|
||||
'cacheable': '<is> True',
|
||||
'replication_enabled': '<is> True',
|
||||
'RESKEY:availability_zones': 'az1',
|
||||
}
|
||||
)
|
||||
self.volume_type_access_mock.add_project_access.assert_not_called()
|
||||
|
@ -176,6 +176,16 @@ class CreateVolumeType(command.ShowOne):
|
||||
"(requires driver support)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--availability-zone',
|
||||
action='append',
|
||||
dest='availability_zones',
|
||||
help=_(
|
||||
"Set an availability zone for this volume type "
|
||||
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
|
||||
"(repeat option to set multiple availabilty zones)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--project',
|
||||
metavar='<project>',
|
||||
@ -274,6 +284,10 @@ class CreateVolumeType(command.ShowOne):
|
||||
properties['cacheable'] = '<is> True'
|
||||
if parsed_args.replicated:
|
||||
properties['replication_enabled'] = '<is> True'
|
||||
if parsed_args.availability_zones:
|
||||
properties['RESKEY:availability_zones'] = ','.join(
|
||||
parsed_args.availability_zones
|
||||
)
|
||||
if properties:
|
||||
result = volume_type.set_keys(properties)
|
||||
volume_type._info.update(
|
||||
@ -435,6 +449,16 @@ class ListVolumeType(command.Lister):
|
||||
"(supported by --os-volume-api-version 3.52 or above)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--availability-zone',
|
||||
action='append',
|
||||
dest='availability_zones',
|
||||
help=_(
|
||||
"List only volume types with this availability configured "
|
||||
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
|
||||
"(repeat option to filter on multiple availabilty zones)"
|
||||
),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -472,6 +496,10 @@ class ListVolumeType(command.Lister):
|
||||
properties['cacheable'] = '<is> True'
|
||||
if parsed_args.replicated:
|
||||
properties['replication_enabled'] = '<is> True'
|
||||
if parsed_args.availability_zones:
|
||||
properties['RESKEY:availability_zones'] = ','.join(
|
||||
parsed_args.availability_zones
|
||||
)
|
||||
if properties:
|
||||
if volume_client.api_version < api_versions.APIVersion('3.52'):
|
||||
msg = _(
|
||||
@ -590,6 +618,16 @@ class SetVolumeType(command.Command):
|
||||
"(requires driver support)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--availability-zone',
|
||||
action='append',
|
||||
dest='availability_zones',
|
||||
help=_(
|
||||
"Set an availability zone for this volume type "
|
||||
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
|
||||
"(repeat option to set multiple availabilty zones)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--project',
|
||||
metavar='<project>',
|
||||
@ -706,6 +744,10 @@ class SetVolumeType(command.Command):
|
||||
properties['cacheable'] = '<is> True'
|
||||
if parsed_args.replicated:
|
||||
properties['replication_enabled'] = '<is> True'
|
||||
if parsed_args.availability_zones:
|
||||
properties['RESKEY:availability_zones'] = ','.join(
|
||||
parsed_args.availability_zones
|
||||
)
|
||||
if properties:
|
||||
try:
|
||||
volume_type.set_keys(properties)
|
||||
|
@ -2,6 +2,6 @@
|
||||
features:
|
||||
- |
|
||||
The ``volume type create``, ``volume type set``, ``volume type list``
|
||||
commands now accept three new options - ``--multiattach``, ``--cacheable``,
|
||||
and ``--replicated`` - which are short cuts for setting or filtering on
|
||||
the relevant properties on the volume type.
|
||||
commands now accept four new options - ``--multiattach``, ``--cacheable``,
|
||||
``--replicated``, and ``--availability-zone`` - which are short cuts for
|
||||
setting or filtering on the relevant properties on the volume type.
|
||||
|
Loading…
Reference in New Issue
Block a user