Merge "Modify generic role template to support custom networks"

This commit is contained in:
Jenkins 2017-07-10 13:11:52 +00:00 committed by Gerrit Code Review
commit 83defdbdbf
2 changed files with 38 additions and 123 deletions

View File

@ -263,81 +263,32 @@ resources:
RoleUserData: RoleUserData:
type: OS::TripleO::{{role.name}}::NodeUserData type: OS::TripleO::{{role.name}}::NodeUserData
ExternalPort: {%- for network in networks %}
type: OS::TripleO::{{role.name}}::Ports::ExternalPort {{network.name}}Port:
properties: type: OS::TripleO::{{role.name}}::Ports::{{network.name}}Port
ControlPlaneIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
IPPool: {get_param: {{role.name}}IPs}
NodeIndex: {get_param: NodeIndex}
InternalApiPort:
type: OS::TripleO::{{role.name}}::Ports::InternalApiPort
properties:
ControlPlaneIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
IPPool: {get_param: {{role.name}}IPs}
NodeIndex: {get_param: NodeIndex}
StoragePort:
type: OS::TripleO::{{role.name}}::Ports::StoragePort
properties:
ControlPlaneIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
IPPool: {get_param: {{role.name}}IPs}
NodeIndex: {get_param: NodeIndex}
StorageMgmtPort:
type: OS::TripleO::{{role.name}}::Ports::StorageMgmtPort
properties:
ControlPlaneIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
IPPool: {get_param: {{role.name}}IPs}
NodeIndex: {get_param: NodeIndex}
TenantPort:
type: OS::TripleO::{{role.name}}::Ports::TenantPort
properties:
ControlPlaneIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
IPPool: {get_param: {{role.name}}IPs}
NodeIndex: {get_param: NodeIndex}
ManagementPort:
type: OS::TripleO::{{role.name}}::Ports::ManagementPort
properties: properties:
ControlPlaneIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]} ControlPlaneIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
IPPool: {get_param: {{role.name}}IPs} IPPool: {get_param: {{role.name}}IPs}
NodeIndex: {get_param: NodeIndex} NodeIndex: {get_param: NodeIndex}
{%- endfor %}
NetworkConfig: NetworkConfig:
type: OS::TripleO::{{role.name}}::Net::SoftwareConfig type: OS::TripleO::{{role.name}}::Net::SoftwareConfig
properties: properties:
ControlPlaneIp: {get_attr: [{{role.name}}, networks, ctlplane, 0]} ControlPlaneIp: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
ExternalIpSubnet: {get_attr: [ExternalPort, ip_subnet]} {%- for network in networks %}
InternalApiIpSubnet: {get_attr: [InternalApiPort, ip_subnet]} {{network.name}}IpSubnet: {get_attr: [{{network.name}}Port, ip_subnet]}
StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]} {%- endfor %}
StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
TenantIpSubnet: {get_attr: [TenantPort, ip_subnet]}
ManagementIpSubnet: {get_attr: [ManagementPort, ip_subnet]}
NetIpMap: NetIpMap:
type: OS::TripleO::Network::Ports::NetIpMap type: OS::TripleO::Network::Ports::NetIpMap
properties: properties:
ControlPlaneIp: {get_attr: [{{role.name}}, networks, ctlplane, 0]} ControlPlaneIp: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
ExternalIp: {get_attr: [ExternalPort, ip_address]} {%- for network in networks %}
ExternalIpSubnet: {get_attr: [ExternalPort, ip_subnet]} {{network.name}}Ip: {get_attr: [{{network.name}}Port, ip_address]}
ExternalIpUri: {get_attr: [ExternalPort, ip_address_uri]} {{network.name}}IpSubnet: {get_attr: [{{network.name}}Port, ip_subnet]}
InternalApiIp: {get_attr: [InternalApiPort, ip_address]} {{network.name}}IpUri: {get_attr: [{{network.name}}Port, ip_address_uri]}
InternalApiIpSubnet: {get_attr: [InternalApiPort, ip_subnet]} {%- endfor %}
InternalApiIpUri: {get_attr: [InternalApiPort, ip_address_uri]}
StorageIp: {get_attr: [StoragePort, ip_address]}
StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]}
StorageIpUri: {get_attr: [StoragePort, ip_address_uri]}
StorageMgmtIp: {get_attr: [StorageMgmtPort, ip_address]}
StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
StorageMgmtIpUri: {get_attr: [StorageMgmtPort, ip_address_uri]}
TenantIp: {get_attr: [TenantPort, ip_address]}
TenantIpSubnet: {get_attr: [TenantPort, ip_subnet]}
TenantIpUri: {get_attr: [TenantPort, ip_address_uri]}
ManagementIp: {get_attr: [ManagementPort, ip_address]}
ManagementIpSubnet: {get_attr: [ManagementPort, ip_subnet]}
ManagementIpUri: {get_attr: [ManagementPort, ip_address_uri]}
NetHostMap: NetHostMap:
type: OS::Heat::Value type: OS::Heat::Value
@ -593,41 +544,27 @@ outputs:
hostname_map: hostname_map:
description: Mapping of network names to hostnames description: Mapping of network names to hostnames
value: value:
external: {get_attr: [NetHostMap, value, external, fqdn]} {%- for network in networks %}
internal_api: {get_attr: [NetHostMap, value, internal_api, fqdn]} {{network.name_lower|default(network.name.lower())}}: {get_attr: [NetHostMap, value, {{network.name_lower|default(network.name.lower()) }}, fqdn]}
storage: {get_attr: [NetHostMap, value, storage, fqdn]} {%- endfor %}
storage_mgmt: {get_attr: [NetHostMap, value, storage_mgmt, fqdn]}
tenant: {get_attr: [NetHostMap, value, tenant, fqdn]}
management: {get_attr: [NetHostMap, value, management, fqdn]}
ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]} ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
hosts_entry: hosts_entry:
value: value:
str_replace: str_replace:
template: | template: |
PRIMARYIP PRIMARYHOST.DOMAIN PRIMARYHOST PRIMARYIP PRIMARYHOST.DOMAIN PRIMARYHOST
EXTERNALIP EXTERNALHOST.DOMAIN EXTERNALHOST {%- for network in networks %}
INTERNAL_APIIP INTERNAL_APIHOST.DOMAIN INTERNAL_APIHOST {{network.name}}IP {{network.name}}HOST.DOMAIN {{network.name}}HOST
STORAGEIP STORAGEHOST.DOMAIN STORAGEHOST {%- endfor %}
STORAGE_MGMTIP STORAGE_MGMTHOST.DOMAIN STORAGE_MGMTHOST
TENANTIP TENANTHOST.DOMAIN TENANTHOST
MANAGEMENTIP MANAGEMENTHOST.DOMAIN MANAGEMENTHOST
CTLPLANEIP CTLPLANEHOST.DOMAIN CTLPLANEHOST CTLPLANEIP CTLPLANEHOST.DOMAIN CTLPLANEHOST
params: params:
PRIMARYIP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, {{role.name}}HostnameResolveNetwork]}]} PRIMARYIP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, {{role.name}}HostnameResolveNetwork]}]}
DOMAIN: {get_param: CloudDomain} DOMAIN: {get_param: CloudDomain}
PRIMARYHOST: {get_attr: [{{role.name}}, name]} PRIMARYHOST: {get_attr: [{{role.name}}, name]}
EXTERNALIP: {get_attr: [ExternalPort, ip_address]} {%- for network in networks %}
EXTERNALHOST: {get_attr: [NetHostMap, value, external, short]} {{network.name}}IP: {get_attr: [{{network.name}}Port, ip_address]}
INTERNAL_APIIP: {get_attr: [InternalApiPort, ip_address]} {{network.name}}HOST: {get_attr: [NetHostMap, value, {{network.name_lower|default(network.name.lower())}}, short]}
INTERNAL_APIHOST: {get_attr: [NetHostMap, value, internal_api, short]} {%- endfor %}
STORAGEIP: {get_attr: [StoragePort, ip_address]}
STORAGEHOST: {get_attr: [NetHostMap, value, storage, short]}
STORAGE_MGMTIP: {get_attr: [StorageMgmtPort, ip_address]}
STORAGE_MGMTHOST: {get_attr: [NetHostMap, value, storage_mgmt, short]}
TENANTIP: {get_attr: [TenantPort, ip_address]}
TENANTHOST: {get_attr: [NetHostMap, value, tenant, short]}
MANAGEMENTIP: {get_attr: [ManagementPort, ip_address]}
MANAGEMENTHOST: {get_attr: [NetHostMap, value, management, short]}
CTLPLANEIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]} CTLPLANEIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]} CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]}
known_hosts_entry: known_hosts_entry:
@ -635,29 +572,18 @@ outputs:
value: value:
str_replace: str_replace:
template: "PRIMARYIP,PRIMARYHOST.DOMAIN,PRIMARYHOST,\ template: "PRIMARYIP,PRIMARYHOST.DOMAIN,PRIMARYHOST,\
EXTERNALIP,EXTERNALHOST.DOMAIN,EXTERNALHOST,\ {%- for network in networks %}
INTERNAL_APIIP,INTERNAL_APIHOST.DOMAIN,INTERNAL_APIHOST,\ {{network.name}}IP,{{network.name}}HOST.DOMAIN,{{network.name}}HOST,\
STORAGEIP,STORAGEHOST.DOMAIN,STORAGEHOST,\ {%- endfor %}
STORAGE_MGMTIP,STORAGE_MGMTHOST.DOMAIN,STORAGE_MGMTHOST,\
TENANTIP,TENANTHOST.DOMAIN,TENANTHOST,\
MANAGEMENTIP,MANAGEMENTHOST.DOMAIN,MANAGEMENTHOST,\
CTLPLANEIP,CTLPLANEHOST.DOMAIN,CTLPLANEHOST HOSTSSHPUBKEY" CTLPLANEIP,CTLPLANEHOST.DOMAIN,CTLPLANEHOST HOSTSSHPUBKEY"
params: params:
PRIMARYIP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, {{role.name}}HostnameResolveNetwork]}]} PRIMARYIP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, {{role.name}}HostnameResolveNetwork]}]}
DOMAIN: {get_param: CloudDomain} DOMAIN: {get_param: CloudDomain}
PRIMARYHOST: {get_attr: [{{role.name}}, name]} PRIMARYHOST: {get_attr: [{{role.name}}, name]}
EXTERNALIP: {get_attr: [ExternalPort, ip_address]} {%- for network in networks %}
EXTERNALHOST: {get_attr: [NetHostMap, value, external, short]} {{network.name}}IP: {get_attr: [{{network.name}}Port, ip_address]}
INTERNAL_APIIP: {get_attr: [InternalApiPort, ip_address]} {{network.name}}HOST: {get_attr: [NetHostMap, value, {{network.name_lower|default(network.name.lower())}}, short]}
INTERNAL_APIHOST: {get_attr: [NetHostMap, value, internal_api, short]} {%- endfor %}
STORAGEIP: {get_attr: [StoragePort, ip_address]}
STORAGEHOST: {get_attr: [NetHostMap, value, storage, short]}
STORAGE_MGMTIP: {get_attr: [StorageMgmtPort, ip_address]}
STORAGE_MGMTHOST: {get_attr: [NetHostMap, value, storage_mgmt, short]}
TENANTIP: {get_attr: [TenantPort, ip_address]}
TENANTHOST: {get_attr: [NetHostMap, value, tenant, short]}
MANAGEMENTIP: {get_attr: [ManagementPort, ip_address]}
MANAGEMENTHOST: {get_attr: [NetHostMap, value, management, short]}
CTLPLANEIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]} CTLPLANEIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]} CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]}
HOSTSSHPUBKEY: {get_attr: [SshHostPubKey, ecdsa]} HOSTSSHPUBKEY: {get_attr: [SshHostPubKey, ecdsa]}
@ -666,24 +592,11 @@ CTLPLANEIP,CTLPLANEHOST.DOMAIN,CTLPLANEHOST HOSTSSHPUBKEY"
value: value:
{get_resource: {{role.name}}} {get_resource: {{role.name}}}
condition: server_not_blacklisted condition: server_not_blacklisted
external_ip_address:
description: IP address of the server in the external network
value: {get_attr: [ExternalPort, ip_address]}
internal_api_ip_address:
description: IP address of the server in the internal_api network
value: {get_attr: [InternalApiPort, ip_address]}
storage_ip_address:
description: IP address of the server in the storage network
value: {get_attr: [StoragePort, ip_address]}
storage_mgmt_ip_address:
description: IP address of the server in the storage_mgmt network
value: {get_attr: [StorageMgmtPort, ip_address]}
tenant_ip_address:
description: IP address of the server in the tenant network
value: {get_attr: [TenantPort, ip_address]}
management_ip_address:
description: IP address of the server in the management network
value: {get_attr: [ManagementPort, ip_address]}
os_collect_config: os_collect_config:
description: The os-collect-config configuration associated with this server resource description: The os-collect-config configuration associated with this server resource
value: {get_attr: [{{role.name}}, os_collect_config]} value: {get_attr: [{{role.name}}, os_collect_config]}
{%- for network in networks %}
{{network.name_lower|default(network.name.lower())}}_ip_address:
description: IP address of the server in the {{network.name}} network
value: {get_attr: [{{network.name}}Port, ip_address]}
{%- endfor %}

View File

@ -146,13 +146,15 @@ def process_templates(template_path, role_data_path, output_dir,
out_f_path = os.path.join(out_dir, out_f) out_f_path = os.path.join(out_dir, out_f)
if not (out_f_path in excl_templates): if not (out_f_path in excl_templates):
if '{{role.name}}' in template_data: if '{{role.name}}' in template_data:
j2_data = {'role': r_map[role]} j2_data = {'role': r_map[role],
'networks': network_data}
_j2_render_to_file(template_data, j2_data, _j2_render_to_file(template_data, j2_data,
out_f_path, overwrite) out_f_path, overwrite)
else: else:
# Backwards compatibility with templates # Backwards compatibility with templates
# that specify {{role}} vs {{role.name}} # that specify {{role}} vs {{role.name}}
j2_data = {'role': role} j2_data = {'role': role,
'networks': network_data}
# (dprince) For the undercloud installer we # (dprince) For the undercloud installer we
# don'twant to have heat check nova/glance # don'twant to have heat check nova/glance
# API's # API's