Add possibility to generate model from cookiecutter templates
using defined cluster_product models
Using MACRO_GENERATE_COOKIECUTTER_MODEL we can define
which cluster models are used for generation
For example
MACRO.MACRO_GENERATE_COOKIECUTTER_MODEL(CLUSTER_PRODUCT_MODELS='infra openstack stacklight1')
Change-Id: If0f67f59017bb51731b78b1deb3be0f3faa653ff
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index b14f868..25132d5 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -200,7 +200,7 @@
{%- endmacro %}
-{%- macro MACRO_GENERATE_COOKIECUTTER_MODEL(IS_CONTRAIL_LAB=false, CONTROL_VLAN=None, TENANT_VLAN=None) %}
+{%- macro MACRO_GENERATE_COOKIECUTTER_MODEL(IS_CONTRAIL_LAB=false, CONTROL_VLAN=None, TENANT_VLAN=None, CLUSTER_PRODUCT_MODELS='') %}
{###################################################################}
{%- set CLUSTER_CONTEXT_PATH = '/tmp/' + CLUSTER_CONTEXT_NAME %}
- description: "[EXPERIMENTAL] Upload cookiecutter-templates context to {{ HOSTNAME_CFG01 }}"
@@ -254,9 +254,10 @@
sed -i 's/==IPV4_NET_TENANT_PREFIX==/{{ IPV4_NET_TENANT_PREFIX }}/g' {{ CLUSTER_CONTEXT_PATH }}
sed -i 's/==IPV4_NET_EXTERNAL_PREFIX==/{{ IPV4_NET_EXTERNAL_PREFIX }}./g' {{ CLUSTER_CONTEXT_PATH }}
- for i in $(ls /tmp/cookiecutter-templates/cluster_product/); do
+ {% set items = CLUSTER_PRODUCT_MODELS or '$(ls /tmp/cookiecutter-templates/cluster_product/)' %}
+ for item in {{ items }}; do
python /tmp/cookiecutter-templates/generate.py \
- --template /tmp/cookiecutter-templates/cluster_product/$i \
+ --template /tmp/cookiecutter-templates/cluster_product/$item \
--config-file {{ CLUSTER_CONTEXT_PATH }} \
--output-dir /srv/salt/reclass/classes/cluster/;
done
@@ -874,4 +875,4 @@
retry: {count: 1, delay: 5}
skip_fail: false
-{%- endmacro %}
\ No newline at end of file
+{%- endmacro %}