Refactor reclass cloning
SALT_MODELS_REF_CHANGE SALT_MODELS_COMMIT are both exclusive. If
SALT_MODELS_REF_CHANGE is specified then it means we don't need to do a
checkout to special commit. SALT_MODELS_COMMIT is specified but
SALT_MODELS_REF_CHANGE is not, then we need to checkout that commit.
* This change refactor the logic across all templates.
* This change introduce for loop for SALT_MODELS_REF_CHANGE. Several
commits can be specified using space as separator. Here is an example
export SALT_MODELS_REF_CHANGE='refs/changes/12/8412/2 refs/changes/58/8458/1'
All commits should not have any conflicts. In case of conflicts create
dependant commits and use top one.
* The 'cmd:' for the step "Clone reclass models with submodules" was moved
to shared-salt.yaml and included to other templates as a jinja2 'macro'.
* SALT_MODELS_SYSTEM_COMMIT now works as expected. If not specified then
will be used the 'system' commit specified in the cluster model
submodule.
Doc-Impact
Change-Id: I0d57b1eea79a7c011231dcf7f46fb3599a62c33f
Signed-off-by: Sergii Golovatiuk <sgolovatiuk@mirantis.com>
Reviewed-on: https://review.gerrithub.io/372906
Reviewed-by: Sergii Golovatiuk <holser@gmail.com>
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/templates/virtual-mcp11-ovs/openstack.yaml b/tcp_tests/templates/virtual-mcp11-ovs/openstack.yaml
index 6f2d10c..66574ae 100644
--- a/tcp_tests/templates/virtual-mcp11-ovs/openstack.yaml
+++ b/tcp_tests/templates/virtual-mcp11-ovs/openstack.yaml
@@ -3,8 +3,8 @@
{% from 'virtual-mcp11-ovs/underlay.yaml' import HOSTNAME_CTL02 with context %}
{% from 'virtual-mcp11-ovs/underlay.yaml' import HOSTNAME_CTL03 with context %}
{% from 'virtual-mcp11-ovs/underlay.yaml' import HOSTNAME_GTW01 with context %}
-{% from 'virtual-mcp11-ovs/salt.yaml' import IPV4_NET_EXTERNAL_PREFIX with context %}
-{% from 'virtual-mcp11-ovs/salt.yaml' import IPV4_NET_TENANT_PREFIX with context %}
+{% from 'shared-salt.yaml' import IPV4_NET_EXTERNAL_PREFIX with context %}
+{% from 'shared-salt.yaml' import IPV4_NET_TENANT_PREFIX with context %}
# Install OpenStack control services
diff --git a/tcp_tests/templates/virtual-mcp11-ovs/salt.yaml b/tcp_tests/templates/virtual-mcp11-ovs/salt.yaml
index ed4850c..a5d6177 100644
--- a/tcp_tests/templates/virtual-mcp11-ovs/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp11-ovs/salt.yaml
@@ -1,28 +1,12 @@
{% from 'virtual-mcp11-ovs/underlay.yaml' import HOSTNAME_CFG01 with context %}
{% from 'virtual-mcp11-ovs/underlay.yaml' import REPOSITORY_SUITE with context %}
+
{% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %}
-{% set SALT_MODELS_BRANCH = os_env('SALT_MODELS_BRANCH','master') %}
-{% set SALT_MODELS_COMMIT = os_env('SALT_MODELS_COMMIT','master') %}
+# Other salt model repository parameters see in shared-salt.yaml
-# Reference to a patch that should be applied to the model if required, for example: export SALT_MODELS_REF_CHANGE=refs/changes/19/7219/12
-{% set SALT_MODELS_REF_CHANGE = os_env('SALT_MODELS_REF_CHANGE', '') %}
-
-# Address pools for reclass cluster model are taken in the following order:
-# 1. environment variables,
-# 2. config.underlay.address_pools based on fuel-devops address pools
-# (see generated '.ini' file after underlay is created),
-# 3. defaults
-{% set address_pools = config.underlay.address_pools %}
-{% set IPV4_NET_ADMIN = os_env('IPV4_NET_ADMIN', address_pools.get('admin-pool01', '192.168.10.0/24')) %}
-{% set IPV4_NET_CONTROL = os_env('IPV4_NET_CONTROL', address_pools.get('private-pool01', '172.16.10.0/24')) %}
-{% set IPV4_NET_TENANT = os_env('IPV4_NET_TENANT', address_pools.get('tenant-pool01', '10.1.0.0/24')) %}
-{% set IPV4_NET_EXTERNAL = os_env('IPV4_NET_EXTERNAL', address_pools.get('external-pool01', '10.16.0.0/24')) %}
-
-{% set IPV4_NET_ADMIN_PREFIX = '.'.join(IPV4_NET_ADMIN.split('.')[0:3]) %}
-{% set IPV4_NET_CONTROL_PREFIX = '.'.join(IPV4_NET_CONTROL.split('.')[0:3]) %}
-{% set IPV4_NET_TENANT_PREFIX = '.'.join(IPV4_NET_TENANT.split('.')[0:3]) %}
-{% set IPV4_NET_EXTERNAL_PREFIX = '.'.join(IPV4_NET_EXTERNAL.split('.')[0:3]) %}
+{% import 'shared-salt.yaml' as SHARED with context %}
+{% from 'shared-salt.yaml' import IPV4_NET_CONTROL_PREFIX with context %}
# Install salt to the config node
@@ -69,41 +53,7 @@
- description: Clone reclass models with submodules
cmd: |
- ssh-keyscan -H github.com >> ~/.ssh/known_hosts;
- git clone -b {{ SALT_MODELS_BRANCH }} --recurse-submodules {{ SALT_MODELS_REPOSITORY }} /srv/salt/reclass;
- pushd /srv/salt/reclass && git checkout {{ SALT_MODELS_COMMIT }} && popd;
- {%- if SALT_MODELS_REF_CHANGE != '' %}
- pushd /srv/salt/reclass && git fetch {{ SALT_MODELS_REPOSITORY }} {{ SALT_MODELS_REF_CHANGE }} && git checkout FETCH_HEAD && popd;
- {%- endif %}
- mkdir -p /srv/salt/reclass/classes/service;
-
- # Replace firstly to an intermediate value to avoid intersection between
- # already replaced and replacing networks.
- # For example, if generated IPV4_NET_ADMIN_PREFIX=10.16.0 , then there is a risk of replacing twice:
- # 192.168.10 -> 10.16.0 (generated network for admin)
- # 10.16.0 -> <external network>
- # So let's replace constant networks to the keywords, and then keywords to the desired networks.
- find /srv/salt/reclass/ -type f -exec sed -i 's/192\.168\.10\./==IPV4_NET_ADMIN_PREFIX==/g' {} +
- find /srv/salt/reclass/ -type f -exec sed -i 's/172\.16\.10\./==IPV4_NET_CONTROL_PREFIX==/g' {} +
- find /srv/salt/reclass/ -type f -exec sed -i 's/10\.1\.0\./==IPV4_NET_TENANT_PREFIX==/g' {} +
- find /srv/salt/reclass/ -type f -exec sed -i 's/10\.16\.0\./==IPV4_NET_EXTERNAL_PREFIX==/g' {} +
-
- find /srv/salt/reclass/ -type f -exec sed -i 's/==IPV4_NET_ADMIN_PREFIX==/{{ IPV4_NET_ADMIN_PREFIX }}./g' {} +
- find /srv/salt/reclass/ -type f -exec sed -i 's/==IPV4_NET_CONTROL_PREFIX==/{{ IPV4_NET_CONTROL_PREFIX }}./g' {} +
- find /srv/salt/reclass/ -type f -exec sed -i 's/==IPV4_NET_TENANT_PREFIX==/{{ IPV4_NET_TENANT_PREFIX }}./g' {} +
- find /srv/salt/reclass/ -type f -exec sed -i 's/==IPV4_NET_EXTERNAL_PREFIX==/{{ IPV4_NET_EXTERNAL_PREFIX }}./g' {} +
-
- find /srv/salt/reclass/ -type f -exec sed -i 's/apt_mk_version:.*/apt_mk_version: {{ REPOSITORY_SUITE }}/g' {} +
-
- # Disable checkouting the model from remote repository
- cat << 'EOF' >> /srv/salt/reclass/nodes/{{ HOSTNAME_CFG01 }}.yml
- # local storage
- reclass:
- storage:
- data_source:
- engine: local
- EOF
-
+{{ SHARED.MACRO_CLONE_RECLASS_MODELS() }}
# Show the changes to the console
cd /srv/salt/reclass/; git diff
node_name: {{ HOSTNAME_CFG01 }}
@@ -305,4 +255,4 @@
cmd: salt 'cmp02*' cmd.run "ip addr del {{ IPV4_NET_CONTROL_PREFIX }}.106/24 dev ens4; ip addr flush dev ens4";
node_name: {{ HOSTNAME_CFG01 }}
retry: {count: 1, delay: 10}
- skip_fail: false
\ No newline at end of file
+ skip_fail: false