summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-12-08 17:44:50 +0000
committerGerrit Code Review <review@openstack.org>2016-12-08 17:44:50 +0000
commitb22af88a1923315737924142a6e9df0ed615407b (patch)
tree9f98e166ef5e0ffa681b5d54a695e8278e009c52 /openstackclient
parentb18dcfc4cbaadc30a27550a2bb30f94200645b06 (diff)
parent99ba4f86b0e2a4072f3a3754a5e3a48be29cdfd7 (diff)
downloadpython-openstackclient-b22af88a1923315737924142a6e9df0ed615407b.tar.gz
Merge "Adjust the code sequence in consistency_group.py"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/volume/v2/consistency_group.py87
1 files changed, 42 insertions, 45 deletions
diff --git a/openstackclient/volume/v2/consistency_group.py b/openstackclient/volume/v2/consistency_group.py
index fbeae745..2ffa2581 100644
--- a/openstackclient/volume/v2/consistency_group.py
+++ b/openstackclient/volume/v2/consistency_group.py
@@ -27,51 +27,6 @@ from openstackclient.i18n import _
LOG = logging.getLogger(__name__)
-class DeleteConsistencyGroup(command.Command):
- _description = _("Delete consistency group(s).")
-
- def get_parser(self, prog_name):
- parser = super(DeleteConsistencyGroup, self).get_parser(prog_name)
- parser.add_argument(
- 'consistency_groups',
- metavar='<consistency-group>',
- nargs="+",
- help=_('Consistency group(s) to delete (name or ID)'),
- )
- parser.add_argument(
- '--force',
- action='store_true',
- default=False,
- help=_("Allow delete in state other than error or available"),
- )
- return parser
-
- def take_action(self, parsed_args):
- volume_client = self.app.client_manager.volume
- result = 0
-
- for i in parsed_args.consistency_groups:
- try:
- consistency_group_id = utils.find_resource(
- volume_client.consistencygroups, i).id
- volume_client.consistencygroups.delete(
- consistency_group_id, parsed_args.force)
- except Exception as e:
- result += 1
- LOG.error(_("Failed to delete consistency group with "
- "name or ID '%(consistency_group)s':%(e)s")
- % {'consistency_group': i, 'e': e})
-
- if result > 0:
- total = len(parsed_args.consistency_groups)
- msg = (_("%(result)s of %(total)s consistency groups failed "
- "to delete.") % {'result': result, 'total': total})
- raise exceptions.CommandError(msg)
-
-
-LOG = logging.getLogger(__name__)
-
-
class CreateConsistencyGroup(command.ShowOne):
_description = _("Create new consistency group.")
@@ -154,6 +109,48 @@ class CreateConsistencyGroup(command.ShowOne):
return zip(*sorted(six.iteritems(consistency_group._info)))
+class DeleteConsistencyGroup(command.Command):
+ _description = _("Delete consistency group(s).")
+
+ def get_parser(self, prog_name):
+ parser = super(DeleteConsistencyGroup, self).get_parser(prog_name)
+ parser.add_argument(
+ 'consistency_groups',
+ metavar='<consistency-group>',
+ nargs="+",
+ help=_('Consistency group(s) to delete (name or ID)'),
+ )
+ parser.add_argument(
+ '--force',
+ action='store_true',
+ default=False,
+ help=_("Allow delete in state other than error or available"),
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ volume_client = self.app.client_manager.volume
+ result = 0
+
+ for i in parsed_args.consistency_groups:
+ try:
+ consistency_group_id = utils.find_resource(
+ volume_client.consistencygroups, i).id
+ volume_client.consistencygroups.delete(
+ consistency_group_id, parsed_args.force)
+ except Exception as e:
+ result += 1
+ LOG.error(_("Failed to delete consistency group with "
+ "name or ID '%(consistency_group)s':%(e)s")
+ % {'consistency_group': i, 'e': e})
+
+ if result > 0:
+ total = len(parsed_args.consistency_groups)
+ msg = (_("%(result)s of %(total)s consistency groups failed "
+ "to delete.") % {'result': result, 'total': total})
+ raise exceptions.CommandError(msg)
+
+
class ListConsistencyGroup(command.Lister):
_description = _("List consistency groups.")