Correct logic for adding id when processing role
Previously the id was always appended, but when the network names were inherited from the parent data they already had it. This change looks for whether the name already ends in -id and if so it skips the id addition.
This commit is contained in:
parent
40db3d9834
commit
db5c1e4d69
@ -351,11 +351,24 @@ def _process_role(role_file, base_envs, stack_name, args):
|
||||
role_env['parameters']['bmc_prefix'] = '%s-%s' % (bmc_prefix, role)
|
||||
# At this time roles are only attached to a single set of networks, so
|
||||
# we use just the primary network parameters.
|
||||
_add_identifier(role_env, 'provision_net', args.id)
|
||||
_add_identifier(role_env, 'overcloud_internal_net', args.id)
|
||||
_add_identifier(role_env, 'overcloud_storage_net', args.id)
|
||||
_add_identifier(role_env, 'overcloud_storage_mgmt_net', args.id)
|
||||
_add_identifier(role_env, 'overcloud_tenant_net', args.id)
|
||||
def maybe_add_id(role_env, name, args):
|
||||
"""Add id only if one is not already present
|
||||
|
||||
When we inherit network names, they will already have the id present.
|
||||
However, if the user overrides the network name (for example, when
|
||||
using multiple routed networks) then it should not have the id.
|
||||
We can detect which is the case by looking at whether the name already
|
||||
ends with -id.
|
||||
"""
|
||||
if (args.id and
|
||||
not role_env['parameter_defaults'].get(name, '')
|
||||
.endswith('-' + args.id)):
|
||||
_add_identifier(role_env, name, args.id)
|
||||
maybe_add_id(role_env, 'provision_net', args)
|
||||
maybe_add_id(role_env, 'overcloud_internal_net', args)
|
||||
maybe_add_id(role_env, 'overcloud_storage_net', args)
|
||||
maybe_add_id(role_env, 'overcloud_storage_mgmt_net', args)
|
||||
maybe_add_id(role_env, 'overcloud_tenant_net', args)
|
||||
role_env['parameter_defaults']['networks'] = {
|
||||
'private': role_env['parameter_defaults']['private_net'],
|
||||
'provision': role_env['parameter_defaults']['provision_net'],
|
||||
|
@ -192,10 +192,13 @@ class TestIdEnv(unittest.TestCase):
|
||||
# _process_role test data
|
||||
role_base_data = {
|
||||
'parameter_defaults': {
|
||||
'overcloud_storage_mgmt_net': 'storage_mgmt',
|
||||
'overcloud_internal_net': 'internal',
|
||||
'overcloud_storage_net': 'storage',
|
||||
'overcloud_tenant_net': 'tenant',
|
||||
'overcloud_storage_mgmt_net': 'storage_mgmt-foo',
|
||||
'overcloud_internal_net': 'internal-foo',
|
||||
'overcloud_storage_net': 'storage-foo',
|
||||
'overcloud_tenant_net': 'tenant-foo',
|
||||
'provision_net': 'provision-foo',
|
||||
'public_net': 'public-foo',
|
||||
'private_net': 'private',
|
||||
'role': 'control',
|
||||
},
|
||||
'parameters': {
|
||||
@ -205,11 +208,9 @@ role_base_data = {
|
||||
'bmc_image': 'bmc-base',
|
||||
'baremetal_flavor': 'baremetal',
|
||||
'os_auth_url': 'http://1.1.1.1:5000/v2.0',
|
||||
'provision_net': 'provision-foo',
|
||||
'os_password': 'password',
|
||||
'os_tenant': 'admin',
|
||||
'bmc_prefix': 'bmc-foo',
|
||||
'public_net': 'public-foo',
|
||||
'undercloud_image': 'centos7-base',
|
||||
'baremetal_image': 'ipxe-boot',
|
||||
'external_net': 'external',
|
||||
@ -228,9 +229,6 @@ role_base_data = {
|
||||
role_specific_data = {
|
||||
'parameter_defaults': {
|
||||
'role': 'compute',
|
||||
'public_net': 'public',
|
||||
'private_net': 'private',
|
||||
'provision_net': 'provision',
|
||||
},
|
||||
'parameters': {
|
||||
'key_name': 'default',
|
||||
@ -249,6 +247,9 @@ role_original_data = {
|
||||
'parameter_defaults': {
|
||||
'role': 'control',
|
||||
'baremetal_prefix': 'baremetal',
|
||||
'public_net': 'public',
|
||||
'private_net': 'private',
|
||||
'provision_net': 'provision',
|
||||
},
|
||||
'parameters': {
|
||||
'os_user': 'admin',
|
||||
|
Loading…
Reference in New Issue
Block a user