Select per-network hostnames for service_node_names
authorSteven Hardy <shardy@redhat.com>
Wed, 28 Sep 2016 15:19:56 +0000 (16:19 +0100)
committerJuan Antonio Osorio Robles <jaosorior@redhat.com>
Wed, 5 Oct 2016 13:24:54 +0000 (16:24 +0300)
Co-Authored-By: Juan Antonio Osorio Robles <jaosorior@redhat.com>
Depends-On: Ic6fec1057439ed9122d44ef294be890d3ff8a8ee
Change-Id: I754c4a41d8a294a4c7c18bd282ae014efd4b9b16
Closes-Bug: #1628521

network/ports/net_ip_list_map.yaml
overcloud.j2.yaml
puppet/all-nodes-config.yaml
puppet/blockstorage-role.yaml
puppet/cephstorage-role.yaml
puppet/compute-role.yaml
puppet/controller-role.yaml
puppet/objectstorage-role.yaml

index 346059f..d7863e0 100644 (file)
@@ -31,6 +31,9 @@ parameters:
   ServiceHostnameList:
     default: []
     type: comma_delimited_list
+  NetworkHostnameMap:
+    default: []
+    type: json
 
 resources:
    # This adds the extra "services" on for keystone
@@ -100,6 +103,28 @@ outputs:
   service_hostnames:
     description: >
       Map of enabled services to a list of hostnames where they're running
+    value:
+      map_replace:
+        - yaql:
+            # This filters any entries where the value hasn't been substituted for
+            # a list, e.g it's still $service_network.  This happens when there is
+            # no network defined for the service in the ServiceNetMap, which is OK
+            # as not all services have to be bound to a network, so we filter them
+            expression: dict($.data.map.items().where(not $[1].endsWith("_network")))
+            data:
+              map:
+                map_replace:
+                  - map_merge:
+                      repeat:
+                        template:
+                          SERVICE_node_names: SERVICE_network
+                        for_each:
+                          SERVICE: {get_attr: [EnabledServicesValue, value]}
+                  - values: {get_param: ServiceNetMap}
+        - values: {get_param: NetworkHostnameMap}
+  short_service_hostnames:
+    description: >
+      Map of enabled services to a list of hostnames where they're running regardless of the network
     value:
       yaql:
         # If ServiceHostnameList is empty the role is deployed with zero nodes
@@ -110,6 +135,6 @@ outputs:
             map_merge:
               repeat:
                 template:
-                  SERVICE_node_names: {get_param: ServiceHostnameList}
+                  SERVICE_short_node_names: {get_param: ServiceHostnameList}
                 for_each:
                     SERVICE: {get_attr: [EnabledServicesValue, value]}
index fc75661..48c741c 100644 (file)
@@ -245,6 +245,15 @@ resources:
       EnabledServices: {get_attr: [{{role.name}}ServiceChain, role_data, service_names]}
       ServiceNetMap: {get_attr: [ServiceNetMap, service_net_map_lower]}
       ServiceHostnameList: {get_attr: [{{role.name}}, hostname]}
+      NetworkHostnameMap:
+        # Note (shardy) this somewhat complex yaql may be replaced
+        # with a map_deep_merge function in ocata.  It merges the
+        # list of maps, but appends to colliding lists so we can
+        # create a map of lists for all nodes for each network
+        yaql:
+          expression: dict($.data.where($ != null).flatten().selectMany($.items()).groupBy($[0], $[1], [$[0], $[1].flatten()]))
+          data:
+            - {get_attr: [{{role.name}}, hostname_map]}
 
   {{role.name}}:
     type: OS::Heat::ResourceGroup
@@ -337,6 +346,14 @@ resources:
             l:
 {% for role in roles %}
               - {get_attr: [{{role.name}}IpListMap, service_hostnames]}
+{% endfor %}
+      short_service_node_names:
+        yaql:
+          expression: dict($.data.l.where($ != null).selectMany($.items()).groupBy($[0], $[1], [$[0], $[1].flatten()]))
+          data:
+            l:
+{% for role in roles %}
+              - {get_attr: [{{role.name}}IpListMap, short_service_hostnames]}
 {% endfor %}
       # FIXME(shardy): These require further work to move into service_ips
       memcache_node_ips: {get_attr: [ControllerIpListMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, MemcachedNetwork]}]}
index 67dc056..cddd99d 100644 (file)
@@ -24,6 +24,8 @@ parameters:
     type: json
   service_node_names:
     type: json
+  short_service_node_names:
+    type: json
   controller_names:
     type: comma_delimited_list
   memcache_node_ips:
@@ -122,6 +124,7 @@ resources:
                   # provides a mapping of service_name_ips to a list of IPs
                   - {get_param: service_ips}
                   - {get_param: service_node_names}
+                  - {get_param: short_service_node_names}
                   - controller_node_ips:
                       list_join:
                       - ','
index a66ea08..2b197a2 100644 (file)
@@ -315,6 +315,51 @@ outputs:
   hostname:
     description: Hostname of the server
     value: {get_attr: [BlockStorage, name]}
+  hostname_map:
+    description: Mapping of network names to hostnames
+    value:
+      external:
+        list_join:
+        - '.'
+        - - {get_attr: [BlockStorage, name]}
+          - external
+          - {get_param: CloudDomain}
+      internal_api:
+        list_join:
+        - '.'
+        - - {get_attr: [BlockStorage, name]}
+          - internalapi
+          - {get_param: CloudDomain}
+      storage:
+        list_join:
+        - '.'
+        - - {get_attr: [BlockStorage, name]}
+          - storage
+          - {get_param: CloudDomain}
+      storage_mgmt:
+        list_join:
+        - '.'
+        - - {get_attr: [BlockStorage, name]}
+          - storagemgmt
+          - {get_param: CloudDomain}
+      tenant:
+        list_join:
+        - '.'
+        - - {get_attr: [BlockStorage, name]}
+          - tenant
+          - {get_param: CloudDomain}
+      management:
+        list_join:
+        - '.'
+        - - {get_attr: [BlockStorage, name]}
+          - management
+          - {get_param: CloudDomain}
+      ctlplane:
+        list_join:
+        - '.'
+        - - {get_attr: [BlockStorage, name]}
+          - ctlplane
+          - {get_param: CloudDomain}
   hosts_entry:
     value:
       str_replace:
index 03a53b0..3716f9e 100644 (file)
@@ -325,6 +325,51 @@ outputs:
   hostname:
     description: Hostname of the server
     value: {get_attr: [CephStorage, name]}
+  hostname_map:
+    description: Mapping of network names to hostnames
+    value:
+      external:
+        list_join:
+        - '.'
+        - - {get_attr: [CephStorage, name]}
+          - external
+          - {get_param: CloudDomain}
+      internal_api:
+        list_join:
+        - '.'
+        - - {get_attr: [CephStorage, name]}
+          - internalapi
+          - {get_param: CloudDomain}
+      storage:
+        list_join:
+        - '.'
+        - - {get_attr: [CephStorage, name]}
+          - storage
+          - {get_param: CloudDomain}
+      storage_mgmt:
+        list_join:
+        - '.'
+        - - {get_attr: [CephStorage, name]}
+          - storagemgmt
+          - {get_param: CloudDomain}
+      tenant:
+        list_join:
+        - '.'
+        - - {get_attr: [CephStorage, name]}
+          - tenant
+          - {get_param: CloudDomain}
+      management:
+        list_join:
+        - '.'
+        - - {get_attr: [CephStorage, name]}
+          - management
+          - {get_param: CloudDomain}
+      ctlplane:
+        list_join:
+        - '.'
+        - - {get_attr: [CephStorage, name]}
+          - ctlplane
+          - {get_param: CloudDomain}
   hosts_entry:
     value:
       str_replace:
index 0205d0a..ff30d20 100644 (file)
@@ -368,6 +368,51 @@ outputs:
   hostname:
     description: Hostname of the server
     value: {get_attr: [NovaCompute, name]}
+  hostname_map:
+    description: Mapping of network names to hostnames
+    value:
+      external:
+        list_join:
+        - '.'
+        - - {get_attr: [NovaCompute, name]}
+          - external
+          - {get_param: CloudDomain}
+      internal_api:
+        list_join:
+        - '.'
+        - - {get_attr: [NovaCompute, name]}
+          - internalapi
+          - {get_param: CloudDomain}
+      storage:
+        list_join:
+        - '.'
+        - - {get_attr: [NovaCompute, name]}
+          - storage
+          - {get_param: CloudDomain}
+      storage_mgmt:
+        list_join:
+        - '.'
+        - - {get_attr: [NovaCompute, name]}
+          - storagemgmt
+          - {get_param: CloudDomain}
+      tenant:
+        list_join:
+        - '.'
+        - - {get_attr: [NovaCompute, name]}
+          - tenant
+          - {get_param: CloudDomain}
+      management:
+        list_join:
+        - '.'
+        - - {get_attr: [NovaCompute, name]}
+          - management
+          - {get_param: CloudDomain}
+      ctlplane:
+        list_join:
+        - '.'
+        - - {get_attr: [NovaCompute, name]}
+          - ctlplane
+          - {get_param: CloudDomain}
   hosts_entry:
     description: >
       Server's IP address and hostname in the /etc/hosts format
index ccb517f..e18126f 100644 (file)
@@ -411,6 +411,51 @@ outputs:
   hostname:
     description: Hostname of the server
     value: {get_attr: [Controller, name]}
+  hostname_map:
+    description: Mapping of network names to hostnames
+    value:
+      external:
+        list_join:
+        - '.'
+        - - {get_attr: [Controller, name]}
+          - external
+          - {get_param: CloudDomain}
+      internal_api:
+        list_join:
+        - '.'
+        - - {get_attr: [Controller, name]}
+          - internalapi
+          - {get_param: CloudDomain}
+      storage:
+        list_join:
+        - '.'
+        - - {get_attr: [Controller, name]}
+          - storage
+          - {get_param: CloudDomain}
+      storage_mgmt:
+        list_join:
+        - '.'
+        - - {get_attr: [Controller, name]}
+          - storagemgmt
+          - {get_param: CloudDomain}
+      tenant:
+        list_join:
+        - '.'
+        - - {get_attr: [Controller, name]}
+          - tenant
+          - {get_param: CloudDomain}
+      management:
+        list_join:
+        - '.'
+        - - {get_attr: [Controller, name]}
+          - management
+          - {get_param: CloudDomain}
+      ctlplane:
+        list_join:
+        - '.'
+        - - {get_attr: [Controller, name]}
+          - ctlplane
+          - {get_param: CloudDomain}
   hosts_entry:
     description: >
       Server's IP address and hostname in the /etc/hosts format
index 899ba66..0914c91 100644 (file)
@@ -314,6 +314,51 @@ outputs:
   hostname:
     description: Hostname of the server
     value: {get_attr: [SwiftStorage, name]}
+  hostname_map:
+    description: Mapping of network names to hostnames
+    value:
+      external:
+        list_join:
+        - '.'
+        - - {get_attr: [SwiftStorage, name]}
+          - external
+          - {get_param: CloudDomain}
+      internal_api:
+        list_join:
+        - '.'
+        - - {get_attr: [SwiftStorage, name]}
+          - internalapi
+          - {get_param: CloudDomain}
+      storage:
+        list_join:
+        - '.'
+        - - {get_attr: [SwiftStorage, name]}
+          - storage
+          - {get_param: CloudDomain}
+      storage_mgmt:
+        list_join:
+        - '.'
+        - - {get_attr: [SwiftStorage, name]}
+          - storagemgmt
+          - {get_param: CloudDomain}
+      tenant:
+        list_join:
+        - '.'
+        - - {get_attr: [SwiftStorage, name]}
+          - tenant
+          - {get_param: CloudDomain}
+      management:
+        list_join:
+        - '.'
+        - - {get_attr: [SwiftStorage, name]}
+          - management
+          - {get_param: CloudDomain}
+      ctlplane:
+        list_join:
+        - '.'
+        - - {get_attr: [SwiftStorage, name]}
+          - ctlplane
+          - {get_param: CloudDomain}
   hosts_entry:
     value:
       str_replace: