Skip to content

Commit 1d51eb8

Browse files
author
Steve Martinelli
committed
Alphabetize QoS specs
setup.cfg and the implementation had some functions that were not in alphabetical order. Since the rest of OSC is alphabetized, let's stick to that. Change-Id: Ief5d4694c7b6bc20a0898437b96305885104d45c
1 parent 4c3f2ed commit 1d51eb8

2 files changed

Lines changed: 107 additions & 107 deletions

File tree

‎openstackclient/volume/v1/qos_specs.py‎

Lines changed: 104 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,38 @@
2626
from openstackclient.common import utils
2727

2828

29+
class AssociateQos(command.Command):
30+
"""Associate a QoS specification to a volume type"""
31+
32+
log = logging.getLogger(__name__ + '.AssociateQos')
33+
34+
def get_parser(self, prog_name):
35+
parser = super(AssociateQos, self).get_parser(prog_name)
36+
parser.add_argument(
37+
'qos_specs',
38+
metavar='<qos-specs>',
39+
help='QoS specification to modify (name or ID)',
40+
)
41+
parser.add_argument(
42+
'volume_type',
43+
metavar='<volume-type>',
44+
help='Volume type to associate the QoS (name or ID)',
45+
)
46+
return parser
47+
48+
def take_action(self, parsed_args):
49+
self.log.debug('take_action(%s)', parsed_args)
50+
volume_client = self.app.client_manager.volume
51+
qos_specs = utils.find_resource(volume_client.qos_specs,
52+
parsed_args.qos_specs)
53+
volume_type = utils.find_resource(volume_client.volume_types,
54+
parsed_args.volume_type)
55+
56+
volume_client.qos_specs.associate(qos_specs.id, volume_type.id)
57+
58+
return
59+
60+
2961
class CreateQos(show.ShowOne):
3062
"""Create new QoS specification"""
3163

@@ -95,6 +127,49 @@ def take_action(self, parsed_args):
95127
return
96128

97129

130+
class DisassociateQos(command.Command):
131+
"""Disassociate a QoS specification from a volume type"""
132+
133+
log = logging.getLogger(__name__ + '.DisassociateQos')
134+
135+
def get_parser(self, prog_name):
136+
parser = super(DisassociateQos, self).get_parser(prog_name)
137+
parser.add_argument(
138+
'qos_specs',
139+
metavar='<qos-specs>',
140+
help='QoS specification to modify (name or ID)',
141+
)
142+
volume_type_group = parser.add_mutually_exclusive_group()
143+
volume_type_group.add_argument(
144+
'--volume-type',
145+
metavar='<volume-type>',
146+
help='Volume type to disassociate the QoS from (name or ID)',
147+
)
148+
volume_type_group.add_argument(
149+
'--all',
150+
action='store_true',
151+
default=False,
152+
help='Disassociate the QoS from every volume type',
153+
)
154+
155+
return parser
156+
157+
def take_action(self, parsed_args):
158+
self.log.debug('take_action(%s)', parsed_args)
159+
volume_client = self.app.client_manager.volume
160+
qos_specs = utils.find_resource(volume_client.qos_specs,
161+
parsed_args.qos_specs)
162+
163+
if parsed_args.volume_type:
164+
volume_type = utils.find_resource(volume_client.volume_types,
165+
parsed_args.volume_type)
166+
volume_client.qos_specs.disassociate(qos_specs.id, volume_type.id)
167+
elif parsed_args.all:
168+
volume_client.qos_specs.disassociate_all(qos_specs.id)
169+
170+
return
171+
172+
98173
class ListQos(lister.Lister):
99174
"""List QoS specifications"""
100175

@@ -127,38 +202,6 @@ def take_action(self, parsed_args):
127202
) for s in qos_specs_list))
128203

129204

130-
class ShowQos(show.ShowOne):
131-
"""Display QoS specification details"""
132-
133-
log = logging.getLogger(__name__ + '.ShowQos')
134-
135-
def get_parser(self, prog_name):
136-
parser = super(ShowQos, self).get_parser(prog_name)
137-
parser.add_argument(
138-
'qos_specs',
139-
metavar='<qos-specs>',
140-
help='QoS specification to display (name or ID)',
141-
)
142-
return parser
143-
144-
def take_action(self, parsed_args):
145-
self.log.debug('take_action(%s)', parsed_args)
146-
volume_client = self.app.client_manager.volume
147-
qos_specs = utils.find_resource(volume_client.qos_specs,
148-
parsed_args.qos_specs)
149-
150-
qos_associations = volume_client.qos_specs.get_associations(qos_specs)
151-
if qos_associations:
152-
associations = [association.name
153-
for association in qos_associations]
154-
qos_specs._info.update({
155-
'associations': utils.format_list(associations)
156-
})
157-
qos_specs._info.update({'specs': utils.format_dict(qos_specs.specs)})
158-
159-
return zip(*sorted(six.iteritems(qos_specs._info)))
160-
161-
162205
class SetQos(command.Command):
163206
"""Set QoS specification properties"""
164207

@@ -195,25 +238,17 @@ def take_action(self, parsed_args):
195238
return
196239

197240

198-
class UnsetQos(command.Command):
199-
"""Unset QoS specification properties"""
241+
class ShowQos(show.ShowOne):
242+
"""Display QoS specification details"""
200243

201-
log = logging.getLogger(__name__ + '.SetQos')
244+
log = logging.getLogger(__name__ + '.ShowQos')
202245

203246
def get_parser(self, prog_name):
204-
parser = super(UnsetQos, self).get_parser(prog_name)
247+
parser = super(ShowQos, self).get_parser(prog_name)
205248
parser.add_argument(
206249
'qos_specs',
207250
metavar='<qos-specs>',
208-
help='QoS specification to modify (name or ID)',
209-
)
210-
parser.add_argument(
211-
'--property',
212-
metavar='<key>',
213-
action='append',
214-
default=[],
215-
help='Property to remove from the QoS specification. '
216-
'(repeat option to unset multiple properties)',
251+
help='QoS specification to display (name or ID)',
217252
)
218253
return parser
219254

@@ -223,72 +258,38 @@ def take_action(self, parsed_args):
223258
qos_specs = utils.find_resource(volume_client.qos_specs,
224259
parsed_args.qos_specs)
225260

226-
if parsed_args.property:
227-
volume_client.qos_specs.unset_keys(qos_specs.id,
228-
parsed_args.property)
229-
else:
230-
self.app.log.error("No changes requested\n")
261+
qos_associations = volume_client.qos_specs.get_associations(qos_specs)
262+
if qos_associations:
263+
associations = [association.name
264+
for association in qos_associations]
265+
qos_specs._info.update({
266+
'associations': utils.format_list(associations)
267+
})
268+
qos_specs._info.update({'specs': utils.format_dict(qos_specs.specs)})
231269

232-
return
270+
return zip(*sorted(six.iteritems(qos_specs._info)))
233271

234272

235-
class AssociateQos(command.Command):
236-
"""Associate a QoS specification to a volume type"""
273+
class UnsetQos(command.Command):
274+
"""Unset QoS specification properties"""
237275

238-
log = logging.getLogger(__name__ + '.AssociateQos')
276+
log = logging.getLogger(__name__ + '.SetQos')
239277

240278
def get_parser(self, prog_name):
241-
parser = super(AssociateQos, self).get_parser(prog_name)
279+
parser = super(UnsetQos, self).get_parser(prog_name)
242280
parser.add_argument(
243281
'qos_specs',
244282
metavar='<qos-specs>',
245283
help='QoS specification to modify (name or ID)',
246284
)
247285
parser.add_argument(
248-
'volume_type',
249-
metavar='<volume-type>',
250-
help='Volume type to associate the QoS (name or ID)',
251-
)
252-
return parser
253-
254-
def take_action(self, parsed_args):
255-
self.log.debug('take_action(%s)', parsed_args)
256-
volume_client = self.app.client_manager.volume
257-
qos_specs = utils.find_resource(volume_client.qos_specs,
258-
parsed_args.qos_specs)
259-
volume_type = utils.find_resource(volume_client.volume_types,
260-
parsed_args.volume_type)
261-
262-
volume_client.qos_specs.associate(qos_specs.id, volume_type.id)
263-
264-
return
265-
266-
267-
class DisassociateQos(command.Command):
268-
"""Disassociate a QoS specification from a volume type"""
269-
270-
log = logging.getLogger(__name__ + '.DisassociateQos')
271-
272-
def get_parser(self, prog_name):
273-
parser = super(DisassociateQos, self).get_parser(prog_name)
274-
parser.add_argument(
275-
'qos_specs',
276-
metavar='<qos-specs>',
277-
help='QoS specification to modify (name or ID)',
278-
)
279-
volume_type_group = parser.add_mutually_exclusive_group()
280-
volume_type_group.add_argument(
281-
'--volume-type',
282-
metavar='<volume-type>',
283-
help='Volume type to disassociate the QoS from (name or ID)',
284-
)
285-
volume_type_group.add_argument(
286-
'--all',
287-
action='store_true',
288-
default=False,
289-
help='Disassociate the QoS from every volume type',
286+
'--property',
287+
metavar='<key>',
288+
action='append',
289+
default=[],
290+
help='Property to remove from the QoS specification. '
291+
'(repeat option to unset multiple properties)',
290292
)
291-
292293
return parser
293294

294295
def take_action(self, parsed_args):
@@ -297,11 +298,10 @@ def take_action(self, parsed_args):
297298
qos_specs = utils.find_resource(volume_client.qos_specs,
298299
parsed_args.qos_specs)
299300

300-
if parsed_args.volume_type:
301-
volume_type = utils.find_resource(volume_client.volume_types,
302-
parsed_args.volume_type)
303-
volume_client.qos_specs.disassociate(qos_specs.id, volume_type.id)
304-
elif parsed_args.all:
305-
volume_client.qos_specs.disassociate_all(qos_specs.id)
301+
if parsed_args.property:
302+
volume_client.qos_specs.unset_keys(qos_specs.id,
303+
parsed_args.property)
304+
else:
305+
self.app.log.error("No changes requested\n")
306306

307307
return

‎setup.cfg‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,14 @@ openstack.volume.v1 =
366366
volume_type_set = openstackclient.volume.v1.type:SetVolumeType
367367
volume_type_unset = openstackclient.volume.v1.type:UnsetVolumeType
368368

369+
volume_qos_associate = openstackclient.volume.v1.qos_specs:AssociateQos
369370
volume_qos_create = openstackclient.volume.v1.qos_specs:CreateQos
370371
volume_qos_delete = openstackclient.volume.v1.qos_specs:DeleteQos
372+
volume_qos_disassociate = openstackclient.volume.v1.qos_specs:DisassociateQos
371373
volume_qos_list = openstackclient.volume.v1.qos_specs:ListQos
372-
volume_qos_show = openstackclient.volume.v1.qos_specs:ShowQos
373374
volume_qos_set = openstackclient.volume.v1.qos_specs:SetQos
375+
volume_qos_show = openstackclient.volume.v1.qos_specs:ShowQos
374376
volume_qos_unset = openstackclient.volume.v1.qos_specs:UnsetQos
375-
volume_qos_associate = openstackclient.volume.v1.qos_specs:AssociateQos
376-
volume_qos_disassociate = openstackclient.volume.v1.qos_specs:DisassociateQos
377377

378378
openstack.volume.v2 =
379379
backup_create = openstackclient.volume.v2.backup:CreateBackup

0 commit comments

Comments
 (0)