Ales Komarek | 1b3870e | 2017-01-06 10:51:37 +0100 | [diff] [blame] | 1 | /** |
Tomáš Kukrál | 511be61 | 2017-02-20 14:50:18 +0100 | [diff] [blame] | 2 | * DO NOT USE THIS OUTDATED PIPELINE - add your steps to mk-lab-pipeline |
Ales Komarek | 1b3870e | 2017-01-06 10:51:37 +0100 | [diff] [blame] | 3 | * |
| 4 | * Launch heat stack with MAAS lab |
| 5 | * |
| 6 | * Expected parameters: |
| 7 | * HEAT_TEMPLATE_URL URL to git repo with Heat templates |
| 8 | * HEAT_TEMPLATE_CREDENTIALS Credentials to the Heat templates repo |
| 9 | * HEAT_TEMPLATE_BRANCH Heat templates repo branch |
| 10 | * OPENSTACK_API_URL OpenStack API address |
| 11 | * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API |
| 12 | * OPENSTACK_API_PROJECT OpenStack project to connect to |
| 13 | * OPENSTACK_API_CLIENT Versions of OpenStack python clients |
| 14 | * OPENSTACK_API_VERSION Version of the OpenStack API (2/3) |
| 15 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 16 | * HEAT_STACK_NAME Heat stack name |
| 17 | * HEAT_STACK_TEMPLATE Heat stack HOT template |
| 18 | * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters |
| 19 | * HEAT_STACK_ZONE Heat stack availability zone |
| 20 | * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool |
| 21 | */ |
| 22 | |
| 23 | git = new com.mirantis.mk.git() |
| 24 | openstack = new com.mirantis.mk.openstack() |
| 25 | salt = new com.mirantis.mk.salt() |
| 26 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 27 | timeout(time: 12, unit: 'HOURS') { |
| 28 | node { |
Ales Komarek | 1b3870e | 2017-01-06 10:51:37 +0100 | [diff] [blame] | 29 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 30 | // connection objects |
| 31 | def openstackCloud |
| 32 | def saltMaster |
Ales Komarek | 1b3870e | 2017-01-06 10:51:37 +0100 | [diff] [blame] | 33 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 34 | // value defaults |
Jakub Josef | 88aaf83 | 2018-01-18 16:18:28 +0100 | [diff] [blame] | 35 | def workspace = common.getWorkspace() |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 36 | def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : "liberty" |
Jakub Josef | 88aaf83 | 2018-01-18 16:18:28 +0100 | [diff] [blame] | 37 | def openstackEnv = "${workspace}/venv" |
Ales Komarek | 1b3870e | 2017-01-06 10:51:37 +0100 | [diff] [blame] | 38 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 39 | stage ('Download Heat templates') { |
| 40 | git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS) |
| 41 | } |
| 42 | |
| 43 | stage('Install OpenStack env') { |
| 44 | openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion) |
| 45 | } |
| 46 | |
| 47 | stage('Connect to OpenStack cloud') { |
Jakub Josef | 88aaf83 | 2018-01-18 16:18:28 +0100 | [diff] [blame] | 48 | openstackCloud = openstack.createOpenstackEnv(openstackEnv, OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 49 | openstack.getKeystoneToken(openstackCloud, openstackEnv) |
| 50 | } |
| 51 | |
| 52 | stage('Launch new Heat stack') { |
| 53 | envParams = [ |
| 54 | 'availability_zone': HEAT_STACK_ZONE, |
| 55 | 'public_net': HEAT_STACK_PUBLIC_NET |
| 56 | ] |
| 57 | openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv) |
| 58 | } |
| 59 | |
| 60 | stage("Connect to Salt master") { |
| 61 | saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv) |
| 62 | saltMasterUrl = "http://${saltMasterHost}:8000" |
| 63 | saltMaster = salt.createSaltConnection(saltMasterUrl, SALT_MASTER_CREDENTIALS) |
| 64 | } |
| 65 | |
| 66 | stage("Install core infra") { |
| 67 | salt.installFoundationInfra(saltMaster) |
| 68 | salt.validateFoundationInfra(saltMaster) |
| 69 | } |
| 70 | |
| 71 | //stage('Delete Heat stack') { |
| 72 | // openstack.deleteHeatStack(openstackCloud, HEAT_STACK_NAME, openstackEnv) |
| 73 | //} |
Ales Komarek | 1b3870e | 2017-01-06 10:51:37 +0100 | [diff] [blame] | 74 | } |
Ales Komarek | 1b3870e | 2017-01-06 10:51:37 +0100 | [diff] [blame] | 75 | } |