| Jiri Broulik | 2c00f4c | 2017-10-26 13:23:11 +0200 | [diff] [blame] | 1 | /** | 
 | 2 |  * | 
 | 3 |  * Add Ceph node to existing cluster | 
 | 4 |  * | 
 | 5 |  * Requred parameters: | 
 | 6 |  *  SALT_MASTER_URL             URL of Salt master | 
 | 7 |  *  SALT_MASTER_CREDENTIALS     Credentials to the Salt API | 
 | 8 |  *  HOST                        Host (minion id) to be added | 
 | 9 |  *  HOST_TYPE                   Type of Ceph node to be added. Valid values are mon/osd/rgw | 
 | 10 |  * | 
 | 11 |  */ | 
 | 12 |  | 
 | 13 | common = new com.mirantis.mk.Common() | 
 | 14 | salt = new com.mirantis.mk.Salt() | 
 | 15 | orchestrate = new com.mirantis.mk.Orchestrate() | 
 | 16 | def python = new com.mirantis.mk.Python() | 
 | 17 |  | 
 | 18 | def pepperEnv = "pepperEnv" | 
 | 19 |  | 
 | 20 | node("python") { | 
 | 21 |  | 
 | 22 |     // create connection to salt master | 
 | 23 |     python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) | 
 | 24 |  | 
 | 25 |     matches = ["osd", "mon", "rgw"] | 
 | 26 |     def found = false | 
 | 27 |     for (s in matches) { | 
 | 28 |         if (HOST_TYPE.toLowerCase() == s) { | 
 | 29 |             found = true | 
 | 30 |         } | 
 | 31 |     } | 
 | 32 |  | 
 | 33 |     if (!found) { | 
| Jiri Broulik | 80af381 | 2017-11-29 10:02:43 +0100 | [diff] [blame] | 34 |         common.errorMsg("No such HOST_TYPE was found. Please insert one of the following types: mon/osd/rgw") | 
 | 35 |         throw new InterruptedException() | 
| Jiri Broulik | 2c00f4c | 2017-10-26 13:23:11 +0200 | [diff] [blame] | 36 |     } | 
 | 37 |  | 
 | 38 |     if (HOST_TYPE.toLowerCase() != 'osd') { | 
 | 39 |  | 
| Jiri Broulik | dc87d72 | 2017-11-03 15:43:22 +0100 | [diff] [blame] | 40 |         // launch VMs | 
| Jiri Broulik | 2c00f4c | 2017-10-26 13:23:11 +0200 | [diff] [blame] | 41 |         stage('Launch VMs') { | 
 | 42 |             salt.enforceState(pepperEnv, 'I@salt:control', 'salt.control', true) | 
 | 43 |  | 
 | 44 |             // wait till the HOST appears in salt-key on salt-master | 
 | 45 |             salt.minionPresent(pepperEnv, 'I@salt:master', HOST) | 
 | 46 |         } | 
 | 47 |     } | 
 | 48 |  | 
 | 49 |     // run basic states | 
 | 50 |     stage('Install infra') { | 
 | 51 |         orchestrate.installFoundationInfraOnTarget(pepperEnv, HOST) | 
 | 52 |     } | 
 | 53 |  | 
 | 54 |     if (HOST_TYPE.toLowerCase() == 'osd') { | 
 | 55 |  | 
 | 56 |         // Install Ceph osd | 
 | 57 |         stage('Install Ceph OSD') { | 
 | 58 |             orchestrate.installCephOsd(pepperEnv, HOST) | 
 | 59 |         } | 
 | 60 |     } else if (HOST_TYPE.toLowerCase() == 'mon') { | 
 | 61 |         // Install Ceph mon | 
 | 62 |         stage('Install Ceph MON') { | 
 | 63 |             salt.enforceState(pepperEnv, 'I@ceph:common', 'ceph.common', true) | 
 | 64 |             // install Ceph Mons | 
 | 65 |             salt.enforceState(pepperEnv, 'I@ceph:mon', 'ceph.mon', true) | 
 | 66 |             if (salt.testTarget(pepperEnv, 'I@ceph:mgr')) { | 
 | 67 |                 salt.enforceState(pepperEnv, 'I@ceph:mgr', 'ceph.mgr', true) | 
 | 68 |             } | 
 | 69 |         } | 
 | 70 |     } else if (HOST_TYPE.toLowerCase() == 'rgw') { | 
 | 71 |         // Install Ceph rgw | 
 | 72 |         stage('Install Ceph RGW') { | 
 | 73 |             salt.enforceState(pepperEnv, 'I@ceph:radosgw', ['keepalived', 'haproxy', 'ceph.radosgw'], true) | 
 | 74 |         } | 
 | 75 |     } | 
 | 76 | } |