Merge "Remove mistral dependency for password generation completely"
This commit is contained in:
commit
21b430b932
|
@ -38,12 +38,6 @@ class TestPasswords(base.TestCase):
|
||||||
self.assertEqual(len(key), 40)
|
self.assertEqual(len(key), 40)
|
||||||
|
|
||||||
def test_get_snmpd_readonly_user_password(self):
|
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(self.open_builtins, mock.mock_open(read_data="data")):
|
||||||
with mock.patch('yaml.load') as mock_yaml:
|
with mock.patch('yaml.load') as mock_yaml:
|
||||||
with mock.patch('os.path.exists') as mock_exists:
|
with mock.patch('os.path.exists') as mock_exists:
|
||||||
|
@ -53,9 +47,7 @@ class TestPasswords(base.TestCase):
|
||||||
'SnmpdReadonlyUserPassword': self.snmp_test_pw
|
'SnmpdReadonlyUserPassword': self.snmp_test_pw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
value = password_utils.get_snmpd_readonly_user_password(
|
value = password_utils.get_snmpd_readonly_user_password()
|
||||||
mock_mistral
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(value, self.snmp_test_pw)
|
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),
|
||||||
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
|
# generate_passwords will be called multiple times
|
||||||
# but the order is based on how the strings are hashed, and thus
|
# 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
|
# 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
|
'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['KeystoneCredential0'], keys)
|
||||||
self.assertIn(value['KeystoneCredential1'], keys)
|
self.assertIn(value['KeystoneCredential1'], keys)
|
||||||
self.assertIn(value['KeystoneFernetKey0'], keys)
|
self.assertIn(value['KeystoneFernetKey0'], keys)
|
||||||
|
|
|
@ -630,9 +630,7 @@ class PlanTest(base.TestCase):
|
||||||
}
|
}
|
||||||
mock_orchestration.resources.get.return_value = mock_resource
|
mock_orchestration.resources.get.return_value = mock_resource
|
||||||
|
|
||||||
mock_workflow = mock.MagicMock()
|
result = plan_utils.generate_passwords(swift, mock_orchestration)
|
||||||
result = plan_utils.generate_passwords(swift, mock_orchestration,
|
|
||||||
mock_workflow)
|
|
||||||
|
|
||||||
for password_param_name in constants.PASSWORD_PARAMETER_NAMES:
|
for password_param_name in constants.PASSWORD_PARAMETER_NAMES:
|
||||||
self.assertTrue(password_param_name in result,
|
self.assertTrue(password_param_name in result,
|
||||||
|
@ -685,10 +683,7 @@ class PlanTest(base.TestCase):
|
||||||
'parameter_defaults': {}
|
'parameter_defaults': {}
|
||||||
}
|
}
|
||||||
|
|
||||||
mock_workflow = mock.MagicMock()
|
result = plan_utils.generate_passwords(swift, mock_orchestration)
|
||||||
|
|
||||||
result = plan_utils.generate_passwords(swift, mock_orchestration,
|
|
||||||
mock_workflow)
|
|
||||||
|
|
||||||
# ensure old passwords used and no new generation
|
# ensure old passwords used and no new generation
|
||||||
self.assertEqual(_EXISTING_PASSWORDS, result)
|
self.assertEqual(_EXISTING_PASSWORDS, result)
|
||||||
|
@ -738,9 +733,7 @@ class PlanTest(base.TestCase):
|
||||||
}
|
}
|
||||||
mock_orchestration.resources.get.return_value = mock_resource
|
mock_orchestration.resources.get.return_value = mock_resource
|
||||||
|
|
||||||
mock_workflow = mock.MagicMock()
|
|
||||||
result = plan_utils.generate_passwords(swift, mock_orchestration,
|
result = plan_utils.generate_passwords(swift, mock_orchestration,
|
||||||
mock_workflow,
|
|
||||||
rotate_passwords=True)
|
rotate_passwords=True)
|
||||||
|
|
||||||
# ensure passwords in the DO_NOT_ROTATE_LIST are not modified
|
# ensure passwords in the DO_NOT_ROTATE_LIST are not modified
|
||||||
|
@ -808,9 +801,7 @@ class PlanTest(base.TestCase):
|
||||||
'MysqlRootPassword'
|
'MysqlRootPassword'
|
||||||
]
|
]
|
||||||
|
|
||||||
mock_workflow = mock.MagicMock()
|
|
||||||
result = plan_utils.generate_passwords(swift, mock_orchestration,
|
result = plan_utils.generate_passwords(swift, mock_orchestration,
|
||||||
mock_workflow,
|
|
||||||
rotate_passwords=True,
|
rotate_passwords=True,
|
||||||
rotate_pw_list=rotate_list)
|
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)
|
||||||
result = plan_utils.generate_passwords(swift, mock_orchestration,
|
|
||||||
mock_workflow)
|
|
||||||
|
|
||||||
existing_passwords["AdminPassword"] = "ExistingPasswordInHeat"
|
existing_passwords["AdminPassword"] = "ExistingPasswordInHeat"
|
||||||
# ensure old passwords used and no new generation
|
# ensure old passwords used and no new generation
|
||||||
|
|
|
@ -34,15 +34,13 @@ KEYSTONE_FERNET_REPO = '/etc/keystone/fernet-keys/'
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def generate_passwords(mistralclient=None, stack_env=None,
|
def generate_passwords(stack_env=None,
|
||||||
rotate_passwords=False):
|
rotate_passwords=False):
|
||||||
"""Create the passwords needed for deploying OpenStack via t-h-t.
|
"""Create the passwords needed for deploying OpenStack via t-h-t.
|
||||||
|
|
||||||
This will create the set of passwords required by the undercloud and
|
This will create the set of passwords required by the undercloud and
|
||||||
overcloud installers that use tripleo-heat-templates and return them
|
overcloud installers that use tripleo-heat-templates and return them
|
||||||
as a dict. The mistralclient is optional and only used to obtain
|
as a dict.
|
||||||
the previously stored SnmpdReadonlyUserPassword supplied by the
|
|
||||||
undercloud to the overcloud deployment.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
passwords = {}
|
passwords = {}
|
||||||
|
|
|
@ -372,7 +372,7 @@ def update_plan_environment_with_image_parameters(
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def generate_passwords(swift, heat, mistral,
|
def generate_passwords(swift, heat, mistral=None,
|
||||||
container=constants.DEFAULT_CONTAINER_NAME,
|
container=constants.DEFAULT_CONTAINER_NAME,
|
||||||
rotate_passwords=False, rotate_pw_list=None):
|
rotate_passwords=False, rotate_pw_list=None):
|
||||||
"""Generates passwords needed for Overcloud deployment
|
"""Generates passwords needed for Overcloud deployment
|
||||||
|
@ -417,7 +417,6 @@ def generate_passwords(swift, heat, mistral,
|
||||||
stack_env = None
|
stack_env = None
|
||||||
|
|
||||||
passwords = password_utils.generate_passwords(
|
passwords = password_utils.generate_passwords(
|
||||||
mistralclient=mistral,
|
|
||||||
stack_env=stack_env,
|
stack_env=stack_env,
|
||||||
rotate_passwords=rotate_passwords
|
rotate_passwords=rotate_passwords
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue