From fefc3ba723865307f4cc2ca287eb59faa4e8a5b1 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Thu, 11 Jan 2018 17:39:50 -0500 Subject: [PATCH] Remove deprecated services binary CLI arg The services CLI 'binary' arg was deprecated in Pike via change Idd0d2be960ca0ed59097c10c931da47a1a3e66fb because with cells v2 support in the API, the binary argument for the enable/disable CLIs doesn't make sense as the only binary those work with is 'nova-compute'. So this removes the deprecated argument and hard-codes the value to be 'nova-compute'. Change-Id: I60490f3d74212bb172dccc1c7d337198e1021236 --- .../functional/v2/legacy/test_os_services.py | 14 +++++------ .../tests/functional/v2/test_os_services.py | 8 +++---- novaclient/tests/unit/v2/test_shell.py | 24 +++++-------------- novaclient/v2/shell.py | 20 ++++------------ ...e-service-binary-arg-ec2838214c8c7abc.yaml | 6 +++++ 5 files changed, 25 insertions(+), 47 deletions(-) create mode 100644 releasenotes/notes/remove-service-binary-arg-ec2838214c8c7abc.yaml diff --git a/novaclient/tests/functional/v2/legacy/test_os_services.py b/novaclient/tests/functional/v2/legacy/test_os_services.py index 8af71611d..6a12de2c2 100644 --- a/novaclient/tests/functional/v2/legacy/test_os_services.py +++ b/novaclient/tests/functional/v2/legacy/test_os_services.py @@ -41,13 +41,12 @@ class TestOsServicesNovaClient(base.ClientTestBase): continue host = self._get_column_value_from_single_row_table( self.nova('service-list --binary %s' % serv.binary), 'Host') - service = self.nova('service-disable %s %s' % (host, serv.binary)) - self.addCleanup(self.nova, 'service-enable', - params="%s %s" % (host, serv.binary)) + service = self.nova('service-disable %s' % host) + self.addCleanup(self.nova, 'service-enable', params=host) status = self._get_column_value_from_single_row_table( service, 'Status') self.assertEqual('disabled', status) - service = self.nova('service-enable %s %s' % (host, serv.binary)) + service = self.nova('service-enable %s' % host) status = self._get_column_value_from_single_row_table( service, 'Status') self.assertEqual('enabled', status) @@ -64,10 +63,9 @@ class TestOsServicesNovaClient(base.ClientTestBase): continue host = self._get_column_value_from_single_row_table( self.nova('service-list --binary %s' % serv.binary), 'Host') - service = self.nova('service-disable --reason test_disable %s %s' - % (host, serv.binary)) - self.addCleanup(self.nova, 'service-enable', - params="%s %s" % (host, serv.binary)) + service = self.nova( + 'service-disable --reason test_disable %s' % host) + self.addCleanup(self.nova, 'service-enable', params=host) status = self._get_column_value_from_single_row_table( service, 'Status') log_reason = self._get_column_value_from_single_row_table( diff --git a/novaclient/tests/functional/v2/test_os_services.py b/novaclient/tests/functional/v2/test_os_services.py index 1dba1ad01..40da9f749 100644 --- a/novaclient/tests/functional/v2/test_os_services.py +++ b/novaclient/tests/functional/v2/test_os_services.py @@ -38,15 +38,13 @@ class TestOsServicesNovaClientV211(test_os_services.TestOsServicesNovaClient): host = self._get_column_value_from_single_row_table(service_list, 'Host') - service = self.nova('service-force-down %s %s' - % (host, serv.binary)) + service = self.nova('service-force-down %s' % host) self.addCleanup(self.nova, 'service-force-down --unset', - params="%s %s" % (host, serv.binary)) + params=host) status = self._get_column_value_from_single_row_table( service, 'Forced down') self.assertEqual('True', status) - service = self.nova('service-force-down --unset %s %s' - % (host, serv.binary)) + service = self.nova('service-force-down --unset %s' % host) status = self._get_column_value_from_single_row_table( service, 'Forced down') self.assertEqual('False', status) diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index 6174feff0..5163959a5 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -2369,8 +2369,8 @@ class ShellTest(utils.TestCase): self.assert_called('GET', '/os-services?host=host1&binary=nova-cert') def test_services_enable(self): - self.run_command('service-enable host1 nova-cert') - body = {'host': 'host1', 'binary': 'nova-cert'} + self.run_command('service-enable host1') + body = {'host': 'host1', 'binary': 'nova-compute'} self.assert_called('PUT', '/os-services/enable', body) def test_services_enable_v2_53(self): @@ -2381,15 +2381,9 @@ class ShellTest(utils.TestCase): self.assert_called( 'PUT', '/os-services/%s' % fakes.FAKE_SERVICE_UUID_1, body) - def test_services_enable_default_binary(self): - """Tests that the default binary is nova-compute if not specified.""" - self.run_command('service-enable host1') - body = {'host': 'host1', 'binary': 'nova-compute'} - self.assert_called('PUT', '/os-services/enable', body) - def test_services_disable(self): - self.run_command('service-disable host1 nova-cert') - body = {'host': 'host1', 'binary': 'nova-cert'} + self.run_command('service-disable host1') + body = {'host': 'host1', 'binary': 'nova-compute'} self.assert_called('PUT', '/os-services/disable', body) def test_services_disable_v2_53(self): @@ -2400,15 +2394,9 @@ class ShellTest(utils.TestCase): self.assert_called( 'PUT', '/os-services/%s' % fakes.FAKE_SERVICE_UUID_1, body) - def test_services_disable_default_binary(self): - """Tests that the default binary is nova-compute if not specified.""" - self.run_command('service-disable host1') - body = {'host': 'host1', 'binary': 'nova-compute'} - self.assert_called('PUT', '/os-services/disable', body) - def test_services_disable_with_reason(self): - self.run_command('service-disable host1 nova-cert --reason no_reason') - body = {'host': 'host1', 'binary': 'nova-cert', + self.run_command('service-disable host1 --reason no_reason') + body = {'host': 'host1', 'binary': 'nova-compute', 'disabled_reason': 'no_reason'} self.assert_called('PUT', '/os-services/disable-log-reason', body) diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index 684f8cf28..8ad018c4d 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -3400,13 +3400,9 @@ def do_service_list(cs, args): # values. @api_versions.wraps('2.0', '2.52') @utils.arg('host', metavar='', help=_('Name of host.')) -# TODO(mriedem): Eventually just hard-code the binary to "nova-compute". -@utils.arg('binary', metavar='', help=_('Service binary. The only ' - 'meaningful binary is "nova-compute". (Deprecated)'), - default='nova-compute', nargs='?') def do_service_enable(cs, args): """Enable the service.""" - result = cs.services.enable(args.host, args.binary) + result = cs.services.enable(args.host, 'nova-compute') utils.print_list([result], ['Host', 'Binary', 'Status']) @@ -3423,10 +3419,6 @@ def do_service_enable(cs, args): # values. @api_versions.wraps('2.0', '2.52') @utils.arg('host', metavar='', help=_('Name of host.')) -# TODO(mriedem): Eventually just hard-code the binary to "nova-compute". -@utils.arg('binary', metavar='', help=_('Service binary. The only ' - 'meaningful binary is "nova-compute". (Deprecated)'), - default='nova-compute', nargs='?') @utils.arg( '--reason', metavar='', @@ -3434,12 +3426,12 @@ def do_service_enable(cs, args): def do_service_disable(cs, args): """Disable the service.""" if args.reason: - result = cs.services.disable_log_reason(args.host, args.binary, + result = cs.services.disable_log_reason(args.host, 'nova-compute', args.reason) utils.print_list([result], ['Host', 'Binary', 'Status', 'Disabled Reason']) else: - result = cs.services.disable(args.host, args.binary) + result = cs.services.disable(args.host, 'nova-compute') utils.print_list([result], ['Host', 'Binary', 'Status']) @@ -3465,10 +3457,6 @@ def do_service_disable(cs, args): # values. @api_versions.wraps("2.11", "2.52") @utils.arg('host', metavar='', help=_('Name of host.')) -# TODO(mriedem): Eventually just hard-code the binary to "nova-compute". -@utils.arg('binary', metavar='', help=_('Service binary. The only ' - 'meaningful binary is "nova-compute". (Deprecated)'), - default='nova-compute', nargs='?') @utils.arg( '--unset', dest='force_down', @@ -3477,7 +3465,7 @@ def do_service_disable(cs, args): default=True) def do_service_force_down(cs, args): """Force service to down.""" - result = cs.services.force_down(args.host, args.binary, args.force_down) + result = cs.services.force_down(args.host, 'nova-compute', args.force_down) utils.print_list([result], ['Host', 'Binary', 'Forced down']) diff --git a/releasenotes/notes/remove-service-binary-arg-ec2838214c8c7abc.yaml b/releasenotes/notes/remove-service-binary-arg-ec2838214c8c7abc.yaml new file mode 100644 index 000000000..2a136a23d --- /dev/null +++ b/releasenotes/notes/remove-service-binary-arg-ec2838214c8c7abc.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + The deprecated ``binary`` argument to the ``nova service-enable``, + ``nova service-disable``, and ``nova service-force-down`` commands has been + removed.