Browse Source

Merge "Remove mistral dependency for password generation completely"

tags/12.3.0
Zuul 3 months ago
committed by Gerrit Code Review
parent
commit
21b430b932
4 changed files with 8 additions and 37 deletions
  1. +2
    -17
      tripleo_common/tests/utils/test_passwords.py
  2. +3
    -14
      tripleo_common/tests/utils/test_plan.py
  3. +2
    -4
      tripleo_common/utils/passwords.py
  4. +1
    -2
      tripleo_common/utils/plan.py

+ 2
- 17
tripleo_common/tests/utils/test_passwords.py View File

@@ -38,12 +38,6 @@ class TestPasswords(base.TestCase):
self.assertEqual(len(key), 40)

def test_get_snmpd_readonly_user_password(self):

mock_mistral = mock.Mock()
mock_mistral.environments.get.return_value = mock.Mock(variables={
"undercloud_ceilometer_snmpd_password": self.snmp_test_pw
})

with mock.patch(self.open_builtins, mock.mock_open(read_data="data")):
with mock.patch('yaml.load') as mock_yaml:
with mock.patch('os.path.exists') as mock_exists:
@@ -53,9 +47,7 @@ class TestPasswords(base.TestCase):
'SnmpdReadonlyUserPassword': self.snmp_test_pw
}
}
value = password_utils.get_snmpd_readonly_user_password(
mock_mistral
)
value = password_utils.get_snmpd_readonly_user_password()

self.assertEqual(value, self.snmp_test_pw)

@@ -70,13 +62,6 @@ class TestPasswords(base.TestCase):
uuidutils.generate_uuid(dashed=False),
uuidutils.generate_uuid(dashed=False)]

snmpd_password = uuidutils.generate_uuid(dashed=False)

mock_mistral = mock.Mock()
mock_mistral.environments.get.return_value = mock.Mock(variables={
"undercloud_ceilometer_snmpd_password": snmpd_password
})

# generate_passwords will be called multiple times
# but the order is based on how the strings are hashed, and thus
# not really predictable. So, make sure it is a unique one of the
@@ -90,7 +75,7 @@ class TestPasswords(base.TestCase):
'SnmpdReadonlyUserPassword': self.snmp_test_pw
}
}
value = password_utils.generate_passwords(mock_mistral)
value = password_utils.generate_passwords()
self.assertIn(value['KeystoneCredential0'], keys)
self.assertIn(value['KeystoneCredential1'], keys)
self.assertIn(value['KeystoneFernetKey0'], keys)


+ 3
- 14
tripleo_common/tests/utils/test_plan.py View File

@@ -630,9 +630,7 @@ class PlanTest(base.TestCase):
}
mock_orchestration.resources.get.return_value = mock_resource

mock_workflow = mock.MagicMock()
result = plan_utils.generate_passwords(swift, mock_orchestration,
mock_workflow)
result = plan_utils.generate_passwords(swift, mock_orchestration)

for password_param_name in constants.PASSWORD_PARAMETER_NAMES:
self.assertTrue(password_param_name in result,
@@ -685,10 +683,7 @@ class PlanTest(base.TestCase):
'parameter_defaults': {}
}

mock_workflow = mock.MagicMock()

result = plan_utils.generate_passwords(swift, mock_orchestration,
mock_workflow)
result = plan_utils.generate_passwords(swift, mock_orchestration)

# ensure old passwords used and no new generation
self.assertEqual(_EXISTING_PASSWORDS, result)
@@ -738,9 +733,7 @@ class PlanTest(base.TestCase):
}
mock_orchestration.resources.get.return_value = mock_resource

mock_workflow = mock.MagicMock()
result = plan_utils.generate_passwords(swift, mock_orchestration,
mock_workflow,
rotate_passwords=True)

# ensure passwords in the DO_NOT_ROTATE_LIST are not modified
@@ -808,9 +801,7 @@ class PlanTest(base.TestCase):
'MysqlRootPassword'
]

mock_workflow = mock.MagicMock()
result = plan_utils.generate_passwords(swift, mock_orchestration,
mock_workflow,
rotate_passwords=True,
rotate_pw_list=rotate_list)

@@ -868,9 +859,7 @@ class PlanTest(base.TestCase):
}
}

mock_workflow = mock.MagicMock()
result = plan_utils.generate_passwords(swift, mock_orchestration,
mock_workflow)
result = plan_utils.generate_passwords(swift, mock_orchestration)

existing_passwords["AdminPassword"] = "ExistingPasswordInHeat"
# ensure old passwords used and no new generation


+ 2
- 4
tripleo_common/utils/passwords.py View File

@@ -34,15 +34,13 @@ KEYSTONE_FERNET_REPO = '/etc/keystone/fernet-keys/'
LOG = logging.getLogger(__name__)


def generate_passwords(mistralclient=None, stack_env=None,
def generate_passwords(stack_env=None,
rotate_passwords=False):
"""Create the passwords needed for deploying OpenStack via t-h-t.

This will create the set of passwords required by the undercloud and
overcloud installers that use tripleo-heat-templates and return them
as a dict. The mistralclient is optional and only used to obtain
the previously stored SnmpdReadonlyUserPassword supplied by the
undercloud to the overcloud deployment.
as a dict.
"""

passwords = {}


+ 1
- 2
tripleo_common/utils/plan.py View File

@@ -372,7 +372,7 @@ def update_plan_environment_with_image_parameters(
return env


def generate_passwords(swift, heat, mistral,
def generate_passwords(swift, heat, mistral=None,
container=constants.DEFAULT_CONTAINER_NAME,
rotate_passwords=False, rotate_pw_list=None):
"""Generates passwords needed for Overcloud deployment
@@ -417,7 +417,6 @@ def generate_passwords(swift, heat, mistral,
stack_env = None

passwords = password_utils.generate_passwords(
mistralclient=mistral,
stack_env=stack_env,
rotate_passwords=rotate_passwords
)


Loading…
Cancel
Save