non-configurable 0 based index variable in OS::Heat::ResourceGroup
Bug #1551582 reported by
robfrey
This bug report is a duplicate of:
Bug #1585206: ResourceGroup removal_policies not applied on create.
Edit
Remove
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Heat |
New
|
Undecided
|
Unassigned |
Bug Description
Currently the index variable in OS::Heat:
One possibility would be to adjust the existing removal_policies interface so it's also respected on create:
http:// docs.openstack. org/developer/ heat/template_ guide/openstack .html#OS: :Heat:: ResourceGroup- prop-removal_ policies
AGroup: :ResourceGroup policies: [{'resource_list': ['0']}] :RandomString
type: OS::Heat:
properties:
count: 10
removal_
resource_def:
type: OS::Heat:
Here, on update it'll remove "0" from the group and give you a group starting from "1", only at present this interface doesn't influence the create group assignments (which is arguably wrong and not very declarative).
Another possibility if all you want is configurable instance names is just to use a mapping, e.g:
[stack@instack ~]$ cat hostname_map.yaml version: 2015-04-30
heat_template_
parameters:
HostnameMap:
type: json
default:
'0': ahost-1
'1': ahost-2
resources: :ResourceGroup mapped_ name.yaml mapped_ name.yaml version: 2015-04-30
AGroup:
type: OS::Heat:
properties:
count: 2
resource_def:
type: server_
properties:
name_map: {get_param: HostnameMap}
index: '%index%'
[stack@instack ~]$ cat server_
heat_template_
parameters:
name_map:
type: json
index:
type: string
resources:
server:
type: OS::Nova::Server
properties:
image: overcloud-full
flavor: baremetal
name: {get_param: [name_map, {get_param: index}]}
[stack@instack ~]$ cat hostname_map.yaml version: 2015-04-30
heat_template_
parameters:
HostnameMap:
type: json
default:
'0': ahost-1
'1': ahost-2
resources: :ResourceGroup mapped_ name.yaml mapped_ name.yaml version: 2015-04-30
AGroup:
type: OS::Heat:
properties:
count: 2
resource_def:
type: server_
properties:
name_map: {get_param: HostnameMap}
index: '%index%'
[stack@instack ~]$ cat server_
heat_template_
parameters:
name_map:
type: json
index:
type: string
resources:
server:
type: OS::Nova::Server
properties:
image: overcloud-full
flavor: baremetal
name: {get_param: [name_map, {get_param: index}]}
If neither of these approaches is palatable we could look into a start_index property, but personally I see that as a pattern we'd be best to avoid, because non-zero based indexes for things like attribute lookups are likely to prove error prone (yeah I know if we use the removal_policies approach we already have this problem, I just don't want to encourage it..)