Skip to content

Commit 718a392

Browse files
committed
Intermediate work on attempting to get Heat to generate arbitrary networks
1 parent 38c3bd5 commit 718a392

File tree

7 files changed

+337
-33
lines changed

7 files changed

+337
-33
lines changed

files/environments/instance-library.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
resource_registry:
33
Cluster::InstanceWithVolume: ../resources/instance-w-volume.yaml
44
Cluster::Instance: ../resources/instance.yaml
5+
6+
# Under development
7+
Cluster::InstanceMultiNet: ../resources/instance-multi.yaml

files/resources/cluster-group.yaml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ parameters:
4343
- "Cluster::NodeNet1WithFIP"
4444
- "Cluster::NodeNet2"
4545
- "Cluster::NodeNet3"
46-
4746
group_idx:
4847
type: number
4948
label: Cluster group index
@@ -72,6 +71,19 @@ conditions:
7271
cluster_group: { get_param: [cluster_groups, {get_param: group_idx}] }
7372

7473
resources:
74+
port_group:
75+
type: OS::Heat::ResourceGroup
76+
properties:
77+
count: { get_param: [cluster_groups, {get_param: group_idx}, num_nodes] }
78+
resource_def:
79+
type:
80+
if:
81+
- nodenet_resource_set
82+
- { get_param: [cluster_groups, {get_param: group_idx}, nodenet_resource ] }
83+
- { get_param: cluster_nodenet_resource }
84+
properties:
85+
cluster_net: { get_param: cluster_net }
86+
7587
node_group:
7688
type: OS::Heat::ResourceGroup
7789
properties:
@@ -104,21 +116,14 @@ resources:
104116
key_name: { get_param: cluster_keypair }
105117
availability_zone: { get_param: cluster_az }
106118
config_drive: { get_param: cluster_config_drive }
107-
cluster_net: { get_param: cluster_net }
108-
# instance_nodenet:
109-
# if:
110-
# - nodenet_resource_set
111-
# - { get_param: [cluster_groups, {get_param: group_idx}, nodenet_resource ] }
112-
# - { get_param: cluster_nodenet_resource }
119+
group_node_ports: { get_attr: [port_group, networks] }
120+
group_node_ips: { get_attr: [port_group, primary_ip] }
121+
node_idx: "%index%"
113122

114123
outputs:
115124
group_data:
116125
description: Instance data for nodes in this group
117126
value:
118127
group: { get_param: [cluster_groups, {get_param: group_idx}, name] }
119128
nodes: { get_attr: [ node_group, instance_data ] }
120-
121-
node_resource:
122-
description: Stig Test
123-
value:
124-
type: { get_param: node_resource }
129+
nodenet: { get_attr: [ port_group, networks ] }

files/resources/instance-multi.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
heat_template_version: pike
3+
4+
description: >
5+
Heat stack containing a Nova instance.
6+
7+
parameters:
8+
name:
9+
type: string
10+
label: Instance name
11+
flavor:
12+
type: string
13+
label: Flavor name or UUID
14+
image:
15+
type: string
16+
label: Image name or UUID
17+
volume_size:
18+
type: number
19+
label: Volume size in GB
20+
volume_type:
21+
type: string
22+
label: Volume type
23+
key_name:
24+
type: string
25+
label: SSH key pair name
26+
availability_zone:
27+
type: string
28+
label: Availability zone
29+
default: nova
30+
config_drive:
31+
type: boolean
32+
label: Whether to provide metadata via a configdrive
33+
default: false
34+
group_node_ports:
35+
type: json
36+
label: Nested list of port resources for all nodes in this group
37+
group_node_ips:
38+
type: json
39+
label: List of primary IPs for all nodes in this group
40+
node_idx:
41+
type: number
42+
label: Resource group index of this node
43+
44+
conditions:
45+
ports_gt_1_yaql:
46+
yaql:
47+
data:
48+
group_node_ports: { get_param: group_node_ports }
49+
expression: $.data.group_node_ports[0].len() > 1
50+
ports_gt_1:
51+
not:
52+
equals:
53+
- ports_gt_1_yaql
54+
- False
55+
56+
ports_gt_2_yaql:
57+
yaql:
58+
data:
59+
group_node_ports: { get_param: group_node_ports }
60+
expression: $.data.group_node_ports[0].len() > 2
61+
ports_gt_2:
62+
not:
63+
equals:
64+
- ports_gt_2_yaql
65+
- False
66+
67+
resources:
68+
69+
instance:
70+
type: OS::Nova::Server
71+
properties:
72+
name: { get_param: name }
73+
flavor: { get_param: flavor }
74+
image: { get_param: image }
75+
key_name: { get_param: key_name }
76+
# FIXME: I would like to do this but Heat does not parse it:
77+
#networks: { get_param: [ group_node_ports, {get_param: node_idx} ] }
78+
#networks:
79+
# list_concat:
80+
# - []
81+
# - { get_param: [ group_node_ports, {get_param: node_idx} ] }
82+
#networks:
83+
# - { get_param: [ group_node_ports, {get_param: node_idx}, 0 ] }
84+
#networks:
85+
# yaql:
86+
# data:
87+
# group_node_ports: { get_param: group_node_ports }
88+
# node_idx: { get_param: node_idx }
89+
# expression: $.data.group_node_ports[$.data.node_idx]
90+
#
91+
# FIXME: this works but is obviously limited to one port:
92+
networks:
93+
- port: { get_param: [ group_node_ports, {get_param: node_idx}, 0, port ] }
94+
#networks:
95+
# list_concat:
96+
# - [port: { get_param: [ group_node_ports, {get_param: node_idx}, 0, port ] }]
97+
# - if:
98+
# - ports_gt_1_yaql
99+
# - [port: { get_param: [ group_node_ports, {get_param: node_idx}, 1, port ] }]
100+
# - []
101+
# - if:
102+
# - False
103+
# - [port: { get_param: [ group_node_ports, {get_param: node_idx}, 2, port ] }]
104+
# - []
105+
106+
availability_zone: { get_param: availability_zone }
107+
config_drive: { get_param: config_drive }
108+
109+
outputs:
110+
OS::stack_id:
111+
description: ID of the Nova instance
112+
value: { get_resource: instance }
113+
114+
instance_data:
115+
description: ID of the primary IP
116+
value:
117+
name: {get_param: name}
118+
ip: {get_param: [group_node_ips, {get_param: node_idx}]}
119+
id: {get_resource: instance}
120+
ports_gt_1: {equals: [ports_gt_1_yaql, True]}

files/resources/instance-w-volume.yaml

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,31 @@ parameters:
3131
type: boolean
3232
label: Whether to provide metadata via a configdrive
3333
default: false
34-
cluster_net:
34+
group_node_ports:
3535
type: json
36-
label: Network names and subnets to which the nodes should be attached
36+
label: Nested list of port resources for all nodes in this group
37+
group_node_ips:
38+
type: json
39+
label: List of primary IPs for all nodes in this group
40+
node_idx:
41+
type: number
42+
label: Resource group index of this node
43+
44+
conditions:
45+
ports_gt_1: False
46+
ports_gt_2: False
47+
# ports_gt_1:
48+
# yaql:
49+
# data:
50+
# group_node_ports: { get_param: group_node_ports }
51+
# expression: $.data.group_node_ports[0].len() > 1
52+
# ports_gt_2:
53+
# yaql:
54+
# data:
55+
# group_node_ports: { get_param: group_node_ports }
56+
# expression: $.data.group_node_ports[0].len() > 2
3757

3858
resources:
39-
instance_net:
40-
type: Cluster::NodeNet1WithFIP
41-
properties:
42-
cluster_net: { get_param: cluster_net }
4359

4460
instance_volume:
4561
type: OS::Cinder::Volume
@@ -57,7 +73,35 @@ resources:
5773
- delete_on_termination: False
5874
volume_id: { get_resource: instance_volume }
5975
key_name: { get_param: key_name }
60-
networks: { get_attr: [ instance_net, networks ] }
76+
# FIXME: I would like to do this but Heat does not parse it:
77+
#networks: { get_param: [ group_node_ports, {get_param: node_idx} ] }
78+
#networks:
79+
# list_concat:
80+
# - []
81+
# - { get_param: [ group_node_ports, {get_param: node_idx} ] }
82+
#networks:
83+
# - { get_param: [ group_node_ports, {get_param: node_idx}, 0 ] }
84+
#networks:
85+
# yaql:
86+
# data:
87+
# group_node_ports: { get_param: group_node_ports }
88+
# node_idx: { get_param: node_idx }
89+
# expression: $.data.group_node_ports[$.data.node_idx]
90+
#
91+
# FIXME: this works but is obviously limited to one port:
92+
#networks:
93+
# - port: { get_param: [ group_node_ports, {get_param: node_idx}, 0, port ] }
94+
networks:
95+
list_concat:
96+
- [port: { get_param: [ group_node_ports, {get_param: node_idx}, 0, port ] }]
97+
- if:
98+
- ports_gt_1
99+
- [port: { get_param: [ group_node_ports, {get_param: node_idx}, 1, port ] }]
100+
- []
101+
- if:
102+
- ports_gt_2
103+
- [port: { get_param: [ group_node_ports, {get_param: node_idx}, 2, port ] }]
104+
- []
61105
availability_zone: { get_param: availability_zone }
62106
config_drive: { get_param: config_drive }
63107

@@ -68,4 +112,7 @@ outputs:
68112

69113
instance_data:
70114
description: ID of the primary IP
71-
value: { 'name': {get_param: name}, 'ip': {get_attr: [instance_net, primary_ip]}, 'id': {get_resource: instance} }
115+
value:
116+
name: {get_param: name}
117+
ip: {get_param: [group_node_ips, {get_param: node_idx}]}
118+
id: {get_resource: instance}

files/resources/instance.yaml

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,40 @@ parameters:
3131
type: boolean
3232
label: Whether to provide metadata via a configdrive
3333
default: false
34-
cluster_net:
34+
group_node_ports:
3535
type: json
36-
label: Network names and subnets to which the nodes should be attached
37-
instance_nodenet:
38-
type: string
39-
default: "Cluster::NodeNet1"
36+
label: Nested list of port resources for all nodes in this group
37+
group_node_ips:
38+
type: json
39+
label: List of primary IPs for all nodes in this group
40+
node_idx:
41+
type: number
42+
label: Resource group index of this node
43+
44+
conditions:
45+
ports_gt_1_yaql:
46+
yaql:
47+
data:
48+
group_node_ports: { get_param: group_node_ports }
49+
expression: $.data.group_node_ports[0].len() > 1
50+
ports_gt_1:
51+
not:
52+
equals:
53+
- ports_gt_1_yaql
54+
- False
55+
56+
ports_gt_2_yaql:
57+
yaql:
58+
data:
59+
group_node_ports: { get_param: group_node_ports }
60+
expression: $.data.group_node_ports[0].len() > 2
61+
ports_gt_2:
62+
not:
63+
equals:
64+
- ports_gt_2_yaql
65+
- False
4066

4167
resources:
42-
instance_net:
43-
# type: Cluster::NodeNet
44-
# type: { get_param: instance_nodenet }
45-
type: Cluster::NodeNet1WithFIP
46-
properties:
47-
cluster_net: { get_param: cluster_net }
4868

4969
instance:
5070
type: OS::Nova::Server
@@ -53,7 +73,36 @@ resources:
5373
flavor: { get_param: flavor }
5474
image: { get_param: image }
5575
key_name: { get_param: key_name }
56-
networks: { get_attr: [ instance_net, networks ] }
76+
# FIXME: I would like to do this but Heat does not parse it:
77+
#networks: { get_param: [ group_node_ports, {get_param: node_idx} ] }
78+
#networks:
79+
# list_concat:
80+
# - []
81+
# - { get_param: [ group_node_ports, {get_param: node_idx} ] }
82+
#networks:
83+
# - { get_param: [ group_node_ports, {get_param: node_idx}, 0 ] }
84+
#networks:
85+
# yaql:
86+
# data:
87+
# group_node_ports: { get_param: group_node_ports }
88+
# node_idx: { get_param: node_idx }
89+
# expression: $.data.group_node_ports[$.data.node_idx]
90+
#
91+
# FIXME: this works but is obviously limited to one port:
92+
networks:
93+
- port: { get_param: [ group_node_ports, {get_param: node_idx}, 0, port ] }
94+
#networks:
95+
# list_concat:
96+
# - [port: { get_param: [ group_node_ports, {get_param: node_idx}, 0, port ] }]
97+
# - if:
98+
# - ports_gt_1_yaql
99+
# - [port: { get_param: [ group_node_ports, {get_param: node_idx}, 1, port ] }]
100+
# - []
101+
# - if:
102+
# - False
103+
# - [port: { get_param: [ group_node_ports, {get_param: node_idx}, 2, port ] }]
104+
# - []
105+
57106
availability_zone: { get_param: availability_zone }
58107
config_drive: { get_param: config_drive }
59108

@@ -64,4 +113,8 @@ outputs:
64113

65114
instance_data:
66115
description: ID of the primary IP
67-
value: { 'name': {get_param: name}, 'ip': {get_attr: [instance_net, primary_ip]}, 'id': {get_resource: instance} }
116+
value:
117+
name: {get_param: name}
118+
ip: {get_param: [group_node_ips, {get_param: node_idx}]}
119+
id: {get_resource: instance}
120+
ports_gt_1: {equals: [ports_gt_1_yaql, True]}

files/resources/nodenet-2.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ conditions:
2121
cluster_net: { get_param: [ cluster_net, 0 ] }
2222

2323
resources:
24+
node_ports:
25+
type: OS::Heat::ResourceGroup
26+
properties:
27+
count:
28+
yaql:
29+
data:
30+
cluster_groups: { get_param: nodegroup_networks }
31+
expression: $.data.cluster_groups.len()
32+
2433
port1:
2534
type: OS::Neutron::Port
2635
properties:

0 commit comments

Comments
 (0)