Merge "Add ctl node as a target Related-Prod:PROD-36446 Change-Id: I1b51cb935aba82a389cbd71ac161607481c57d0c"
diff --git a/jobs/backups/backup-swarm-cookied-model-generator.sh b/jobs/backups/backup-swarm-cookied-model-generator.sh
new file mode 100644
index 0000000..a69b1cf
--- /dev/null
+++ b/jobs/backups/backup-swarm-cookied-model-generator.sh
@@ -0,0 +1,101 @@
+# export REMOTE_JENKINS='172.19.112.216'
+export REMOTE_JENKINS='sre-ci.scc.mirantis.net'
+
+if [ ! -n "$LAB_CONTEXT_NAME" ]; then
+  echo 'LAB_CONTEXT_NAME is not set!
+    This name will be used:
+    - to find the template file tcp_tests/templates/cookied-model-generator/salt_${LAB_CONTEXT_NAME}.yaml
+    - to set the salt model cluster name
+    - to make DOMAIN_NAME=${LAB_CONTEXT_NAME}.local
+  ';
+  exit 1
+fi
+
+
+if [ -n "$TCP_QA_REVIEW" ]; then
+	git fetch https://gerrit.mcp.mirantis.com/mcp/tcp-qa $TCP_QA_REVIEW && git checkout FETCH_HEAD
+fi
+
+. ${VENV_PATH}/bin/activate
+
+if [ "$ERASE_EXISTING_ENVIRONMENT" = "true" ]; then
+    dos.py erase $ENV_NAME || true
+fi
+
+cd tcp_tests
+
+rm -f ./*.tar.gz
+
+#MODEL_FILENAME=model_${CLUSTER_NAME}_${BUILD_NUMBER}.tar.gz
+MODEL_FILENAME=model_${ENV_NAME}.tar.gz
+if [[ -f $MODEL_FILENAME ]]; then
+   rm $MODEL_FILENAME
+fi
+
+####################
+# Generate the model
+
+py.test --junit-xml=deploy_generate_model.xml -k ${TEST_GROUP}
+
+
+########################################################
+# Upload the generated model to the repository on cz8133
+
+# Create a directory where the created model will be unpacked
+rm -rf ./model
+mkdir -p ./model
+
+eval $(ssh-agent)
+ssh-add ${SSH_PRIVATE_KEY}
+
+# Create remote repository
+ssh jenkins@${REMOTE_JENKINS} "
+  if [[ ! -d /home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git ]]; then
+    mkdir -p /home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git;
+    cd /home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git;
+    git init --bare;
+    cp hooks/post-update.sample hooks/post-update;
+  fi"
+
+cd ./model
+
+# Prepare the repository in the ./model
+git init
+git remote add integration ssh://jenkins@${REMOTE_JENKINS}/home/jenkins/salt-models/${LAB_CONTEXT_NAME}.git
+git pull integration ${REPOSITORY_SUITE} || true
+git checkout -b ${REPOSITORY_SUITE}
+git rm -rf . || true   # remove previous content from the working dir
+
+# unpack new model into ./model dir
+tar -xzf ../${MODEL_FILENAME} -C ./
+# Add reclass-system submodule
+git submodule add https://gerrit.mcp.mirantis.com/salt-models/reclass-system classes/system/
+cd classes/system
+git checkout ${SALT_MODELS_SYSTEM_COMMIT}
+cd ../..
+
+# The directory "classes/service" is created at bootstrap time
+# and cannot be commited to the repository automatically.
+# It is not needed in the repo because contains only symlinks.
+cat << EOF > ./.gitignore
+classes/service
+EOF
+
+# create a commit with new model (if any change exists)
+git add -A
+git commit -m "${LAB_CONTEXT_NAME}@${REPOSITORY_SUITE} generated at $(date +%Y-%m-%d/%H-%M)
+
+REPOSITORY_SUITE=${REPOSITORY_SUITE}
+SALT_MODELS_SYSTEM_COMMIT=${SALT_MODELS_SYSTEM_COMMIT}
+COOKIECUTTER_TEMPLATE_COMMIT=${COOKIECUTTER_TEMPLATE_COMMIT}
+"
+
+# Push new commit to the ${REMOTE_JENKINS} repository
+git push integration ${REPOSITORY_SUITE}
+
+echo "######################################################################################################################"
+echo "#"
+echo "# Clone the model into the tests:  git clone http://${REMOTE_JENKINS}:8098/${LAB_CONTEXT_NAME}.git -b ${REPOSITORY_SUITE}"
+echo "#"
+echo "######################################################################################################################"
+
diff --git a/tcp_tests/templates/bm-cicd-pike-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml b/tcp_tests/templates/bm-cicd-pike-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml
index 42bf3e9..04adcc4 100644
--- a/tcp_tests/templates/bm-cicd-pike-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml
+++ b/tcp_tests/templates/bm-cicd-pike-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml
@@ -850,6 +850,6 @@
   stacklight_ssl_enabled: 'True'
 
   # Enable Mirantis repo with CVE fixes for xenial
-  updates_mirantis_login: "root"
-  updates_mirantis_password: "r00tme"
+  updates_mirantis_login: "%LOGIN%"
+  updates_mirantis_password: "%PASS%"
   updates_mirantis_version: "staging"
\ No newline at end of file
diff --git a/tcp_tests/templates/bm-e7-cicd-pike-odl-maas/salt-context-cookiecutter-openstack_odl.yaml b/tcp_tests/templates/bm-e7-cicd-pike-odl-maas/salt-context-cookiecutter-openstack_odl.yaml
index 56f0c42..3458dbc 100644
--- a/tcp_tests/templates/bm-e7-cicd-pike-odl-maas/salt-context-cookiecutter-openstack_odl.yaml
+++ b/tcp_tests/templates/bm-e7-cicd-pike-odl-maas/salt-context-cookiecutter-openstack_odl.yaml
@@ -435,6 +435,6 @@
   stacklight_ssl_enabled: 'True'
 
   # Enable Mirantis repo with CVE fixes for xenial
-  updates_mirantis_login: "root"
-  updates_mirantis_password: "r00tme"
+  updates_mirantis_login: "%LOGIN%"
+  updates_mirantis_password: "%PASS%"
   updates_mirantis_version: "staging"
\ No newline at end of file
diff --git a/tcp_tests/templates/bm-e7-cicd-pike-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml b/tcp_tests/templates/bm-e7-cicd-pike-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml
index 4c2f81e..28d5916 100644
--- a/tcp_tests/templates/bm-e7-cicd-pike-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml
+++ b/tcp_tests/templates/bm-e7-cicd-pike-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml
@@ -436,6 +436,6 @@
   stacklight_ssl_enabled: 'True'
 
   # Enable Mirantis repo with CVE fixes for xenial
-  updates_mirantis_login: "root"
-  updates_mirantis_password: "r00tme"
+  updates_mirantis_login: "%LOGIN%"
+  updates_mirantis_password: "%PASS%"
   updates_mirantis_version: "staging"
\ No newline at end of file
diff --git a/tcp_tests/templates/heat-cicd-pike-dvr-sl/salt-context-cookiecutter.yaml b/tcp_tests/templates/heat-cicd-pike-dvr-sl/salt-context-cookiecutter.yaml
index 58fdf66..08076e4 100644
--- a/tcp_tests/templates/heat-cicd-pike-dvr-sl/salt-context-cookiecutter.yaml
+++ b/tcp_tests/templates/heat-cicd-pike-dvr-sl/salt-context-cookiecutter.yaml
@@ -374,6 +374,6 @@
     change_password_upon_first_use: False
 
   # Enable Mirantis repo with CVE fixes for xenial
-  updates_mirantis_login: "root"
-  updates_mirantis_password: "r00tme"
+  updates_mirantis_login: "%LOGIN%"
+  updates_mirantis_password: "%PASS%"
   updates_mirantis_version: "staging"
diff --git a/tcp_tests/templates/heat-cicd-queens-contrail41-sl/salt-context-cookiecutter-contrail.yaml b/tcp_tests/templates/heat-cicd-queens-contrail41-sl/salt-context-cookiecutter-contrail.yaml
index 3f99b08..6449796 100644
--- a/tcp_tests/templates/heat-cicd-queens-contrail41-sl/salt-context-cookiecutter-contrail.yaml
+++ b/tcp_tests/templates/heat-cicd-queens-contrail41-sl/salt-context-cookiecutter-contrail.yaml
@@ -310,6 +310,6 @@
     change_password_upon_first_use: False
 
   # Enable Mirantis repo with CVE fixes for xenial
-  updates_mirantis_login: "root"
-  updates_mirantis_password: "r00tme"
+  updates_mirantis_login: "%LOGIN%"
+  updates_mirantis_password: "%PASS%"
   updates_mirantis_version: "staging"
\ No newline at end of file
diff --git a/tcp_tests/templates/released-heat-cicd-pike-contrail41-sl/salt-context-cookiecutter-contrail.yaml b/tcp_tests/templates/released-heat-cicd-pike-contrail41-sl/salt-context-cookiecutter-contrail.yaml
index b0cf6e8..d8978f0 100644
--- a/tcp_tests/templates/released-heat-cicd-pike-contrail41-sl/salt-context-cookiecutter-contrail.yaml
+++ b/tcp_tests/templates/released-heat-cicd-pike-contrail41-sl/salt-context-cookiecutter-contrail.yaml
@@ -316,6 +316,6 @@
     change_password_upon_first_use: False
 
   # Enable Mirantis repo with CVE fixes for xenial
-  updates_mirantis_login: "root"
-  updates_mirantis_password: "r00tme"
+  updates_mirantis_login: "%LOGIN%"
+  updates_mirantis_password: "%PASS%"
   updates_mirantis_version: "staging"
\ No newline at end of file
diff --git a/tcp_tests/templates/released-heat-cicd-queens-dvr-sl/salt-context-cookiecutter.yaml b/tcp_tests/templates/released-heat-cicd-queens-dvr-sl/salt-context-cookiecutter.yaml
index c26143e..83ea6b3 100644
--- a/tcp_tests/templates/released-heat-cicd-queens-dvr-sl/salt-context-cookiecutter.yaml
+++ b/tcp_tests/templates/released-heat-cicd-queens-dvr-sl/salt-context-cookiecutter.yaml
@@ -379,6 +379,6 @@
 
   stacklight_ssl_enabled: 'True'
   # Enable Mirantis repo with CVE fixes for xenial
-  updates_mirantis_login: "root"
-  updates_mirantis_password: "r00tme"
+  updates_mirantis_login: "%LOGIN%"
+  updates_mirantis_password: "%PASS%"
   updates_mirantis_version: "staging"
\ No newline at end of file