Merge "volume: Add alias for volume type AZs"
This commit is contained in:
commit
5883bcecd4
@ -130,6 +130,8 @@ class TestTypeCreate(TestType):
|
||||
'--multiattach',
|
||||
'--cacheable',
|
||||
'--replicated',
|
||||
'--availability-zone',
|
||||
'az1',
|
||||
self.new_volume_type.name,
|
||||
]
|
||||
verifylist = [
|
||||
@ -137,6 +139,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)
|
||||
@ -151,6 +154,7 @@ class TestTypeCreate(TestType):
|
||||
'multiattach': '<is> True',
|
||||
'cacheable': '<is> True',
|
||||
'replication_enabled': '<is> True',
|
||||
'RESKEY:availability_zones': 'az1',
|
||||
}
|
||||
)
|
||||
|
||||
@ -440,6 +444,8 @@ class TestTypeList(TestType):
|
||||
"--multiattach",
|
||||
"--cacheable",
|
||||
"--replicated",
|
||||
"--availability-zone",
|
||||
"az1",
|
||||
]
|
||||
verifylist = [
|
||||
("encryption_type", False),
|
||||
@ -450,6 +456,7 @@ class TestTypeList(TestType):
|
||||
("multiattach", True),
|
||||
("cacheable", True),
|
||||
("replicated", True),
|
||||
("availability_zones", ["az1"]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -461,6 +468,7 @@ class TestTypeList(TestType):
|
||||
"multiattach": "<is> True",
|
||||
"cacheable": "<is> True",
|
||||
"replication_enabled": "<is> True",
|
||||
"RESKEY:availability_zones": "az1",
|
||||
}
|
||||
},
|
||||
is_public=None,
|
||||
@ -605,6 +613,8 @@ class TestTypeSet(TestType):
|
||||
'--multiattach',
|
||||
'--cacheable',
|
||||
'--replicated',
|
||||
'--availability-zone',
|
||||
'az1',
|
||||
self.volume_type.id,
|
||||
]
|
||||
verifylist = [
|
||||
@ -614,6 +624,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)
|
||||
@ -627,6 +638,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