aboutsummaryrefslogtreecommitdiffstats
path: root/network/ports/net_ip_list_map.yaml
blob: 6d7b7c162fa612f50510a8f20d7b1b32ab963db1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
heat_template_version: pike

parameters:
  ControlPlaneIpList:
    default: []
    type: comma_delimited_list
  ExternalIpList:
    default: []
    type: comma_delimited_list
  InternalApiIpList:
    default: []
    type: comma_delimited_list
  StorageIpList:
    default: []
    type: comma_delimited_list
  StorageMgmtIpList:
    default: []
    type: comma_delimited_list
  TenantIpList:
    default: []
    type: comma_delimited_list
  ManagementIpList:
    default: []
    type: comma_delimited_list
  EnabledServices:
    default: []
    type: comma_delimited_list
  ServiceNetMap:
    default: {}
    type: json
  ServiceHostnameList:
    default: []
    type: comma_delimited_list
  NetworkHostnameMap:
    default: []
    type: json

  InternalApiNetName:
    default: internal_api
    description: The name of the internal_api network.
    type: string
  ExternalNetName:
    default: external
    description: The name of the external network.
    type: string
  ManagementNetName:
    default: management
    description: The name of the management network.
    type: string
  StorageNetName:
    default: storage
    description: The name of the storage network.
    type: string
  StorageMgmtNetName:
    default: storage_mgmt
    description: The name of the storage_mgmt network.
    type: string
  TenantNetName:
    default: tenant
    description: The name of the tenant network.
    type: string


resources:
   # This adds the extra "services" on for keystone
   # so that keystone_admin_api_network and
   # keystone_public_api_network point to the correct
   # network on the nodes running the "keystone" service
  EnabledServicesValue:
    type: OS::Heat::Value
    properties:
      type: comma_delimited_list
      value:
        yaql:
          expression: let(root => $) -> $.data.extra_services.items().where($[0] in $root.data.enabled_services).select($[1]).flatten() + $root.data.enabled_services
          data:
            enabled_services: {get_param: EnabledServices}
            extra_services:
              # If anything other than keystone needs this
              # then we should add an extra_networks interface
              # to the service templates role_data but for
              # now we hard-code the keystone special case
              keystone:
                - keystone_admin_api
                - keystone_public_api

  NetIpMapValue:
    type: OS::Heat::Value
    properties:
      type: json
      value:
        map_replace:
          - ctlplane: {get_param: ControlPlaneIpList}
            external: {get_param: ExternalIpList}
            internal_api: {get_param: InternalApiIpList}
            storage: {get_param: StorageIpList}
            storage_mgmt: {get_param: StorageMgmtIpList}
            tenant: {get_param: TenantIpList}
            management: {get_param: ManagementIpList}
          - keys:
              external: {get_param: ExternalNetName}
              internal_api: {get_param: InternalApiNetName}
              storage: {get_param: StorageNetName}
              storage_mgmt: {get_param: StorageMgmtNetName}
              tenant: {get_param: TenantNetName}
              management: {get_param: ManagementNetName}

outputs:
  net_ip_map:
    description: >
      A Hash containing a mapping of network names to assigned lists
      of IP addresses.
    value: {get_attr: [NetIpMapValue, value]}
  service_ips:
    description: >
      Map of enabled services to a list of their IP addresses
    value:
      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 isString($[1])))
        data:
          map:
            map_replace:
              - map_replace:
                  - map_merge:
                      repeat:
                        template:
                          SERVICE_node_ips: SERVICE_network
                        for_each:
                          SERVICE: {get_attr: [EnabledServicesValue, value]}
                  - values: {get_param: ServiceNetMap}
              - values: {get_attr: [NetIpMapValue, value]}
  ctlplane_service_ips:
    description: >
      Map of enabled services to a list of their ctlplane IP addresses
    value:
      yaql:
        expression: dict($.data.map.items().where(len($[1]) > 0))
        data:
          map:
            map_merge:
              repeat:
                template:
                  SERVICE_ctlplane_node_ips: {get_param: ControlPlaneIpList}
                for_each:
                  SERVICE: {get_attr: [EnabledServicesValue, value]}
  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
        # therefore we don't want to add any *_node_names to the map
        expression: dict($.data.map.items().where(len($[1]) > 0))
        data:
          map:
            map_merge:
              repeat:
                template:
                  SERVICE_short_node_names: {get_param: ServiceHostnameList}
                for_each:
                    SERVICE: {get_attr: [EnabledServicesValue, value]}
  short_service_bootstrap_hostnames:
    description: >
      Map of enabled services to a list of hostnames where they're running regardless of the network
      Used for bootstrap purposes
    value:
      yaql:
        # If ServiceHostnameList is empty the role is deployed with zero nodes
        # therefore we don't want to add any *_node_names to the map
        expression: dict($.data.map.items().where(len($[1]) > 0))
        data:
          map:
            map_merge:
              repeat:
                template:
                  SERVICE_short_bootstrap_node_name: {get_param: ServiceHostnameList}
                for_each:
                    SERVICE: {get_attr: [EnabledServicesValue, value]}