Fix population of username, public keys
The expand function was failing to add the username and public keys to the instances list. This change treats these arguments like other defaults, and adds tests to confirm they're ending up in the instances list. This change also has a minor fix to the unprovision prompt validation logic. Change-Id: I603623511e4061e782a65d53a3118d211ea6e708
This commit is contained in:
parent
a70139e5b9
commit
967da6836e
|
@ -130,6 +130,11 @@ def expand(roles, stack_name, expand_provisioned=True, default_image=None,
|
|||
role['defaults'].setdefault('image', default_image)
|
||||
if default_network:
|
||||
role['defaults'].setdefault('nics', default_network)
|
||||
if ssh_public_keys:
|
||||
role['defaults'].setdefault('ssh_public_keys', ssh_public_keys)
|
||||
if user_name:
|
||||
role['defaults'].setdefault('user_name', user_name)
|
||||
|
||||
for inst in role.get('instances', []):
|
||||
for k, v in role['defaults'].items():
|
||||
inst.setdefault(k, v)
|
||||
|
@ -170,11 +175,6 @@ def expand(roles, stack_name, expand_provisioned=True, default_image=None,
|
|||
if inst.get('hostname') in potential_gen_names:
|
||||
hostname_map[inst['hostname']] = inst['hostname']
|
||||
|
||||
if ssh_public_keys:
|
||||
inst['ssh_public_keys'] = ssh_public_keys
|
||||
if user_name:
|
||||
inst['user_name'] = user_name
|
||||
|
||||
role_instances.append(inst)
|
||||
|
||||
# add generated instance entries until the desired count of
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
msg: unprovision_confirm or unprovision_environment is required when prompt is true
|
||||
when:
|
||||
- prompt
|
||||
- unprovision_confirm is undefined or
|
||||
unprovision_environment is undefined
|
||||
- unprovision_confirm is undefined
|
||||
- unprovision_environment is undefined
|
||||
|
||||
tasks:
|
||||
|
||||
|
|
|
@ -143,20 +143,31 @@ class TestExpandRoles(base.TestCase):
|
|||
'hostname_format': 'controller-%index%.example.com'
|
||||
}]
|
||||
instances, environment = bd.expand(
|
||||
roles, 'overcloud', True, self.default_image
|
||||
roles, 'overcloud', True, self.default_image,
|
||||
user_name='heat-admin', ssh_public_keys='aaaa'
|
||||
)
|
||||
self.assertEqual(
|
||||
[
|
||||
{'hostname': 'compute-0.example.com', 'profile': 'compute',
|
||||
'image': {'href': 'overcloud-full'}},
|
||||
'image': {'href': 'overcloud-full'},
|
||||
'ssh_public_keys': 'aaaa',
|
||||
'user_name': 'heat-admin'},
|
||||
{'hostname': 'compute-1.example.com', 'profile': 'compute',
|
||||
'image': {'href': 'overcloud-full'}},
|
||||
'image': {'href': 'overcloud-full'},
|
||||
'ssh_public_keys': 'aaaa',
|
||||
'user_name': 'heat-admin'},
|
||||
{'hostname': 'controller-0.example.com', 'profile': 'control',
|
||||
'image': {'href': 'overcloud-full'}},
|
||||
'image': {'href': 'overcloud-full'},
|
||||
'ssh_public_keys': 'aaaa',
|
||||
'user_name': 'heat-admin'},
|
||||
{'hostname': 'controller-1.example.com', 'profile': 'control',
|
||||
'image': {'href': 'overcloud-full'}},
|
||||
'image': {'href': 'overcloud-full'},
|
||||
'ssh_public_keys': 'aaaa',
|
||||
'user_name': 'heat-admin'},
|
||||
{'hostname': 'controller-2.example.com', 'profile': 'control',
|
||||
'image': {'href': 'overcloud-full'}},
|
||||
'image': {'href': 'overcloud-full'},
|
||||
'ssh_public_keys': 'aaaa',
|
||||
'user_name': 'heat-admin'},
|
||||
],
|
||||
instances)
|
||||
self.assertEqual(
|
||||
|
|
Loading…
Reference in New Issue