diff options
| author | Jenkins <jenkins@review.openstack.org> | 2016-09-06 03:40:31 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2016-09-06 03:40:31 +0000 |
| commit | 20ad61b9d44daba59a0fd6378ee947621273f15f (patch) | |
| tree | c8f3b6df456f1f33a3b1e4d95225804309c6afbc /openstackclient/volume | |
| parent | 3b75c9aae55356e8f7b2c04e0101ede99d860c1a (diff) | |
| parent | 81431d24a9f94f56c4c39cb12bf846871f6230d8 (diff) | |
| download | python-openstackclient-20ad61b9d44daba59a0fd6378ee947621273f15f.tar.gz | |
Merge "Add "volume service set" command"
Diffstat (limited to 'openstackclient/volume')
| -rw-r--r-- | openstackclient/volume/v1/service.py | 56 | ||||
| -rw-r--r-- | openstackclient/volume/v2/service.py | 56 |
2 files changed, 112 insertions, 0 deletions
diff --git a/openstackclient/volume/v1/service.py b/openstackclient/volume/v1/service.py index 2df38573..867c4b9c 100644 --- a/openstackclient/volume/v1/service.py +++ b/openstackclient/volume/v1/service.py @@ -15,6 +15,7 @@ """Service action implementations""" from osc_lib.command import command +from osc_lib import exceptions from osc_lib import utils from openstackclient.i18n import _ @@ -72,3 +73,58 @@ class ListService(command.Lister): (utils.get_item_properties( s, columns, ) for s in data)) + + +class SetService(command.Command): + """Set volume service properties""" + + def get_parser(self, prog_name): + parser = super(SetService, self).get_parser(prog_name) + parser.add_argument( + "host", + metavar="<host>", + help=_("Name of host") + ) + parser.add_argument( + "service", + metavar="<service>", + help=_("Name of service (Binary name)") + ) + enabled_group = parser.add_mutually_exclusive_group() + enabled_group.add_argument( + "--enable", + action="store_true", + help=_("Enable volume service") + ) + enabled_group.add_argument( + "--disable", + action="store_true", + help=_("Disable volume service") + ) + parser.add_argument( + "--disable-reason", + metavar="<reason>", + help=_("Reason for disabling the service " + "(should be used with --disable option)") + ) + return parser + + def take_action(self, parsed_args): + if parsed_args.disable_reason and not parsed_args.disable: + msg = _("Cannot specify option --disable-reason without " + "--disable specified.") + raise exceptions.CommandError(msg) + + service_client = self.app.client_manager.volume + if parsed_args.enable: + service_client.services.enable( + parsed_args.host, parsed_args.service) + if parsed_args.disable: + if parsed_args.disable_reason: + service_client.services.disable_log_reason( + parsed_args.host, + parsed_args.service, + parsed_args.disable_reason) + else: + service_client.services.disable( + parsed_args.host, parsed_args.service) diff --git a/openstackclient/volume/v2/service.py b/openstackclient/volume/v2/service.py index 2df38573..867c4b9c 100644 --- a/openstackclient/volume/v2/service.py +++ b/openstackclient/volume/v2/service.py @@ -15,6 +15,7 @@ """Service action implementations""" from osc_lib.command import command +from osc_lib import exceptions from osc_lib import utils from openstackclient.i18n import _ @@ -72,3 +73,58 @@ class ListService(command.Lister): (utils.get_item_properties( s, columns, ) for s in data)) + + +class SetService(command.Command): + """Set volume service properties""" + + def get_parser(self, prog_name): + parser = super(SetService, self).get_parser(prog_name) + parser.add_argument( + "host", + metavar="<host>", + help=_("Name of host") + ) + parser.add_argument( + "service", + metavar="<service>", + help=_("Name of service (Binary name)") + ) + enabled_group = parser.add_mutually_exclusive_group() + enabled_group.add_argument( + "--enable", + action="store_true", + help=_("Enable volume service") + ) + enabled_group.add_argument( + "--disable", + action="store_true", + help=_("Disable volume service") + ) + parser.add_argument( + "--disable-reason", + metavar="<reason>", + help=_("Reason for disabling the service " + "(should be used with --disable option)") + ) + return parser + + def take_action(self, parsed_args): + if parsed_args.disable_reason and not parsed_args.disable: + msg = _("Cannot specify option --disable-reason without " + "--disable specified.") + raise exceptions.CommandError(msg) + + service_client = self.app.client_manager.volume + if parsed_args.enable: + service_client.services.enable( + parsed_args.host, parsed_args.service) + if parsed_args.disable: + if parsed_args.disable_reason: + service_client.services.disable_log_reason( + parsed_args.host, + parsed_args.service, + parsed_args.disable_reason) + else: + service_client.services.disable( + parsed_args.host, parsed_args.service) |
