Make usage of --*-flavor and --*-count an error

The flavor and count CLI params have been deprecated since Newton.
Obviously, we'd like to remove them, but these params are rather
crucial to earlier deployments. As such, we should have these be an
error for a cycle (or two) to give deployers a chance to change their
command lines and get the environment files set up properly.

Depends-On: https://review.openstack.org/#/c/648564/
Change-Id: I94376c5f25c354a9fcdbca11548f7e3eedbd9491
Related-Bug: #1768244
This commit is contained in:
Brad P. Crochet 2018-04-25 09:09:04 -04:00 committed by Alex Schultz
parent 182fd0d615
commit 6666e3def8
3 changed files with 45 additions and 34 deletions

View File

@ -0,0 +1,7 @@
---
deprecations:
- |
The scale and flavor params have been deprecated since Newton. This is the
start of the process to removing these params. The CLI will now throw an
error if any of the old scale and/or flavor params are passed. This check
should be removed in a future release.

View File

@ -118,11 +118,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
self.useFixture(plane_management_fixture)
utils_fixture = deployment.UtilsFixture()
self.useFixture(utils_fixture)
arglist = ['--templates', '--ceph-storage-scale', '3']
arglist = ['--templates']
verifylist = [
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
('ceph_storage_scale', 3)
]
clients = self.app.client_manager
@ -211,12 +209,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
self.useFixture(utils_fixture)
utils_overcloud_fixture = deployment.UtilsOvercloudFixture()
self.useFixture(utils_overcloud_fixture)
arglist = ['--templates', '--ceph-storage-scale', '3',
'--control-flavor', 'oooq_control', '--no-cleanup']
arglist = ['--templates', '--no-cleanup']
verifylist = [
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
('ceph_storage_scale', 3)
]
mock_tmpdir.return_value = self.tmp_dir.path
@ -251,9 +246,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
parameters_env = {
'parameter_defaults': {
'CephStorageCount': 3,
'OvercloudControlFlavor': 'oooq_control',
'OvercloudControllerFlavor': 'oooq_control',
'StackAction': 'CREATE',
'UpdateIdentifier': '',
'DeployIdentifier': ''}}
@ -1155,12 +1147,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
arglist = ['--answers-file', test_answerfile,
'--environment-file', test_env2,
'--block-storage-scale', '3',
'--disable-password-generation']
verifylist = [
('answers_file', test_answerfile),
('environment_files', [test_env2]),
('block_storage_scale', 3),
('disable_password_generation', True)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -1185,8 +1175,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
self.tmp_dir.join('tripleo-heat-templates'))
self.assertIn('Test', call_args[8]['resource_registry'])
self.assertIn('Test2', call_args[8]['resource_registry'])
self.assertEqual(
3, call_args[8]['parameter_defaults']['BlockStorageCount'])
utils_fixture.mock_deploy_tht.assert_called_with()
@ -1244,10 +1232,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_stack = fakes.create_tht_stack()
orchestration_client.stacks.get.return_value = mock_stack
arglist = ['--templates', '--control-scale', '3']
arglist = ['--templates']
verifylist = [
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
('control_scale', 3)
]
clients = self.app.client_manager
@ -1262,6 +1249,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
def _custom_create_params_env(_self, parameters, tht_root,
container_name):
parameters.update({"ControllerCount": 3})
parameter_defaults = {"parameter_defaults": parameters}
return parameter_defaults
@ -1306,12 +1294,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
utils_fixture = deployment.UtilsFixture()
self.useFixture(utils_fixture)
arglist = ['--templates', '--ceph-storage-scale', '3',
'--control-scale', '3', '--ntp-server', 'ntp']
arglist = ['--templates', '--ntp-server', 'ntp']
verifylist = [
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
('ceph_storage_scale', 3),
('control_scale', 3),
]
clients = self.app.client_manager
@ -1350,8 +1335,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
expected_parameters = {
'CephClusterFSID': self.uuid1_value,
'CephStorageCount': 3,
'ControllerCount': 3,
'ExtraConfig': '{}',
'HypervisorNeutronPhysicalBridge': 'br-ex',
'HypervisorNeutronPublicInterface': 'nic1',
@ -1678,6 +1661,19 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_makedirs.assert_called_with(dirname)
mock_open.assert_called()
def test_validate_args_deprecated(self):
arglist = ['--control-scale', '3', '--control-flavor', 'control']
verifylist = [
('control_scale', 3),
('control_flavor', 'control'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaises(oscexc.CommandError,
self.cmd.take_action,
parsed_args)
class TestArgumentValidation(fakes.TestDeployOvercloud):

View File

@ -94,18 +94,6 @@ class DeployOvercloud(command.Command):
param_args = (
('NtpServer', 'ntp_server'),
('ControllerCount', 'control_scale'),
('ComputeCount', 'compute_scale'),
('ObjectStorageCount', 'swift_storage_scale'),
('BlockStorageCount', 'block_storage_scale'),
('CephStorageCount', 'ceph_storage_scale'),
('OvercloudControlFlavor', 'control_flavor'),
('OvercloudControllerFlavor', 'control_flavor'),
('OvercloudComputeFlavor', 'compute_flavor'),
('OvercloudBlockStorageFlavor', 'block_storage_flavor'),
('OvercloudObjectStorageFlavor', 'swift_storage_flavor'),
('OvercloudSwiftStorageFlavor', 'swift_storage_flavor'),
('OvercloudCephStorageFlavor', 'ceph_storage_flavor'),
)
if stack_is_new:
@ -522,6 +510,26 @@ class DeployOvercloud(command.Command):
utils.remove_known_hosts(overcloud_ip_or_fqdn)
def _validate_args(self, parsed_args):
# TODO(bcrochet): This should be removed after Rocky or 'S'.
if any(map(lambda x: getattr(parsed_args, x) is not None, [
'control_scale',
'compute_scale',
'ceph_storage_scale',
'block_storage_scale',
'swift_storage_scale',
'control_flavor',
'compute_flavor',
'ceph_storage_flavor',
'block_storage_flavor',
'swift_storage_flavor'
])):
raise oscexc.CommandError(
"A scale or flavor argument was passed to the command line. "
"These arguments are no longer valid. They MUST be replaced "
"with an environment file that contains a valid "
"parameter_default. Failure to do so may cause possible data "
"loss or a decommisioning of nodes.")
if parsed_args.templates is None and parsed_args.answers_file is None:
raise oscexc.CommandError(
"You must specify either --templates or --answers-file")