diff options
| author | Steve Martinelli <stevemar@ca.ibm.com> | 2015-06-28 23:40:34 -0400 |
|---|---|---|
| committer | Steve Martinelli <stevemar@ca.ibm.com> | 2015-06-28 23:42:55 -0400 |
| commit | 1d51eb82d05bce9b78ad289378e7d656511933d9 (patch) | |
| tree | ad1e9132f6145222547c2a9c5b26cf6f5d4a1f7f /openstackclient | |
| parent | 4c3f2ed73eeb0ee824e3390017e5258d895f5a0c (diff) | |
| download | python-openstackclient-1d51eb82d05bce9b78ad289378e7d656511933d9.tar.gz | |
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
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/volume/v1/qos_specs.py | 208 |
1 files changed, 104 insertions, 104 deletions
diff --git a/openstackclient/volume/v1/qos_specs.py b/openstackclient/volume/v1/qos_specs.py index 634b6297..74429481 100644 --- a/openstackclient/volume/v1/qos_specs.py +++ b/openstackclient/volume/v1/qos_specs.py @@ -26,6 +26,38 @@ from openstackclient.common import parseractions from openstackclient.common import utils +class AssociateQos(command.Command): + """Associate a QoS specification to a volume type""" + + log = logging.getLogger(__name__ + '.AssociateQos') + + def get_parser(self, prog_name): + parser = super(AssociateQos, self).get_parser(prog_name) + parser.add_argument( + 'qos_specs', + metavar='<qos-specs>', + help='QoS specification to modify (name or ID)', + ) + parser.add_argument( + 'volume_type', + metavar='<volume-type>', + help='Volume type to associate the QoS (name or ID)', + ) + return parser + + def take_action(self, parsed_args): + self.log.debug('take_action(%s)', parsed_args) + volume_client = self.app.client_manager.volume + qos_specs = utils.find_resource(volume_client.qos_specs, + parsed_args.qos_specs) + volume_type = utils.find_resource(volume_client.volume_types, + parsed_args.volume_type) + + volume_client.qos_specs.associate(qos_specs.id, volume_type.id) + + return + + class CreateQos(show.ShowOne): """Create new QoS specification""" @@ -95,6 +127,49 @@ class DeleteQos(command.Command): return +class DisassociateQos(command.Command): + """Disassociate a QoS specification from a volume type""" + + log = logging.getLogger(__name__ + '.DisassociateQos') + + def get_parser(self, prog_name): + parser = super(DisassociateQos, self).get_parser(prog_name) + parser.add_argument( + 'qos_specs', + metavar='<qos-specs>', + help='QoS specification to modify (name or ID)', + ) + volume_type_group = parser.add_mutually_exclusive_group() + volume_type_group.add_argument( + '--volume-type', + metavar='<volume-type>', + help='Volume type to disassociate the QoS from (name or ID)', + ) + volume_type_group.add_argument( + '--all', + action='store_true', + default=False, + help='Disassociate the QoS from every volume type', + ) + + return parser + + def take_action(self, parsed_args): + self.log.debug('take_action(%s)', parsed_args) + volume_client = self.app.client_manager.volume + qos_specs = utils.find_resource(volume_client.qos_specs, + parsed_args.qos_specs) + + if parsed_args.volume_type: + volume_type = utils.find_resource(volume_client.volume_types, + parsed_args.volume_type) + volume_client.qos_specs.disassociate(qos_specs.id, volume_type.id) + elif parsed_args.all: + volume_client.qos_specs.disassociate_all(qos_specs.id) + + return + + class ListQos(lister.Lister): """List QoS specifications""" @@ -127,38 +202,6 @@ class ListQos(lister.Lister): ) for s in qos_specs_list)) -class ShowQos(show.ShowOne): - """Display QoS specification details""" - - log = logging.getLogger(__name__ + '.ShowQos') - - def get_parser(self, prog_name): - parser = super(ShowQos, self).get_parser(prog_name) - parser.add_argument( - 'qos_specs', - metavar='<qos-specs>', - help='QoS specification to display (name or ID)', - ) - return parser - - def take_action(self, parsed_args): - self.log.debug('take_action(%s)', parsed_args) - volume_client = self.app.client_manager.volume - qos_specs = utils.find_resource(volume_client.qos_specs, - parsed_args.qos_specs) - - qos_associations = volume_client.qos_specs.get_associations(qos_specs) - if qos_associations: - associations = [association.name - for association in qos_associations] - qos_specs._info.update({ - 'associations': utils.format_list(associations) - }) - qos_specs._info.update({'specs': utils.format_dict(qos_specs.specs)}) - - return zip(*sorted(six.iteritems(qos_specs._info))) - - class SetQos(command.Command): """Set QoS specification properties""" @@ -195,25 +238,17 @@ class SetQos(command.Command): return -class UnsetQos(command.Command): - """Unset QoS specification properties""" +class ShowQos(show.ShowOne): + """Display QoS specification details""" - log = logging.getLogger(__name__ + '.SetQos') + log = logging.getLogger(__name__ + '.ShowQos') def get_parser(self, prog_name): - parser = super(UnsetQos, self).get_parser(prog_name) + parser = super(ShowQos, self).get_parser(prog_name) parser.add_argument( 'qos_specs', metavar='<qos-specs>', - help='QoS specification to modify (name or ID)', - ) - parser.add_argument( - '--property', - metavar='<key>', - action='append', - default=[], - help='Property to remove from the QoS specification. ' - '(repeat option to unset multiple properties)', + help='QoS specification to display (name or ID)', ) return parser @@ -223,72 +258,38 @@ class UnsetQos(command.Command): qos_specs = utils.find_resource(volume_client.qos_specs, parsed_args.qos_specs) - if parsed_args.property: - volume_client.qos_specs.unset_keys(qos_specs.id, - parsed_args.property) - else: - self.app.log.error("No changes requested\n") + qos_associations = volume_client.qos_specs.get_associations(qos_specs) + if qos_associations: + associations = [association.name + for association in qos_associations] + qos_specs._info.update({ + 'associations': utils.format_list(associations) + }) + qos_specs._info.update({'specs': utils.format_dict(qos_specs.specs)}) - return + return zip(*sorted(six.iteritems(qos_specs._info))) -class AssociateQos(command.Command): - """Associate a QoS specification to a volume type""" +class UnsetQos(command.Command): + """Unset QoS specification properties""" - log = logging.getLogger(__name__ + '.AssociateQos') + log = logging.getLogger(__name__ + '.SetQos') def get_parser(self, prog_name): - parser = super(AssociateQos, self).get_parser(prog_name) + parser = super(UnsetQos, self).get_parser(prog_name) parser.add_argument( 'qos_specs', metavar='<qos-specs>', help='QoS specification to modify (name or ID)', ) parser.add_argument( - 'volume_type', - metavar='<volume-type>', - help='Volume type to associate the QoS (name or ID)', - ) - return parser - - def take_action(self, parsed_args): - self.log.debug('take_action(%s)', parsed_args) - volume_client = self.app.client_manager.volume - qos_specs = utils.find_resource(volume_client.qos_specs, - parsed_args.qos_specs) - volume_type = utils.find_resource(volume_client.volume_types, - parsed_args.volume_type) - - volume_client.qos_specs.associate(qos_specs.id, volume_type.id) - - return - - -class DisassociateQos(command.Command): - """Disassociate a QoS specification from a volume type""" - - log = logging.getLogger(__name__ + '.DisassociateQos') - - def get_parser(self, prog_name): - parser = super(DisassociateQos, self).get_parser(prog_name) - parser.add_argument( - 'qos_specs', - metavar='<qos-specs>', - help='QoS specification to modify (name or ID)', - ) - volume_type_group = parser.add_mutually_exclusive_group() - volume_type_group.add_argument( - '--volume-type', - metavar='<volume-type>', - help='Volume type to disassociate the QoS from (name or ID)', - ) - volume_type_group.add_argument( - '--all', - action='store_true', - default=False, - help='Disassociate the QoS from every volume type', + '--property', + metavar='<key>', + action='append', + default=[], + help='Property to remove from the QoS specification. ' + '(repeat option to unset multiple properties)', ) - return parser def take_action(self, parsed_args): @@ -297,11 +298,10 @@ class DisassociateQos(command.Command): qos_specs = utils.find_resource(volume_client.qos_specs, parsed_args.qos_specs) - if parsed_args.volume_type: - volume_type = utils.find_resource(volume_client.volume_types, - parsed_args.volume_type) - volume_client.qos_specs.disassociate(qos_specs.id, volume_type.id) - elif parsed_args.all: - volume_client.qos_specs.disassociate_all(qos_specs.id) + if parsed_args.property: + volume_client.qos_specs.unset_keys(qos_specs.id, + parsed_args.property) + else: + self.app.log.error("No changes requested\n") return |
