Merge "Add --reason for disable service"
This commit is contained in:
commit
c8e4a1407f
@ -50,19 +50,24 @@ Set service command
|
|||||||
.. program:: compute service set
|
.. program:: compute service set
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
os compute service list
|
os compute service set
|
||||||
[--enable | --disable]
|
[--enable | --disable]
|
||||||
|
[--disable-reason <reason>]
|
||||||
<host> <service>
|
<host> <service>
|
||||||
|
|
||||||
.. _compute-service-set:
|
.. _compute-service-set:
|
||||||
.. describe:: --enable
|
.. option:: --enable
|
||||||
|
|
||||||
Enable service (default)
|
Enable service (default)
|
||||||
|
|
||||||
.. describe:: --disable
|
.. option:: --disable
|
||||||
|
|
||||||
Disable service
|
Disable service
|
||||||
|
|
||||||
|
.. option:: --disable-reason <reason>
|
||||||
|
|
||||||
|
Reason for disabling the service (in quotes)
|
||||||
|
|
||||||
.. describe:: <host>
|
.. describe:: <host>
|
||||||
|
|
||||||
Name of host
|
Name of host
|
||||||
|
@ -95,14 +95,24 @@ class SetService(command.Command):
|
|||||||
dest="enabled",
|
dest="enabled",
|
||||||
help="Disable a service",
|
help="Disable a service",
|
||||||
action="store_false")
|
action="store_false")
|
||||||
|
parser.add_argument(
|
||||||
|
"--disable-reason",
|
||||||
|
default=None,
|
||||||
|
metavar="<reason>",
|
||||||
|
help="Reason for disabling the service (in quotas)"
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.compute
|
||||||
|
cs = compute_client.services
|
||||||
|
|
||||||
if parsed_args.enabled:
|
if not parsed_args.enabled:
|
||||||
action = compute_client.services.enable
|
if parsed_args.disable_reason:
|
||||||
|
cs.disable_log_reason(parsed_args.host,
|
||||||
|
parsed_args.service,
|
||||||
|
parsed_args.disable_reason)
|
||||||
else:
|
else:
|
||||||
action = compute_client.services.disable
|
cs.disable(parsed_args.host, parsed_args.service)
|
||||||
|
else:
|
||||||
action(parsed_args.host, parsed_args.service)
|
cs.enable(parsed_args.host, parsed_args.service)
|
||||||
|
@ -153,3 +153,29 @@ class TestServiceSet(TestService):
|
|||||||
compute_fakes.service_binary,
|
compute_fakes.service_binary,
|
||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_service_set_disable_with_reason(self):
|
||||||
|
reason = 'earthquake'
|
||||||
|
arglist = [
|
||||||
|
compute_fakes.service_host,
|
||||||
|
compute_fakes.service_binary,
|
||||||
|
'--disable',
|
||||||
|
'--disable-reason',
|
||||||
|
reason
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('host', compute_fakes.service_host),
|
||||||
|
('service', compute_fakes.service_binary),
|
||||||
|
('enabled', False),
|
||||||
|
('disable_reason', reason)
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.service_mock.disable_log_reason.assert_called_with(
|
||||||
|
compute_fakes.service_host,
|
||||||
|
compute_fakes.service_binary,
|
||||||
|
reason
|
||||||
|
)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add support for the ``--disable-reason`` of ``service set`` command
|
Loading…
Reference in New Issue
Block a user