blob: f0218ac52f7e893b3802220b230902c1e511e99b [file] [log] [blame]
Ales Komarek1b3870e2017-01-06 10:51:37 +01001/**
2 *
3 * Launch heat stack with MAAS lab
4 *
5 * Expected parameters:
6 * HEAT_TEMPLATE_URL URL to git repo with Heat templates
7 * HEAT_TEMPLATE_CREDENTIALS Credentials to the Heat templates repo
8 * HEAT_TEMPLATE_BRANCH Heat templates repo branch
9 * OPENSTACK_API_URL OpenStack API address
10 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
11 * OPENSTACK_API_PROJECT OpenStack project to connect to
12 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
13 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
14 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
15 * HEAT_STACK_NAME Heat stack name
16 * HEAT_STACK_TEMPLATE Heat stack HOT template
17 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
18 * HEAT_STACK_ZONE Heat stack availability zone
19 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
20 */
21
22git = new com.mirantis.mk.git()
23openstack = new com.mirantis.mk.openstack()
24salt = new com.mirantis.mk.salt()
25
26node {
27
28 // connection objects
29 def openstackCloud
30 def saltMaster
31
32 // value defaults
33 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : "liberty"
34 def openstackEnv = "${env.WORKSPACE}/venv"
35
36 stage ('Download Heat templates') {
37 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
38 }
39
40 stage('Install OpenStack env') {
41 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
42 }
43
44 stage('Connect to OpenStack cloud') {
45 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
46 openstack.getKeystoneToken(openstackCloud, openstackEnv)
47 }
48
49 stage('Launch new Heat stack') {
50 envParams = [
51 'availability_zone': HEAT_STACK_ZONE,
52 'public_net': HEAT_STACK_PUBLIC_NET
53 ]
54 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
55 }
56
57 stage("Connect to Salt master") {
58 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
59 saltMasterUrl = "http://${saltMasterHost}:8000"
60 saltMaster = salt.createSaltConnection(saltMasterUrl, SALT_MASTER_CREDENTIALS)
61 }
62
63 stage("Install core infra") {
64 salt.installFoundationInfra(saltMaster)
65 salt.validateFoundationInfra(saltMaster)
66 }
67
68 //stage('Delete Heat stack') {
69 // openstack.deleteHeatStack(openstackCloud, HEAT_STACK_NAME, openstackEnv)
70 //}
71
72}