From e1c07fc453e5113782fb0d22cd4a487260f68579 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Wed, 23 Nov 2016 11:26:11 +0000 Subject: [PATCH] Revert changes to CephClusterFSID generation This patch reverts the two commits listed below. There was a problem with CephClusterFSID generation as it was created by the password generation code in Mistral in Newton. However, this password generation didn't work for upgrades as it didn't take into account upgrades and passwords that were in use in an existing Heat stack. This issue was resolved in I3ea6bbd0d9c5dd345b8a4a26a1788326e09d4209. Now when a deployment plan is created, if there is an existing Heat stack it takes the parameters from the Heat stack and uses those, rather than regenerating. This change should also resolve the issue where the CephClusterFSID was regenerated. Revert "Generate CephClusterFSID for new stacks" This reverts commit 20167e850a6bcb1fbb1bfa8cb030000600c3dc27. Revert "Revert "Add CephClusterFSID to generated passwords"" This reverts commit ad64050485f79d2330c68b76a3f21b4c0d9a3e33. Related-Bug: #1636555 Change-Id: I10b5613eda4bd47554a4f5e9f57218010b835fe7 --- tripleo_common/actions/deployment.py | 4 ---- tripleo_common/constants.py | 1 + tripleo_common/tests/actions/test_deployment.py | 10 ++-------- tripleo_common/utils/passwords.py | 11 +++++++++-- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tripleo_common/actions/deployment.py b/tripleo_common/actions/deployment.py index 132801627..b1470b773 100644 --- a/tripleo_common/actions/deployment.py +++ b/tripleo_common/actions/deployment.py @@ -14,9 +14,7 @@ # under the License. import json import logging -import six import time -import uuid from heatclient.common import deployment_utils from heatclient import exc as heat_exc @@ -152,8 +150,6 @@ class DeployStackAction(templates.ProcessTemplatesAction): parameters['DeployIdentifier'] = int(time.time()) parameters['UpdateIdentifier'] = '' parameters['StackAction'] = 'CREATE' if stack_is_new else 'UPDATE' - if stack_is_new: - parameters['CephClusterFSID'] = six.text_type(uuid.uuid1()) if 'parameter_defaults' not in wf_env.variables: wf_env.variables['parameter_defaults'] = {} diff --git a/tripleo_common/constants.py b/tripleo_common/constants.py index 21cd1c8d4..3b69f8ce6 100644 --- a/tripleo_common/constants.py +++ b/tripleo_common/constants.py @@ -63,6 +63,7 @@ PASSWORD_PARAMETER_NAMES = ( 'CeilometerPassword', 'CephAdminKey', 'CephClientKey', + 'CephClusterFSID', 'CephMonKey', 'CephRgwKey', 'CinderPassword', diff --git a/tripleo_common/tests/actions/test_deployment.py b/tripleo_common/tests/actions/test_deployment.py index 51e66864f..d9b2bb0e2 100644 --- a/tripleo_common/tests/actions/test_deployment.py +++ b/tripleo_common/tests/actions/test_deployment.py @@ -194,7 +194,6 @@ class DeployStackActionTest(base.TestCase): def setUp(self,): super(DeployStackActionTest, self).setUp() - @mock.patch('uuid.uuid1') @mock.patch('tripleo_common.actions.deployment.time') @mock.patch('heatclient.common.template_utils.' 'process_multiple_environments_and_files') @@ -209,8 +208,7 @@ class DeployStackActionTest(base.TestCase): mock_get_object_client, mock_get_workflow_client, mock_get_template_contents, mock_process_multiple_environments_and_files, - mock_time, - mock_uuid1): + mock_time): mock_ctx.return_value = mock.MagicMock() # setup swift @@ -242,15 +240,11 @@ class DeployStackActionTest(base.TestCase): # freeze time at datetime.datetime(2016, 9, 8, 16, 24, 24) mock_time.time.return_value = 1473366264 - # fake an uuid1 for CephClusterFSID - mock_uuid1.return_value = 'some-uuid1' - action = deployment.DeployStackAction(1, 'overcloud') action.run() # verify parameters are as expected - expected_defaults = {'CephClusterFSID': 'some-uuid1', - 'DeployIdentifier': 1473366264, + expected_defaults = {'DeployIdentifier': 1473366264, 'StackAction': 'CREATE', 'UpdateIdentifier': '', 'random_existing_data': 'a_value'} diff --git a/tripleo_common/utils/passwords.py b/tripleo_common/utils/passwords.py index 4bd36a37a..84fabf25e 100644 --- a/tripleo_common/utils/passwords.py +++ b/tripleo_common/utils/passwords.py @@ -17,8 +17,11 @@ import logging import os import struct import time +import uuid import passlib.utils as passutils +import six + from tripleo_common import constants @@ -41,9 +44,13 @@ def generate_overcloud_passwords(mistralclient, stack_env=None): # a Heat stack that already exists. if stack_env and name in stack_env.get('parameter_defaults', {}): passwords[name] = stack_env['parameter_defaults'][name] - # CephX keys aren't random strings elif name.startswith("Ceph"): - passwords[name] = create_cephx_key() + if name == "CephClusterFSID": + # The FSID must be a UUID + passwords[name] = six.text_type(uuid.uuid1()) + else: + # CephX keys aren't random strings + passwords[name] = create_cephx_key() # The SnmpdReadonlyUserPassword is stored in a mistral env. elif name == 'SnmpdReadonlyUserPassword': passwords[name] = get_snmpd_readonly_user_password(mistralclient)