/**
 *  DO NOT USE THIS PIPELINE, USE cleanup-pipeline.groovy
 *
 * Launch heat stack with basic k8s
 *
 * Expected parameters:
 *   OPENSTACK_API_URL          OpenStack API address
 *   OPENSTACK_API_CREDENTIALS  Credentials to the OpenStack API
 *   OPENSTACK_API_PROJECT      OpenStack project to connect to
 *   OPENSTACK_API_CLIENT       Versions of OpenStack python clients
 *   OPENSTACK_API_VERSION      Version of the OpenStack API (2/3)
 *   HEAT_STACK_NAME            Heat stack name
 *
 */

git = new com.mirantis.mk.Git()
openstack = new com.mirantis.mk.Openstack()
salt = new com.mirantis.mk.Salt()
timeout(time: 12, unit: 'HOURS') {
    node {

        // connection objects
        def openstackCloud
        def saltMaster

        // value defaults
        def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
        def workspace = common.getWorkspace()
        def openstackEnv = "${workspace}/venv"

        stage('Install OpenStack env') {
            openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
        }

        stage('Connect to OpenStack cloud') {
            openstackCloud = openstack.createOpenstackEnv(openstackEnv, OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
            openstack.getKeystoneToken(openstackCloud, openstackEnv)
        }

        stage('Delete Heat stack') {
            openstack.deleteHeatStack(openstackCloud, HEAT_STACK_NAME, openstackEnv)
        }

    }
}
