Fix released-bm-b300-cicd-queens-ovs-maas job

Related-Prod:PROD-34858

Change-Id: If4dee32cef481153255b17b309ff81029dc443a7
diff --git a/jobs/pipelines/deploy-cicd-and-run-tests.groovy b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
index f72b28f..5b4c174 100644
--- a/jobs/pipelines/deploy-cicd-and-run-tests.groovy
+++ b/jobs/pipelines/deploy-cicd-and-run-tests.groovy
@@ -214,16 +214,19 @@
         if (env.RUN_UPGRADE_AFTER_JOB == "true" && currentBuild.result == 'SUCCESS') {
             network_backend = env.PLATFORM_STACK_INSTALL.contains("contrail") ? 'contrail' : 'dvr'
             upgrade_job = "mcp-update-${env.TEMPEST_IMAGE_VERSION}-${network_backend}-sl"
-              def deploy = build job: "${upgrade_job}",
-                  parameters: [
-                      string(name: 'PARENT_NODE_NAME', value: "openstack_slave_${env.LAB_CONFIG_NAME}"),
-                      string(name: 'TCP_QA_REFS', value: env.TCP_QA_REFS),
-                      string(name: 'PASSED_STEPS', value: steps),
-                      string(name: 'TEMPEST_TEST_SUITE_NAME', value: env.TEMPEST_TEST_SUITE_NAME),
-                      string(name: 'NODE', value: "openstack_slave_${env.LAB_CONFIG_NAME}")
-                  ],
-                  wait: false,
-                  propagate: false
+            if (env.IPMI_CREDS) {
+                upgrade_job = "mcp-update-bm-b300-queens-ovs-maas"
+            }
+            def deploy = build job: "${upgrade_job}",
+                parameters: [
+                    string(name: 'PARENT_NODE_NAME', value: "openstack_slave_${env.LAB_CONFIG_NAME}"),
+                    string(name: 'TCP_QA_REFS', value: env.TCP_QA_REFS),
+                    string(name: 'PASSED_STEPS', value: steps),
+                    string(name: 'TEMPEST_TEST_SUITE_NAME', value: env.TEMPEST_TEST_SUITE_NAME),
+                    string(name: 'NODE', value: "openstack_slave_${env.LAB_CONFIG_NAME}")
+                ],
+                wait: false,
+                propagate: false
         }
     } // try
   } // node
diff --git a/jobs/project.yaml b/jobs/project.yaml
index 3addb2e..145ae0d 100644
--- a/jobs/project.yaml
+++ b/jobs/project.yaml
@@ -23,7 +23,7 @@
       - bm-e7-cicd-pike-ovs-maas
       - bm-e7-cicd-pike-odl-maas
       - bm-b300-cicd-queens-ovs-maas
-      - released-b300-cicd-queens-ovs-maas
+      - released-bm-b300-cicd-queens-ovs-maas
       - released-bm-pike-ovs
       # --- Released envs ------
       - deploy-released:
diff --git a/jobs/templates/released-bm-b300-cicd-queens-ovs-maas.yml b/jobs/templates/released-bm-b300-cicd-queens-ovs-maas.yml
index b30db21..ea418dc 100644
--- a/jobs/templates/released-bm-b300-cicd-queens-ovs-maas.yml
+++ b/jobs/templates/released-bm-b300-cicd-queens-ovs-maas.yml
@@ -6,7 +6,7 @@
     name: released-bm-b300-cicd-queens-ovs-maas
     parameters:
     - string:
-        default: bm-b300-cicd-queens-ovs-maas
+        default: released-bm-b300-cicd-queens-ovs-maas
         description: ''
         name: LAB_CONFIG_NAME
         trim: 'false'
@@ -33,7 +33,7 @@
         name: PLATFORM_STACK_INSTALL_TIMEOUT
         trim: 'false'
     - string:
-        default: 2019.2.0
+        default: "{previous-version}"
         description: ''
         name: MCP_VERSION
         trim: 'false'
@@ -58,12 +58,12 @@
         name: CFG01_CONFIG_IMAGE_NAME
         trim: 'false'
     - string:
-        default: bm-b300-cicd-queens-ovs-maas
+        default: released-bm-b300-cicd-queens-ovs-maas
         description: ''
         name: ENV_NAME
         trim: 'false'
     - string:
-        default: refs/tags/{previous-version}
+        default: ''
         description: |-
           Example: refs/changes/89/411189/36
           (for now - only one reference allowed)
@@ -108,7 +108,7 @@
         name: COOKIECUTTER_REF_CHANGE
         trim: 'false'
     - string:
-        default: refs/tags/{previous-version}
+        default: ''
         description: ''
         name: ENVIRONMENT_TEMPLATE_REF_CHANGE
         trim: 'false'
@@ -123,7 +123,7 @@
         name: TEMPEST_IMAGE_VERSION
         trim: 'false'
     - string:
-        default: proposed
+        default: ''
         description: ''
         name: UPDATE_REPO_CUSTOM_TAG
         trim: 'false'
@@ -177,7 +177,7 @@
         trim: 'false'
     - string:
         default: proposed
-        description: ''
+        description: "{previous-version}"
         name: UPDATE_VERSION
         trim: 'false'
     - string:
@@ -209,6 +209,10 @@
         default: true
         description: 'Works starting from MCP 2019.2.10 or master. Whether to apply saltstack updates on all nodes in cluster before deployment'
         name: UPGRADE_SALTSTACK
+    - bool:
+        name: RUN_UPGRADE_AFTER_JOB
+        default: true
+        description: "Upgrade and test after deploy?"
     pipeline-scm:
       lightweight-checkout: false
       scm:
diff --git a/jobs/templates/test-scenarios.yml b/jobs/templates/test-scenarios.yml
index abf7273..9bc9cc9 100644
--- a/jobs/templates/test-scenarios.yml
+++ b/jobs/templates/test-scenarios.yml
@@ -150,6 +150,13 @@
     test-pattern-with-contrail:
       ^heat_tempest_plugin.tests*|^tempest.api.image*|^tempest_horizon*|^tempest.api.identity*|^tempest.api.network*|^tempest.api.compute*|^tempest.api.volume*|^tempest.scenario*|^tempest.api.object_storage*
     test_scenario:
+      - mcp-update-bm-b300-queens-ovs-maas:
+          deployment: released-bm-b300-cicd-queens-ovs-maas
+          run-test-opts: '{test-opt}'
+          tempest_pattern: 'tempest'
+          display-name: MCP update (BM-B300-queens + MAAS)
+          tempest_test_suite: "[MCP1.1_QUEENS]Tempest"
+
       - mcp-update-pike-dvr-sl:
           deployment: released-heat-cicd-pike-dvr-sl
           run-test-opts: '{test-opt}'
diff --git a/tcp_tests/templates/cookied-model-generator/salt_released-bm-b300-cicd-queens-ovs-maas.yaml b/tcp_tests/templates/cookied-model-generator/salt_released-bm-b300-cicd-queens-ovs-maas.yaml
new file mode 100644
index 0000000..c99f568
--- /dev/null
+++ b/tcp_tests/templates/cookied-model-generator/salt_released-bm-b300-cicd-queens-ovs-maas.yaml
@@ -0,0 +1,72 @@
+{% from 'cookied-model-generator/underlay.yaml' import HOSTNAME_CFG01 with context %}
+{% from 'cookied-model-generator/underlay.yaml' import DOMAIN_NAME with context %}
+
+# Other salt model repository parameters see in shared-salt.yaml
+{% set LAB_CONFIG_NAME = 'released-bm-b300-cicd-queens-ovs-maas' %}
+# Name of the context file (without extension, that is fixed .yaml) used to render the Environment model
+{% set ENVIRONMENT_MODEL_INVENTORY_NAME = os_env('ENVIRONMENT_MODEL_INVENTORY_NAME','released-bm-b300-cicd-queens-ovs-maas') %}
+# Path to the context files used to render Cluster and Environment models
+{%- set CLUSTER_CONTEXT_NAME = 'salt-context-cookiecutter-openstack_ovs.yaml' %}
+{%- set ENVIRONMENT_CONTEXT_NAMES = ['salt-context-vcp-environment.yaml', 'salt-context-environment.yaml','salt-context-cookiecutter-openstack_ovs.yaml'] %}
+{%- set CONTROL_VLAN = os_env('CONTROL_VLAN', '2404') %}
+{%- set TENANT_VLAN = os_env('TENANT_VLAN', '2406') %}
+
+{%- set IPMI_USER = os_env('IPMI_USER', 'mcp-qa') %}
+{%- set IPMI_PASS = os_env('IPMI_PASS', 'password') %}
+{%- set CISCO_PASS = os_env('CISCO_PASS', 'cisco_pass') %}
+
+
+{% import 'shared-salt.yaml' as SHARED with context %}
+
+{{ SHARED.MACRO_INSTALL_PACKAGES_ON_NODES(HOSTNAME_CFG01) }}
+
+{{ SHARED.MACRO_INSTALL_FORMULAS_FROM_UPDATE() }}
+
+{{ SHARED.MACRO_INSTALL_FORMULAS('\*') }}
+
+{{ SHARED.MACRO_UPLOAD_AND_IMPORT_GPG_ENCRYPTION_KEY() }}
+
+{{ SHARED.MACRO_GENERATE_COOKIECUTTER_MODEL(CONTROL_VLAN=CONTROL_VLAN, TENANT_VLAN=TENANT_VLAN) }}
+
+{{ SHARED.MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() }}
+
+
+- description: Temporary WR for correct bridge name according to envoronment templates
+  cmd: |
+    sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
+    sed -i 's/br\-mgm/br\_mgm/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
+    sed -i 's/br\-baremetal/br\_baremetal/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/kvm.yml;
+    sed -i 's/br\-ctl/br\_ctl/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/openstack/gateway.yml;
+    salt '*' saltutil.refresh_pillar;
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 10}
+  skip_fail: false
+
+{{ SHARED.MACRO_GENERATE_INVENTORY(RERUN_SALTMASTER_STATE=true) }}
+
+- description: Defining username and password params for IPMI access
+  cmd: |
+    sed -i 's/==IPMI_USER==/${_param:power_user}/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/maas_machines.yml;
+    sed -i 's/==IPMI_PASS==/${_param:power_password}/g' /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/maas_machines.yml;
+    sed -i 's/==IPMI_USER==/${_param:power_user}/g' /srv/salt/reclass/classes/environment/{{ LAB_CONFIG_NAME }}/features/ironic/baremetal_nodes.yml;
+    sed -i 's/==IPMI_PASS==/${_param:power_password}/g' /srv/salt/reclass/classes/environment/{{ LAB_CONFIG_NAME }}/features/ironic/baremetal_nodes.yml;
+    sed -i 's/==IPMI_USER==/${_param:power_user}/g' /srv/salt/reclass/classes/environment/{{ LAB_CONFIG_NAME }}/features/ironic/switch.yml;
+    sed -i 's/==CISCO_PASS==/${_param:cisco_password}/g' /srv/salt/reclass/classes/environment/{{ LAB_CONFIG_NAME }}/features/ironic/switch.yml;
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 10}
+  skip_fail: false
+
+- description: "Add user/password for IPMI access"
+  cmd: |
+    set -e;
+    set -x;
+    . /root/venv-reclass-tools/bin/activate;
+    reclass-tools add-key parameters._param.power_user {{ IPMI_USER }} /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/maas_machines.yml;
+    reclass-tools add-key parameters._param.power_password {{ IPMI_PASS }} /srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/infra/maas_machines.yml;
+    reclass-tools add-key parameters._param.power_user {{ IPMI_USER }} /srv/salt/reclass/classes/environment/{{ LAB_CONFIG_NAME }}/features/ironic/baremetal_nodes.yml;
+    reclass-tools add-key parameters._param.power_password {{ IPMI_PASS }} /srv/salt/reclass/classes/environment/{{ LAB_CONFIG_NAME }}/features/ironic/baremetal_nodes.yml;
+    reclass-tools add-key parameters._param.power_user {{ IPMI_USER }} /srv/salt/reclass/classes/environment/{{ LAB_CONFIG_NAME }}/features/ironic/switch.yml;
+    reclass-tools add-key parameters._param.cisco_password {{ CISCO_PASS }} /srv/salt/reclass/classes/environment/{{ LAB_CONFIG_NAME }}/features/ironic/switch.yml;
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false