Skip to content

Commit 5883bce

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "volume: Add alias for volume type AZs"
2 parents e13f948 + a3410cd commit 5883bce

3 files changed

Lines changed: 57 additions & 3 deletions

File tree

openstackclient/tests/unit/volume/v2/test_volume_type.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ def test_type_create_with_properties(self):
130130
'--multiattach',
131131
'--cacheable',
132132
'--replicated',
133+
'--availability-zone',
134+
'az1',
133135
self.new_volume_type.name,
134136
]
135137
verifylist = [
136138
('properties', {'myprop': 'myvalue'}),
137139
('multiattach', True),
138140
('cacheable', True),
139141
('replicated', True),
142+
('availability_zones', ['az1']),
140143
('name', self.new_volume_type.name),
141144
]
142145
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -151,6 +154,7 @@ def test_type_create_with_properties(self):
151154
'multiattach': '<is> True',
152155
'cacheable': '<is> True',
153156
'replication_enabled': '<is> True',
157+
'RESKEY:availability_zones': 'az1',
154158
}
155159
)
156160

@@ -440,6 +444,8 @@ def test_type_list_with_properties(self):
440444
"--multiattach",
441445
"--cacheable",
442446
"--replicated",
447+
"--availability-zone",
448+
"az1",
443449
]
444450
verifylist = [
445451
("encryption_type", False),
@@ -450,6 +456,7 @@ def test_type_list_with_properties(self):
450456
("multiattach", True),
451457
("cacheable", True),
452458
("replicated", True),
459+
("availability_zones", ["az1"]),
453460
]
454461
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
455462

@@ -461,6 +468,7 @@ def test_type_list_with_properties(self):
461468
"multiattach": "<is> True",
462469
"cacheable": "<is> True",
463470
"replication_enabled": "<is> True",
471+
"RESKEY:availability_zones": "az1",
464472
}
465473
},
466474
is_public=None,
@@ -605,6 +613,8 @@ def test_type_set_property(self):
605613
'--multiattach',
606614
'--cacheable',
607615
'--replicated',
616+
'--availability-zone',
617+
'az1',
608618
self.volume_type.id,
609619
]
610620
verifylist = [
@@ -614,6 +624,7 @@ def test_type_set_property(self):
614624
('multiattach', True),
615625
('cacheable', True),
616626
('replicated', True),
627+
('availability_zones', ['az1']),
617628
('volume_type', self.volume_type.id),
618629
]
619630
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -627,6 +638,7 @@ def test_type_set_property(self):
627638
'multiattach': '<is> True',
628639
'cacheable': '<is> True',
629640
'replication_enabled': '<is> True',
641+
'RESKEY:availability_zones': 'az1',
630642
}
631643
)
632644
self.volume_type_access_mock.add_project_access.assert_not_called()

openstackclient/volume/v2/volume_type.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ def get_parser(self, prog_name):
176176
"(requires driver support)"
177177
),
178178
)
179+
parser.add_argument(
180+
'--availability-zone',
181+
action='append',
182+
dest='availability_zones',
183+
help=_(
184+
"Set an availability zone for this volume type "
185+
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
186+
"(repeat option to set multiple availabilty zones)"
187+
),
188+
)
179189
parser.add_argument(
180190
'--project',
181191
metavar='<project>',
@@ -274,6 +284,10 @@ def take_action(self, parsed_args):
274284
properties['cacheable'] = '<is> True'
275285
if parsed_args.replicated:
276286
properties['replication_enabled'] = '<is> True'
287+
if parsed_args.availability_zones:
288+
properties['RESKEY:availability_zones'] = ','.join(
289+
parsed_args.availability_zones
290+
)
277291
if properties:
278292
result = volume_type.set_keys(properties)
279293
volume_type._info.update(
@@ -435,6 +449,16 @@ def get_parser(self, prog_name):
435449
"(supported by --os-volume-api-version 3.52 or above)"
436450
),
437451
)
452+
parser.add_argument(
453+
'--availability-zone',
454+
action='append',
455+
dest='availability_zones',
456+
help=_(
457+
"List only volume types with this availability configured "
458+
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
459+
"(repeat option to filter on multiple availabilty zones)"
460+
),
461+
)
438462
return parser
439463

440464
def take_action(self, parsed_args):
@@ -472,6 +496,10 @@ def take_action(self, parsed_args):
472496
properties['cacheable'] = '<is> True'
473497
if parsed_args.replicated:
474498
properties['replication_enabled'] = '<is> True'
499+
if parsed_args.availability_zones:
500+
properties['RESKEY:availability_zones'] = ','.join(
501+
parsed_args.availability_zones
502+
)
475503
if properties:
476504
if volume_client.api_version < api_versions.APIVersion('3.52'):
477505
msg = _(
@@ -590,6 +618,16 @@ def get_parser(self, prog_name):
590618
"(requires driver support)"
591619
),
592620
)
621+
parser.add_argument(
622+
'--availability-zone',
623+
action='append',
624+
dest='availability_zones',
625+
help=_(
626+
"Set an availability zone for this volume type "
627+
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
628+
"(repeat option to set multiple availabilty zones)"
629+
),
630+
)
593631
parser.add_argument(
594632
'--project',
595633
metavar='<project>',
@@ -706,6 +744,10 @@ def take_action(self, parsed_args):
706744
properties['cacheable'] = '<is> True'
707745
if parsed_args.replicated:
708746
properties['replication_enabled'] = '<is> True'
747+
if parsed_args.availability_zones:
748+
properties['RESKEY:availability_zones'] = ','.join(
749+
parsed_args.availability_zones
750+
)
709751
if properties:
710752
try:
711753
volume_type.set_keys(properties)

releasenotes/notes/volume-type-extra-specs-22a22fcb6e269832.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
features:
33
- |
44
The ``volume type create``, ``volume type set``, ``volume type list``
5-
commands now accept three new options - ``--multiattach``, ``--cacheable``,
6-
and ``--replicated`` - which are short cuts for setting or filtering on
7-
the relevant properties on the volume type.
5+
commands now accept four new options - ``--multiattach``, ``--cacheable``,
6+
``--replicated``, and ``--availability-zone`` - which are short cuts for
7+
setting or filtering on the relevant properties on the volume type.

0 commit comments

Comments
 (0)