summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMichal Zegan <m.zegan@samsung.com>2019-09-05 18:36:47 +0200
committerMichal Zegan <m.zegan@samsung.com>2019-09-06 12:26:09 +0200
commit07d99883b5e5895000fa400da3dfe12dad54c4e9 (patch)
treee38b7b08c5f67647614558c0dfdfa6034443ca91 /tools
parent1da8b7af533aa48450d42219f0615d0bb510da4a (diff)
Change the way how volume map is constructed
This commit modifies volume handling in heat template in cicdansible. Namely, it simplifies the generation of node to volume list mapping and makes it more readable and understandable, and also more flexible, because now parts of it could be conditionalized. This is required for a followup commit. Change-Id: I204aefd819f40050a2cb9e6a031dfb2c62da1f48 Issue-ID: OOM-2042 Signed-off-by: Michal Zegan <m.zegan@samsung.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/cicdansible/heat/installer.yaml41
-rw-r--r--tools/cicdansible/heat/node.yaml4
2 files changed, 34 insertions, 11 deletions
diff --git a/tools/cicdansible/heat/installer.yaml b/tools/cicdansible/heat/installer.yaml
index 8fff3a74..7dd585d5 100644
--- a/tools/cicdansible/heat/installer.yaml
+++ b/tools/cicdansible/heat/installer.yaml
@@ -256,6 +256,33 @@ resources:
properties:
floatingip_id: { get_param: installer_ip }
port_id: { get_attr: [installer, port_id] }
+ #Map of node volumes, taken from volumes output param.
+ node_volumes:
+ type: OS::Heat::Value
+ properties:
+ type: json
+ #We need yaql transformation to be done on the volume map.
+ value:
+ yaql:
+ data:
+ #This is a map of node number to value of "volumes" attribute, that contains
+ #a list of volumes written as pairs [volumeid, mountpoint].
+ volumes: { get_attr: [nodes, attributes, volumes] }
+ #We need yaql expressions to transform node numbers to node names in the form "node0" and similar.
+ #However we don't need anything more complicated.
+ expression: "$.data.volumes?.items()?.toDict('node'+str($[0]), $[1])"
+ #List of infra specific volumes (not a map as above).
+ infra_volumes:
+ type: OS::Heat::Value
+ properties:
+ value:
+ - [{ get_resource: resources_storage }, "/opt/onap"]
+ #Contains node0 specific volume list.
+ node0_volumes:
+ type: OS::Heat::Value
+ properties:
+ value:
+ - [{ get_resource: nfs_storage }, "/dockerdata-nfs"]
#Output values
outputs:
installer_ip:
@@ -270,14 +297,10 @@ outputs:
volumes:
description: "map of volumes per each instance"
value:
+ #Can do deep merging only with yaql.
yaql:
data:
- resources_volid: { get_resource: resources_storage }
- nfs_volid: { get_resource: nfs_storage }
- docker_volids: { get_attr: [nodes, docker_storage_id] }
- #This is going to create a map, where keys are instance names, and values are lists of
- #pairs of volume ids and their mount points.
- #This is done by merging few generated maps together, base map is taken by
- #enumerating over docker storage volumes and transforming them into a map like
- #{"node0"=>["volid","/var/lib/docker"],...], node1=>...}
- expression: 'dict($.data.docker_volids.enumerate().select(["node"+str($[0]), [[$[1], "/var/lib/docker"]]])).mergeWith({"infra" => [[$.data.resources_volid, "/opt/onap"]], "node0" => [[$.data.nfs_volid, "/dockerdata-nfs"]]})'
+ node_volumes: { get_attr: [node_volumes, value]}
+ infra_volumes: { infra: { get_attr: [infra_volumes, value] }}
+ node0_volumes: {node0: { get_attr: [node0_volumes, value] }}
+ expression: "$.data.node_volumes?.mergeWith($.data.infra_volumes)?.mergeWith($.data.node0_volumes)"
diff --git a/tools/cicdansible/heat/node.yaml b/tools/cicdansible/heat/node.yaml
index b6048d8d..7f6af35b 100644
--- a/tools/cicdansible/heat/node.yaml
+++ b/tools/cicdansible/heat/node.yaml
@@ -55,5 +55,5 @@ outputs:
value: { get_attr: ["instance", "port_id"] }
ip:
value: { get_attr: ["instance", "ip"] }
- docker_storage_id:
- value: { get_resource: docker_storage }
+ volumes:
+ value: [[{ get_resource: docker_storage }, "/var/lib/docker"]]