Merge "Preserve existing placement password during extraction"
This commit is contained in:
commit
3614cdf8d3
|
@ -627,6 +627,9 @@ class PlanTest(base.TestCase):
|
|||
}
|
||||
mock_resource = mock.MagicMock()
|
||||
mock_resource.attributes = {
|
||||
'endpoint_map': {
|
||||
'PlacementPublic': {}
|
||||
},
|
||||
'value': 'existing_value'
|
||||
}
|
||||
mock_orchestration.resources.get.return_value = mock_resource
|
||||
|
@ -683,6 +686,14 @@ class PlanTest(base.TestCase):
|
|||
mock_orchestration.stacks.environment.return_value = {
|
||||
'parameter_defaults': {}
|
||||
}
|
||||
mock_resource = mock.MagicMock()
|
||||
mock_resource.attributes = {
|
||||
'endpoint_map': {
|
||||
'PlacementPublic': {}
|
||||
},
|
||||
'value': None
|
||||
}
|
||||
mock_orchestration.resources.get.return_value = mock_resource
|
||||
|
||||
result = plan_utils.generate_passwords(swift, mock_orchestration)
|
||||
|
||||
|
@ -694,6 +705,56 @@ class PlanTest(base.TestCase):
|
|||
"tripleo.parameters.get"
|
||||
)
|
||||
|
||||
@mock.patch('tripleo_common.utils.plan.'
|
||||
'cache_delete')
|
||||
@mock.patch('tripleo_common.utils.passwords.'
|
||||
'create_ssh_keypair')
|
||||
@mock.patch('tripleo_common.utils.passwords.'
|
||||
'create_fernet_keys_repo_structure_and_keys')
|
||||
@mock.patch('tripleo_common.utils.passwords.'
|
||||
'get_snmpd_readonly_user_password')
|
||||
def test_placement_passwords_upgrade(self,
|
||||
mock_get_snmpd_readonly_user_password,
|
||||
mock_fernet_keys_setup,
|
||||
mock_create_ssh_keypair,
|
||||
mock_cache):
|
||||
|
||||
mock_get_snmpd_readonly_user_password.return_value = "TestPassword"
|
||||
mock_create_ssh_keypair.return_value = {'public_key': 'Foo',
|
||||
'private_key': 'Bar'}
|
||||
mock_fernet_keys_setup.return_value = {'/tmp/foo': {'content': 'Foo'},
|
||||
'/tmp/bar': {'content': 'Bar'}}
|
||||
|
||||
passwords = _EXISTING_PASSWORDS.copy()
|
||||
|
||||
swift = mock.MagicMock(url="http://test.com")
|
||||
mock_env = yaml.safe_dump({
|
||||
'name': constants.DEFAULT_CONTAINER_NAME,
|
||||
'temp_environment': 'temp_environment',
|
||||
'template': 'template',
|
||||
'environments': [{u'path': u'environments/test.yaml'}],
|
||||
'passwords': passwords
|
||||
}, default_flow_style=False)
|
||||
swift.get_object.return_value = ({}, mock_env)
|
||||
|
||||
mock_orchestration = mock.MagicMock()
|
||||
mock_orchestration.stacks.environment.return_value = {
|
||||
'parameter_defaults': {}
|
||||
}
|
||||
mock_resource = mock.MagicMock()
|
||||
mock_resource.attributes = {
|
||||
'endpoint_map': {},
|
||||
'value': None
|
||||
}
|
||||
mock_orchestration.resources.get.return_value = mock_resource
|
||||
|
||||
result = plan_utils.generate_passwords(swift, mock_orchestration)
|
||||
|
||||
self.assertEqual(
|
||||
passwords['NovaPassword'],
|
||||
result['PlacementPassword']
|
||||
)
|
||||
|
||||
@mock.patch('tripleo_common.utils.plan.'
|
||||
'cache_delete')
|
||||
@mock.patch('tripleo_common.utils.passwords.'
|
||||
|
@ -730,6 +791,9 @@ class PlanTest(base.TestCase):
|
|||
|
||||
mock_resource = mock.MagicMock()
|
||||
mock_resource.attributes = {
|
||||
'endpoint_map': {
|
||||
'PlacementPublic': {}
|
||||
},
|
||||
'value': 'existing_value'
|
||||
}
|
||||
mock_orchestration.resources.get.return_value = mock_resource
|
||||
|
@ -786,8 +850,12 @@ class PlanTest(base.TestCase):
|
|||
mock_orchestration.stacks.environment.return_value = {
|
||||
'parameter_defaults': {}
|
||||
}
|
||||
|
||||
mock_resource = mock.MagicMock()
|
||||
mock_resource.attributes = {
|
||||
'endpoint_map': {
|
||||
'PlacementPublic': {}
|
||||
},
|
||||
'value': 'existing_value'
|
||||
}
|
||||
mock_orchestration.resources.get.return_value = mock_resource
|
||||
|
@ -860,6 +928,15 @@ class PlanTest(base.TestCase):
|
|||
}
|
||||
}
|
||||
|
||||
mock_resource = mock.MagicMock()
|
||||
mock_resource.attributes = {
|
||||
'endpoint_map': {
|
||||
'PlacementPublic': {}
|
||||
},
|
||||
'value': 'existing_value'
|
||||
}
|
||||
mock_orchestration.resources.get.return_value = mock_resource
|
||||
|
||||
result = plan_utils.generate_passwords(swift, mock_orchestration)
|
||||
|
||||
existing_passwords["AdminPassword"] = "ExistingPasswordInHeat"
|
||||
|
|
|
@ -416,6 +416,17 @@ def generate_passwords(swift, heat, mistral=None,
|
|||
except heat_exc.HTTPNotFound:
|
||||
stack_env = None
|
||||
|
||||
try:
|
||||
# We can't rely on the existence of PlacementPassword to
|
||||
# determine if placement extraction has occured as it was added
|
||||
# in stein while the service extraction was delayed to train.
|
||||
# Inspect the endpoint map instead.
|
||||
endpoint_res = heat.resources.get(container, 'EndpointMap')
|
||||
endpoints = endpoint_res.attributes.get('endpoint_map', {})
|
||||
placement_extracted = 'PlacementPublic' in endpoints
|
||||
except heat_exc.HTTPNotFound:
|
||||
placement_extracted = False
|
||||
|
||||
passwords = password_utils.generate_passwords(
|
||||
stack_env=stack_env,
|
||||
rotate_passwords=rotate_passwords
|
||||
|
@ -432,6 +443,15 @@ def generate_passwords(swift, heat, mistral=None,
|
|||
if i not in env['passwords']:
|
||||
env['passwords'][i] = env['passwords']['RabbitPassword']
|
||||
|
||||
# NOTE(owalsh): placement previously used NovaPassword
|
||||
# Default to the same password for PlacementPassword if it is an
|
||||
# upgrade (i.e NovaPassword is set) so we do not need to update the
|
||||
# password in keystone
|
||||
if not placement_extracted and 'NovaPassword' in env['passwords']:
|
||||
LOG.debug('Setting PlacementPassword to NovaPassword')
|
||||
env['passwords']['PlacementPassword'] = \
|
||||
env['passwords']['NovaPassword']
|
||||
|
||||
# ensure all generated passwords are present in plan env,
|
||||
# but respect any values previously generated and stored
|
||||
for name, password in passwords.items():
|
||||
|
|
Loading…
Reference in New Issue