Added 12h timeout to all pipelines

Change-Id: I085fcbda322d0877d5ffebd002fc109577788c29
diff --git a/cloud-deploy-pipeline.groovy b/cloud-deploy-pipeline.groovy
index 11ac571..cda022b 100644
--- a/cloud-deploy-pipeline.groovy
+++ b/cloud-deploy-pipeline.groovy
@@ -87,500 +87,501 @@
 if (common.validInputParam('SLAVE_NODE')) {
     slave_node = SLAVE_NODE
 }
+timeout(time: 12, unit: 'HOURS') {
+    node(slave_node) {
+        try {
+            // Set build-specific variables
+            venv = "${env.WORKSPACE}/venv"
+            venvPepper = "${env.WORKSPACE}/venvPepper"
 
-node(slave_node) {
-    try {
-        // Set build-specific variables
-        venv = "${env.WORKSPACE}/venv"
-        venvPepper = "${env.WORKSPACE}/venvPepper"
+            //
+            // Prepare machines
+            //
+            stage ('Create infrastructure') {
 
-        //
-        // Prepare machines
-        //
-        stage ('Create infrastructure') {
+                outputs.put('stack_type', STACK_TYPE)
 
-            outputs.put('stack_type', STACK_TYPE)
+                if (STACK_TYPE == 'heat') {
+                    // value defaults
+                    envParams = [
+                        'cluster_zone': HEAT_STACK_ZONE,
+                        'cluster_public_net': HEAT_STACK_PUBLIC_NET
+                    ]
 
-            if (STACK_TYPE == 'heat') {
-                // value defaults
-                envParams = [
-                    'cluster_zone': HEAT_STACK_ZONE,
-                    'cluster_public_net': HEAT_STACK_PUBLIC_NET
-                ]
-
-                if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
-                    error("If you want to reuse existing stack you need to provide it's name")
-                }
-
-                if (STACK_REUSE.toBoolean() == false) {
-                    // Don't allow to set custom heat stack name
-                    wrap([$class: 'BuildUser']) {
-                        if (env.BUILD_USER_ID) {
-                            STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
-                        } else {
-                            STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
-                        }
-                        currentBuild.description = STACK_NAME
-                    }
-                }
-
-                // no underscore in STACK_NAME
-                STACK_NAME = STACK_NAME.replaceAll('_', '-')
-                outputs.put('stack_name', STACK_NAME)
-
-                // set description
-                currentBuild.description = "${STACK_NAME}"
-
-                // get templates
-                git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
-
-                // create openstack env
-                openstack.setupOpenstackVirtualenv(venv, OPENSTACK_API_CLIENT)
-                openstackCloud = openstack.createOpenstackEnv(
-                    OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS,
-                    OPENSTACK_API_PROJECT, OPENSTACK_API_PROJECT_DOMAIN,
-                    OPENSTACK_API_PROJECT_ID, OPENSTACK_API_USER_DOMAIN,
-                    OPENSTACK_API_VERSION)
-                openstack.getKeystoneToken(openstackCloud, venv)
-
-                //
-                // Verify possibility of create stack for given user and stack type
-                //
-                wrap([$class: 'BuildUser']) {
-                    if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !STACK_REUSE.toBoolean()) {
-                        def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}".replaceAll('_', '-'), venv)
-                        if (existingStacks.size() >= _MAX_PERMITTED_STACKS) {
-                            STACK_DELETE = "false"
-                            throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
-                        }
-                    }
-                }
-                // launch stack
-                if (STACK_REUSE.toBoolean() == false) {
-
-                    // set reclass repo in heat env
-                    try {
-                        envParams.put('cfg_reclass_branch', STACK_RECLASS_BRANCH)
-                        envParams.put('cfg_reclass_address', STACK_RECLASS_ADDRESS)
-                    } catch (MissingPropertyException e) {
-                        common.infoMsg("Property STACK_RECLASS_BRANCH or STACK_RECLASS_ADDRESS not found! Using default values from template.")
+                    if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
+                        error("If you want to reuse existing stack you need to provide it's name")
                     }
 
-                    // put formulas revision - stable, testing or nightly
-                    if (common.validInputParam('FORMULA_PKG_REVISION')) {
-                        common.infoMsg("Setting formulas revision to ${FORMULA_PKG_REVISION}")
-                        envParams.put('cfg_formula_pkg_revision', FORMULA_PKG_REVISION)
-                    }
-
-                    // put extra repo definitions
-                    if (common.validInputParam('BOOTSTRAP_EXTRA_REPO_PARAMS')) {
-                        common.infoMsg("Setting additional repo during bootstrap to ${BOOTSTRAP_EXTRA_REPO_PARAMS}")
-                        envParams.put('cfg_bootstrap_extra_repo_params', BOOTSTRAP_EXTRA_REPO_PARAMS)
-                    }
-
-                    // put extra salt-formulas
-                    if (common.validInputParam('EXTRA_FORMULAS')) {
-                        common.infoMsg("Setting extra salt-formulas to ${EXTRA_FORMULAS}")
-                        envParams.put('cfg_extra_formulas', EXTRA_FORMULAS)
-                    }
-
-                    openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, venv)
-                }
-
-                // get SALT_MASTER_URL
-                saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', venv)
-                // check that saltMasterHost is valid
-                if (!saltMasterHost || !saltMasterHost.matches(ipRegex)) {
-                    common.errorMsg("saltMasterHost is not a valid ip, value is: ${saltMasterHost}")
-                    throw new Exception("saltMasterHost is not a valid ip")
-                }
-
-                currentBuild.description = "${STACK_NAME} ${saltMasterHost}"
-
-                SALT_MASTER_URL = "http://${saltMasterHost}:6969"
-
-            } else if (STACK_TYPE == 'aws') {
-
-                // setup environment
-                aws.setupVirtualEnv(venv)
-
-                // set aws_env_vars
-                aws_env_vars = aws.getEnvVars(AWS_API_CREDENTIALS, AWS_STACK_REGION)
-
-                if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
-                    error("If you want to reuse existing stack you need to provide it's name")
-                }
-
-                if (STACK_REUSE.toBoolean() == false) {
-                    // Don't allow to set custom stack name
-                    wrap([$class: 'BuildUser']) {
-                        if (env.BUILD_USER_ID) {
-                            STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
-                        } else {
-                            STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
+                    if (STACK_REUSE.toBoolean() == false) {
+                        // Don't allow to set custom heat stack name
+                        wrap([$class: 'BuildUser']) {
+                            if (env.BUILD_USER_ID) {
+                                STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
+                            } else {
+                                STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
+                            }
+                            currentBuild.description = STACK_NAME
                         }
                     }
 
                     // no underscore in STACK_NAME
                     STACK_NAME = STACK_NAME.replaceAll('_', '-')
-                }
+                    outputs.put('stack_name', STACK_NAME)
 
-                // set description
-                currentBuild.description = STACK_NAME
-                outputs.put('stack_name', STACK_NAME)
+                    // set description
+                    currentBuild.description = "${STACK_NAME}"
 
-                if (STACK_REUSE.toBoolean() == false) {
                     // get templates
                     git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
 
-                    // start stack
-                    def stack_params = [
-                        "ParameterKey=KeyName,ParameterValue=" + AWS_SSH_KEY,
-                        "ParameterKey=CmpNodeCount,ParameterValue=" + STACK_COMPUTE_COUNT
-                    ]
-                    def template_file = 'cfn/' + STACK_TEMPLATE + '.yml'
-                    aws.createStack(venv, aws_env_vars, template_file, STACK_NAME, stack_params)
-                }
+                    // create openstack env
+                    openstack.setupOpenstackVirtualenv(venv, OPENSTACK_API_CLIENT)
+                    openstackCloud = openstack.createOpenstackEnv(
+                        OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS,
+                        OPENSTACK_API_PROJECT, OPENSTACK_API_PROJECT_DOMAIN,
+                        OPENSTACK_API_PROJECT_ID, OPENSTACK_API_USER_DOMAIN,
+                        OPENSTACK_API_VERSION)
+                    openstack.getKeystoneToken(openstackCloud, venv)
 
-                // wait for stack to be ready
-                aws.waitForStatus(venv, aws_env_vars, STACK_NAME, 'CREATE_COMPLETE')
-
-                // get outputs
-                saltMasterHost = aws.getOutputs(venv, aws_env_vars, STACK_NAME, 'SaltMasterIP')
-
-                // check that saltMasterHost is valid
-                if (!saltMasterHost || !saltMasterHost.matches(ipRegex)) {
-                    common.errorMsg("saltMasterHost is not a valid ip, value is: ${saltMasterHost}")
-                    throw new Exception("saltMasterHost is not a valid ip")
-                }
-
-                currentBuild.description = "${STACK_NAME} ${saltMasterHost}"
-                SALT_MASTER_URL = "http://${saltMasterHost}:6969"
-
-            } else if (STACK_TYPE != 'physical') {
-                throw new Exception("STACK_TYPE ${STACK_TYPE} is not supported")
-            }
-
-            outputs.put('salt_api', SALT_MASTER_URL)
-
-            // Setup virtualenv for pepper
-            python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
-        }
-
-
-        // Set up override params
-        if (common.validInputParam('SALT_OVERRIDES')) {
-            stage('Set Salt overrides') {
-                salt.setSaltOverrides(venvPepper,  SALT_OVERRIDES)
-            }
-        }
-
-        //
-        // Install
-        //
-
-        if (common.checkContains('STACK_INSTALL', 'core')) {
-            stage('Install core infrastructure') {
-                def staticMgmtNetwork = false
-                if (common.validInputParam('STATIC_MGMT_NETWORK')) {
-                    staticMgmtNetwork = STATIC_MGMT_NETWORK.toBoolean()
-                }
-                orchestrate.installFoundationInfra(venvPepper, staticMgmtNetwork)
-
-                if (common.checkContains('STACK_INSTALL', 'kvm')) {
-                    orchestrate.installInfraKvm(venvPepper)
-                    orchestrate.installFoundationInfra(venvPepper, staticMgmtNetwork)
-                }
-
-                orchestrate.validateFoundationInfra(venvPepper)
-            }
-        }
-
-        // install k8s
-        if (common.checkContains('STACK_INSTALL', 'k8s')) {
-
-            stage('Install Kubernetes infra') {
-                if (STACK_TYPE == 'aws') {
-                    // configure kubernetes_control_address - save loadbalancer
-                    def awsOutputs = aws.getOutputs(venv, aws_env_vars, STACK_NAME)
-                    common.prettyPrint(awsOutputs)
-                    if (awsOutputs.containsKey('ControlLoadBalancer')) {
-                        salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_control_address', awsOutputs['ControlLoadBalancer']], null, true)
-                        outputs.put('kubernetes_apiserver', 'https://' + awsOutputs['ControlLoadBalancer'])
+                    //
+                    // Verify possibility of create stack for given user and stack type
+                    //
+                    wrap([$class: 'BuildUser']) {
+                        if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !STACK_REUSE.toBoolean()) {
+                            def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}".replaceAll('_', '-'), venv)
+                            if (existingStacks.size() >= _MAX_PERMITTED_STACKS) {
+                                STACK_DELETE = "false"
+                                throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}")
+                            }
+                        }
                     }
-                }
+                    // launch stack
+                    if (STACK_REUSE.toBoolean() == false) {
 
-                // ensure certificates are generated properly
-                salt.runSaltProcessStep(venvPepper, '*', 'saltutil.refresh_pillar', [], null, true)
-                salt.enforceState(venvPepper, '*', ['salt.minion.cert'], true)
-
-                orchestrate.installKubernetesInfra(venvPepper)
-            }
-
-            if (common.checkContains('STACK_INSTALL', 'contrail')) {
-                stage('Install Contrail for Kubernetes') {
-                    orchestrate.installContrailNetwork(venvPepper)
-                    orchestrate.installContrailCompute(venvPepper)
-                }
-            }
-
-            stage('Install Kubernetes control') {
-                orchestrate.installKubernetesControl(venvPepper)
-
-                // collect artifacts (kubeconfig)
-                writeFile(file: 'kubeconfig', text: salt.getFileContent(venvPepper, 'I@kubernetes:master and *01*', '/etc/kubernetes/admin-kube-config'))
-                archiveArtifacts(artifacts: 'kubeconfig')
-            }
-
-            stage('Install Kubernetes computes') {
-                if (common.validInputParam('STACK_COMPUTE_COUNT')) {
-                    if (STACK_COMPUTE_COUNT > 0) {
-                        if (STACK_TYPE == 'aws') {
-                            // get stack info
-                            def scaling_group = aws.getOutputs(venv, aws_env_vars, STACK_NAME, 'ComputesScalingGroup')
-
-                            //update autoscaling group
-                            aws.updateAutoscalingGroup(venv, aws_env_vars, scaling_group, ["--desired-capacity " + STACK_COMPUTE_COUNT])
-
-                            // wait for computes to boot up
-                            aws.waitForAutoscalingInstances(venv, aws_env_vars, scaling_group)
-                            sleep(60)
-
-                        } else if (STACK_TYPE == 'heat') {
-                            envParams.put('cluster_node_count', STACK_COMPUTE_COUNT)
-
-                            openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, venv, "update")
-                            sleep(60)
+                        // set reclass repo in heat env
+                        try {
+                            envParams.put('cfg_reclass_branch', STACK_RECLASS_BRANCH)
+                            envParams.put('cfg_reclass_address', STACK_RECLASS_ADDRESS)
+                        } catch (MissingPropertyException e) {
+                            common.infoMsg("Property STACK_RECLASS_BRANCH or STACK_RECLASS_ADDRESS not found! Using default values from template.")
                         }
 
+                        // put formulas revision - stable, testing or nightly
+                        if (common.validInputParam('FORMULA_PKG_REVISION')) {
+                            common.infoMsg("Setting formulas revision to ${FORMULA_PKG_REVISION}")
+                            envParams.put('cfg_formula_pkg_revision', FORMULA_PKG_REVISION)
+                        }
+
+                        // put extra repo definitions
+                        if (common.validInputParam('BOOTSTRAP_EXTRA_REPO_PARAMS')) {
+                            common.infoMsg("Setting additional repo during bootstrap to ${BOOTSTRAP_EXTRA_REPO_PARAMS}")
+                            envParams.put('cfg_bootstrap_extra_repo_params', BOOTSTRAP_EXTRA_REPO_PARAMS)
+                        }
+
+                        // put extra salt-formulas
+                        if (common.validInputParam('EXTRA_FORMULAS')) {
+                            common.infoMsg("Setting extra salt-formulas to ${EXTRA_FORMULAS}")
+                            envParams.put('cfg_extra_formulas', EXTRA_FORMULAS)
+                        }
+
+                        openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, venv)
+                    }
+
+                    // get SALT_MASTER_URL
+                    saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', venv)
+                    // check that saltMasterHost is valid
+                    if (!saltMasterHost || !saltMasterHost.matches(ipRegex)) {
+                        common.errorMsg("saltMasterHost is not a valid ip, value is: ${saltMasterHost}")
+                        throw new Exception("saltMasterHost is not a valid ip")
+                    }
+
+                    currentBuild.description = "${STACK_NAME} ${saltMasterHost}"
+
+                    SALT_MASTER_URL = "http://${saltMasterHost}:6969"
+
+                } else if (STACK_TYPE == 'aws') {
+
+                    // setup environment
+                    aws.setupVirtualEnv(venv)
+
+                    // set aws_env_vars
+                    aws_env_vars = aws.getEnvVars(AWS_API_CREDENTIALS, AWS_STACK_REGION)
+
+                    if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') {
+                        error("If you want to reuse existing stack you need to provide it's name")
+                    }
+
+                    if (STACK_REUSE.toBoolean() == false) {
+                        // Don't allow to set custom stack name
+                        wrap([$class: 'BuildUser']) {
+                            if (env.BUILD_USER_ID) {
+                                STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
+                            } else {
+                                STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
+                            }
+                        }
+
+                        // no underscore in STACK_NAME
+                        STACK_NAME = STACK_NAME.replaceAll('_', '-')
+                    }
+
+                    // set description
+                    currentBuild.description = STACK_NAME
+                    outputs.put('stack_name', STACK_NAME)
+
+                    if (STACK_REUSE.toBoolean() == false) {
+                        // get templates
+                        git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS)
+
+                        // start stack
+                        def stack_params = [
+                            "ParameterKey=KeyName,ParameterValue=" + AWS_SSH_KEY,
+                            "ParameterKey=CmpNodeCount,ParameterValue=" + STACK_COMPUTE_COUNT
+                        ]
+                        def template_file = 'cfn/' + STACK_TEMPLATE + '.yml'
+                        aws.createStack(venv, aws_env_vars, template_file, STACK_NAME, stack_params)
+                    }
+
+                    // wait for stack to be ready
+                    aws.waitForStatus(venv, aws_env_vars, STACK_NAME, 'CREATE_COMPLETE')
+
+                    // get outputs
+                    saltMasterHost = aws.getOutputs(venv, aws_env_vars, STACK_NAME, 'SaltMasterIP')
+
+                    // check that saltMasterHost is valid
+                    if (!saltMasterHost || !saltMasterHost.matches(ipRegex)) {
+                        common.errorMsg("saltMasterHost is not a valid ip, value is: ${saltMasterHost}")
+                        throw new Exception("saltMasterHost is not a valid ip")
+                    }
+
+                    currentBuild.description = "${STACK_NAME} ${saltMasterHost}"
+                    SALT_MASTER_URL = "http://${saltMasterHost}:6969"
+
+                } else if (STACK_TYPE != 'physical') {
+                    throw new Exception("STACK_TYPE ${STACK_TYPE} is not supported")
+                }
+
+                outputs.put('salt_api', SALT_MASTER_URL)
+
+                // Setup virtualenv for pepper
+                python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+            }
+
+
+            // Set up override params
+            if (common.validInputParam('SALT_OVERRIDES')) {
+                stage('Set Salt overrides') {
+                    salt.setSaltOverrides(venvPepper,  SALT_OVERRIDES)
+                }
+            }
+
+            //
+            // Install
+            //
+
+            if (common.checkContains('STACK_INSTALL', 'core')) {
+                stage('Install core infrastructure') {
+                    def staticMgmtNetwork = false
+                    if (common.validInputParam('STATIC_MGMT_NETWORK')) {
+                        staticMgmtNetwork = STATIC_MGMT_NETWORK.toBoolean()
+                    }
+                    orchestrate.installFoundationInfra(venvPepper, staticMgmtNetwork)
+
+                    if (common.checkContains('STACK_INSTALL', 'kvm')) {
+                        orchestrate.installInfraKvm(venvPepper)
+                        orchestrate.installFoundationInfra(venvPepper, staticMgmtNetwork)
+                    }
+
+                    orchestrate.validateFoundationInfra(venvPepper)
+                }
+            }
+
+            // install k8s
+            if (common.checkContains('STACK_INSTALL', 'k8s')) {
+
+                stage('Install Kubernetes infra') {
+                    if (STACK_TYPE == 'aws') {
+                        // configure kubernetes_control_address - save loadbalancer
+                        def awsOutputs = aws.getOutputs(venv, aws_env_vars, STACK_NAME)
+                        common.prettyPrint(awsOutputs)
+                        if (awsOutputs.containsKey('ControlLoadBalancer')) {
+                            salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_control_address', awsOutputs['ControlLoadBalancer']], null, true)
+                            outputs.put('kubernetes_apiserver', 'https://' + awsOutputs['ControlLoadBalancer'])
+                        }
+                    }
+
+                    // ensure certificates are generated properly
+                    salt.runSaltProcessStep(venvPepper, '*', 'saltutil.refresh_pillar', [], null, true)
+                    salt.enforceState(venvPepper, '*', ['salt.minion.cert'], true)
+
+                    orchestrate.installKubernetesInfra(venvPepper)
+                }
+
+                if (common.checkContains('STACK_INSTALL', 'contrail')) {
+                    stage('Install Contrail for Kubernetes') {
+                        orchestrate.installContrailNetwork(venvPepper)
+                        orchestrate.installContrailCompute(venvPepper)
                     }
                 }
 
-                orchestrate.installKubernetesCompute(venvPepper)
-            }
-        }
+                stage('Install Kubernetes control') {
+                    orchestrate.installKubernetesControl(venvPepper)
 
-        // install openstack
-        if (common.checkContains('STACK_INSTALL', 'openstack')) {
-            // install Infra and control, tests, ...
-
-            stage('Install OpenStack infra') {
-                orchestrate.installOpenstackInfra(venvPepper)
-            }
-
-            stage('Install OpenStack control') {
-                orchestrate.installOpenstackControl(venvPepper)
-            }
-
-            stage('Install OpenStack network') {
-
-                if (common.checkContains('STACK_INSTALL', 'contrail')) {
-                    orchestrate.installContrailNetwork(venvPepper)
-                } else if (common.checkContains('STACK_INSTALL', 'ovs')) {
-                    orchestrate.installOpenstackNetwork(venvPepper)
+                    // collect artifacts (kubeconfig)
+                    writeFile(file: 'kubeconfig', text: salt.getFileContent(venvPepper, 'I@kubernetes:master and *01*', '/etc/kubernetes/admin-kube-config'))
+                    archiveArtifacts(artifacts: 'kubeconfig')
                 }
 
-                salt.runSaltProcessStep(venvPepper, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
-                salt.runSaltProcessStep(venvPepper, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
+                stage('Install Kubernetes computes') {
+                    if (common.validInputParam('STACK_COMPUTE_COUNT')) {
+                        if (STACK_COMPUTE_COUNT > 0) {
+                            if (STACK_TYPE == 'aws') {
+                                // get stack info
+                                def scaling_group = aws.getOutputs(venv, aws_env_vars, STACK_NAME, 'ComputesScalingGroup')
+
+                                //update autoscaling group
+                                aws.updateAutoscalingGroup(venv, aws_env_vars, scaling_group, ["--desired-capacity " + STACK_COMPUTE_COUNT])
+
+                                // wait for computes to boot up
+                                aws.waitForAutoscalingInstances(venv, aws_env_vars, scaling_group)
+                                sleep(60)
+
+                            } else if (STACK_TYPE == 'heat') {
+                                envParams.put('cluster_node_count', STACK_COMPUTE_COUNT)
+
+                                openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, venv, "update")
+                                sleep(60)
+                            }
+
+                        }
+                    }
+
+                    orchestrate.installKubernetesCompute(venvPepper)
+                }
             }
 
-            if (salt.testTarget(venvPepper, 'I@ironic:conductor')){
-                stage('Install OpenStack Ironic conductor') {
-                    orchestrate.installIronicConductor(venvPepper)
+            // install openstack
+            if (common.checkContains('STACK_INSTALL', 'openstack')) {
+                // install Infra and control, tests, ...
+
+                stage('Install OpenStack infra') {
+                    orchestrate.installOpenstackInfra(venvPepper)
+                }
+
+                stage('Install OpenStack control') {
+                    orchestrate.installOpenstackControl(venvPepper)
+                }
+
+                stage('Install OpenStack network') {
+
+                    if (common.checkContains('STACK_INSTALL', 'contrail')) {
+                        orchestrate.installContrailNetwork(venvPepper)
+                    } else if (common.checkContains('STACK_INSTALL', 'ovs')) {
+                        orchestrate.installOpenstackNetwork(venvPepper)
+                    }
+
+                    salt.runSaltProcessStep(venvPepper, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'])
+                    salt.runSaltProcessStep(venvPepper, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'])
+                }
+
+                if (salt.testTarget(venvPepper, 'I@ironic:conductor')){
+                    stage('Install OpenStack Ironic conductor') {
+                        orchestrate.installIronicConductor(venvPepper)
+                    }
+                }
+
+
+                stage('Install OpenStack compute') {
+                    orchestrate.installOpenstackCompute(venvPepper)
+
+                    if (common.checkContains('STACK_INSTALL', 'contrail')) {
+                        orchestrate.installContrailCompute(venvPepper)
+                    }
+                }
+
+            }
+
+            // install ceph
+            if (common.checkContains('STACK_INSTALL', 'ceph')) {
+                stage('Install Ceph MONs') {
+                    orchestrate.installCephMon(venvPepper)
+                }
+
+                stage('Install Ceph OSDs') {
+                    orchestrate.installCephOsd(venvPepper)
+                }
+
+
+                stage('Install Ceph clients') {
+                    orchestrate.installCephClient(venvPepper)
+                }
+
+                stage('Connect Ceph') {
+                    orchestrate.connectCeph(venvPepper)
+                }
+            }
+
+            if (common.checkContains('STACK_INSTALL', 'oss')) {
+              stage('Install Oss infra') {
+                orchestrate.installOssInfra(venvPepper)
+              }
+            }
+
+            if (common.checkContains('STACK_INSTALL', 'cicd')) {
+                stage('Install Cicd') {
+                    orchestrate.installInfra(venvPepper)
+                    orchestrate.installDockerSwarm(venvPepper)
+                    orchestrate.installCicd(venvPepper)
+                }
+            }
+
+            if (common.checkContains('STACK_INSTALL', 'sl-legacy')) {
+                stage('Install StackLight v1') {
+                    orchestrate.installStacklightv1Control(venvPepper)
+                    orchestrate.installStacklightv1Client(venvPepper)
+                }
+            }
+
+            if (common.checkContains('STACK_INSTALL', 'stacklight')) {
+                stage('Install StackLight') {
+                    orchestrate.installDockerSwarm(venvPepper)
+                    orchestrate.installStacklight(venvPepper)
+                }
+            }
+
+            if (common.checkContains('STACK_INSTALL', 'oss')) {
+              stage('Install OSS') {
+                if (!common.checkContains('STACK_INSTALL', 'stacklight')) {
+                  // In case if StackLightv2 enabled containers already started
+                  orchestrate.installDockerSwarm(venvPepper)
+                  salt.enforceState(venvPepper, 'I@docker:swarm:role:master and I@devops_portal:config', 'docker.client', true)
+                }
+                orchestrate.installOss(venvPepper)
+              }
+            }
+
+            //
+            // Test
+            //
+            def artifacts_dir = '_artifacts/'
+
+            if (common.checkContains('STACK_TEST', 'k8s')) {
+                stage('Run k8s conformance e2e tests') {
+                    def image = TEST_K8S_CONFORMANCE_IMAGE
+                    def output_file = image.replaceAll('/', '-') + '.output'
+
+                    // run image
+                    test.runConformanceTests(venvPepper, 'ctl01*', TEST_K8S_API_SERVER, image)
+
+                    // collect output
+                    sh "mkdir -p ${artifacts_dir}"
+                    file_content = salt.getFileContent(venvPepper, 'ctl01*', '/tmp/' + output_file)
+                    writeFile file: "${artifacts_dir}${output_file}", text: file_content
+                    sh "cat ${artifacts_dir}${output_file}"
+
+                    // collect artifacts
+                    archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
+                }
+            }
+
+            if (common.checkContains('STACK_TEST', 'openstack')) {
+                if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) {
+                    test.install_docker(venvPepper, TEST_TEMPEST_TARGET)
+                }
+                stage('Run OpenStack tests') {
+                    test.runTempestTests(venvPepper, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN)
+                }
+
+                stage('Copy Tempest results to config node') {
+                    test.copyTempestResults(venvPepper, TEST_TEMPEST_TARGET)
+                }
+
+                stage('Archive rally artifacts') {
+                    test.archiveRallyArtifacts(venvPepper, TEST_TEMPEST_TARGET)
                 }
             }
 
 
-            stage('Install OpenStack compute') {
-                orchestrate.installOpenstackCompute(venvPepper)
-
-                if (common.checkContains('STACK_INSTALL', 'contrail')) {
-                    orchestrate.installContrailCompute(venvPepper)
+            if (common.checkContains('STACK_TEST', 'ceph')) {
+                stage('Run infra tests') {
+                    sleep(120)
+                    def cmd = "apt-get install -y python-pip && pip install -r /usr/share/salt-formulas/env/ceph/files/testinfra/requirements.txt && python -m pytest --junitxml=/root/report.xml /usr/share/salt-formulas/env/ceph/files/testinfra/"
+                    salt.cmdRun(venvPepper, 'I@salt:master', cmd, false)
+                    writeFile(file: 'report.xml', text: salt.getFileContent(venvPepper, 'I@salt:master', '/root/report.xml'))
+                    junit(keepLongStdio: true, testResults: 'report.xml')
                 }
             }
 
-        }
+            if (common.checkContains('STACK_TEST', 'opencontrail')) {
+                stage('Run opencontrail tests') {
+                    def opencontrail_tests_dir = "/opt/opencontrail_test/fuel-plugin-contrail/plugin_test/vapor/"
+                    def report_dir = "/opt/opencontrail-test-report/"
+                    def cmd = ". ${opencontrail_tests_dir}exports.sh && " +
+                              "cd ${opencontrail_tests_dir} && " +
+                              "py.test --junit-xml=${report_dir}report.xml" +
+                              " --html=${report_dir}report.html -v vapor/tests/ -k 'not destructive' "
 
-        // install ceph
-        if (common.checkContains('STACK_INSTALL', 'ceph')) {
-            stage('Install Ceph MONs') {
-                orchestrate.installCephMon(venvPepper)
-            }
+                    salt.runSaltProcessStep(venvPepper, 'cfg*', 'saltutil.refresh_pillar', [], null, true)
+                    salt.enforceState(venvPepper, 'I@opencontrail:test' , 'opencontrail.test' , true)
 
-            stage('Install Ceph OSDs') {
-                orchestrate.installCephOsd(venvPepper)
+                    salt.cmdRun(venvPepper, 'I@opencontrail:test', cmd, false)
+
+                    writeFile(file: 'report.xml', text: salt.getFileContent(venvPepper,
+                              'I@opencontrail:test', "${report_dir}report.xml"))
+                    junit(keepLongStdio: true, testResults: 'report.xml')
+                }
             }
 
 
-            stage('Install Ceph clients') {
-                orchestrate.installCephClient(venvPepper)
+            stage('Finalize') {
+                if (common.checkContains('STACK_INSTALL', 'finalize')) {
+                    salt.runSaltProcessStep(venvPepper, '*', 'state.apply', [], null, true)
+                }
+
+                outputsPretty = common.prettify(outputs)
+                print(outputsPretty)
+                writeFile(file: 'outputs.json', text: outputsPretty)
+                archiveArtifacts(artifacts: 'outputs.json')
             }
 
-            stage('Connect Ceph') {
-                orchestrate.connectCeph(venvPepper)
-            }
-        }
+        } catch (Throwable e) {
+            currentBuild.result = 'FAILURE'
+            throw e
+        } finally {
 
-        if (common.checkContains('STACK_INSTALL', 'oss')) {
-          stage('Install Oss infra') {
-            orchestrate.installOssInfra(venvPepper)
-          }
-        }
 
-        if (common.checkContains('STACK_INSTALL', 'cicd')) {
-            stage('Install Cicd') {
-                orchestrate.installInfra(venvPepper)
-                orchestrate.installDockerSwarm(venvPepper)
-                orchestrate.installCicd(venvPepper)
-            }
-        }
+            //
+            // Clean
+            //
 
-        if (common.checkContains('STACK_INSTALL', 'sl-legacy')) {
-            stage('Install StackLight v1') {
-                orchestrate.installStacklightv1Control(venvPepper)
-                orchestrate.installStacklightv1Client(venvPepper)
-            }
-        }
-
-        if (common.checkContains('STACK_INSTALL', 'stacklight')) {
-            stage('Install StackLight') {
-                orchestrate.installDockerSwarm(venvPepper)
-                orchestrate.installStacklight(venvPepper)
-            }
-        }
-
-        if (common.checkContains('STACK_INSTALL', 'oss')) {
-          stage('Install OSS') {
-            if (!common.checkContains('STACK_INSTALL', 'stacklight')) {
-              // In case if StackLightv2 enabled containers already started
-              orchestrate.installDockerSwarm(venvPepper)
-              salt.enforceState(venvPepper, 'I@docker:swarm:role:master and I@devops_portal:config', 'docker.client', true)
-            }
-            orchestrate.installOss(venvPepper)
-          }
-        }
-
-        //
-        // Test
-        //
-        def artifacts_dir = '_artifacts/'
-
-        if (common.checkContains('STACK_TEST', 'k8s')) {
-            stage('Run k8s conformance e2e tests') {
-                def image = TEST_K8S_CONFORMANCE_IMAGE
-                def output_file = image.replaceAll('/', '-') + '.output'
-
-                // run image
-                test.runConformanceTests(venvPepper, 'ctl01*', TEST_K8S_API_SERVER, image)
-
-                // collect output
-                sh "mkdir -p ${artifacts_dir}"
-                file_content = salt.getFileContent(venvPepper, 'ctl01*', '/tmp/' + output_file)
-                writeFile file: "${artifacts_dir}${output_file}", text: file_content
-                sh "cat ${artifacts_dir}${output_file}"
-
-                // collect artifacts
-                archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
-            }
-        }
-
-        if (common.checkContains('STACK_TEST', 'openstack')) {
-            if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) {
-                test.install_docker(venvPepper, TEST_TEMPEST_TARGET)
-            }
-            stage('Run OpenStack tests') {
-                test.runTempestTests(venvPepper, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN)
+            if (common.validInputParam('STACK_NAME')) {
+                // send notification
+                common.sendNotification(currentBuild.result, STACK_NAME, ["slack"])
             }
 
-            stage('Copy Tempest results to config node') {
-                test.copyTempestResults(venvPepper, TEST_TEMPEST_TARGET)
-            }
+            if (common.validInputParam('STACK_DELETE') && STACK_DELETE.toBoolean() == true) {
+                stage('Trigger cleanup job') {
+                    common.errorMsg('Stack cleanup job triggered')
+                    build(job: STACK_CLEANUP_JOB, parameters: [
+                        [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME],
+                        [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE],
+                        [$class: 'StringParameterValue', name: 'OPENSTACK_API_URL', value: OPENSTACK_API_URL],
+                        [$class: 'StringParameterValue', name: 'OPENSTACK_API_CREDENTIALS', value: OPENSTACK_API_CREDENTIALS],
+                        [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT', value: OPENSTACK_API_PROJECT],
+                        [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_DOMAIN', value: OPENSTACK_API_PROJECT_DOMAIN],
+                        [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_ID', value: OPENSTACK_API_PROJECT_ID],
+                        [$class: 'StringParameterValue', name: 'OPENSTACK_API_USER_DOMAIN', value: OPENSTACK_API_USER_DOMAIN],
+                        [$class: 'StringParameterValue', name: 'OPENSTACK_API_CLIENT', value: OPENSTACK_API_CLIENT],
+                        [$class: 'StringParameterValue', name: 'OPENSTACK_API_VERSION', value: OPENSTACK_API_VERSION]
+                    ])
+                }
+            } else {
+                if (currentBuild.result == 'FAILURE') {
+                    common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.")
 
-            stage('Archive rally artifacts') {
-                test.archiveRallyArtifacts(venvPepper, TEST_TEMPEST_TARGET)
-            }
-        }
-
-
-        if (common.checkContains('STACK_TEST', 'ceph')) {
-            stage('Run infra tests') {
-                sleep(120)
-                def cmd = "apt-get install -y python-pip && pip install -r /usr/share/salt-formulas/env/ceph/files/testinfra/requirements.txt && python -m pytest --junitxml=/root/report.xml /usr/share/salt-formulas/env/ceph/files/testinfra/"
-                salt.cmdRun(venvPepper, 'I@salt:master', cmd, false)
-                writeFile(file: 'report.xml', text: salt.getFileContent(venvPepper, 'I@salt:master', '/root/report.xml'))
-                junit(keepLongStdio: true, testResults: 'report.xml')
-            }
-        }
-
-        if (common.checkContains('STACK_TEST', 'opencontrail')) {
-            stage('Run opencontrail tests') {
-                def opencontrail_tests_dir = "/opt/opencontrail_test/fuel-plugin-contrail/plugin_test/vapor/"
-                def report_dir = "/opt/opencontrail-test-report/"
-                def cmd = ". ${opencontrail_tests_dir}exports.sh && " +
-                          "cd ${opencontrail_tests_dir} && " +
-                          "py.test --junit-xml=${report_dir}report.xml" +
-                          " --html=${report_dir}report.html -v vapor/tests/ -k 'not destructive' "
-
-                salt.runSaltProcessStep(venvPepper, 'cfg*', 'saltutil.refresh_pillar', [], null, true)
-                salt.enforceState(venvPepper, 'I@opencontrail:test' , 'opencontrail.test' , true)
-
-                salt.cmdRun(venvPepper, 'I@opencontrail:test', cmd, false)
-
-                writeFile(file: 'report.xml', text: salt.getFileContent(venvPepper,
-                          'I@opencontrail:test', "${report_dir}report.xml"))
-                junit(keepLongStdio: true, testResults: 'report.xml')
-            }
-        }
-
-
-        stage('Finalize') {
-            if (common.checkContains('STACK_INSTALL', 'finalize')) {
-                salt.runSaltProcessStep(venvPepper, '*', 'state.apply', [], null, true)
-            }
-
-            outputsPretty = common.prettify(outputs)
-            print(outputsPretty)
-            writeFile(file: 'outputs.json', text: outputsPretty)
-            archiveArtifacts(artifacts: 'outputs.json')
-        }
-
-    } catch (Throwable e) {
-        currentBuild.result = 'FAILURE'
-        throw e
-    } finally {
-
-
-        //
-        // Clean
-        //
-
-        if (common.validInputParam('STACK_NAME')) {
-            // send notification
-            common.sendNotification(currentBuild.result, STACK_NAME, ["slack"])
-        }
-
-        if (common.validInputParam('STACK_DELETE') && STACK_DELETE.toBoolean() == true) {
-            stage('Trigger cleanup job') {
-                common.errorMsg('Stack cleanup job triggered')
-                build(job: STACK_CLEANUP_JOB, parameters: [
-                    [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME],
-                    [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE],
-                    [$class: 'StringParameterValue', name: 'OPENSTACK_API_URL', value: OPENSTACK_API_URL],
-                    [$class: 'StringParameterValue', name: 'OPENSTACK_API_CREDENTIALS', value: OPENSTACK_API_CREDENTIALS],
-                    [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT', value: OPENSTACK_API_PROJECT],
-                    [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_DOMAIN', value: OPENSTACK_API_PROJECT_DOMAIN],
-                    [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_ID', value: OPENSTACK_API_PROJECT_ID],
-                    [$class: 'StringParameterValue', name: 'OPENSTACK_API_USER_DOMAIN', value: OPENSTACK_API_USER_DOMAIN],
-                    [$class: 'StringParameterValue', name: 'OPENSTACK_API_CLIENT', value: OPENSTACK_API_CLIENT],
-                    [$class: 'StringParameterValue', name: 'OPENSTACK_API_VERSION', value: OPENSTACK_API_VERSION]
-                ])
-            }
-        } else {
-            if (currentBuild.result == 'FAILURE') {
-                common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.")
-
-                if (common.validInputParam('SALT_MASTER_URL')) {
-                    common.errorMsg("Salt master URL: ${SALT_MASTER_URL}")
+                    if (common.validInputParam('SALT_MASTER_URL')) {
+                        common.errorMsg("Salt master URL: ${SALT_MASTER_URL}")
+                    }
                 }
             }
         }