Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Update reclass model on salt master |
| 3 | * |
| 4 | * Expected parameters: |
| 5 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API. |
| 6 | * SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000]. |
| 7 | * TARGET_SERVERS Server to update |
| 8 | * |
| 9 | **/ |
| 10 | |
| 11 | def common = new com.mirantis.mk.Common() |
| 12 | def salt = new com.mirantis.mk.Salt() |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 13 | def python = new com.mirantis.mk.Python() |
Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 14 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 15 | def pepperEnv = "pepperEnv" |
Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 16 | def target = ['expression': TARGET_SERVERS, 'type': 'compound'] |
| 17 | def result |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 18 | timeout(time: 12, unit: 'HOURS') { |
| 19 | node("python") { |
| 20 | try { |
Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 21 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 22 | stage('Setup virtualenv for Pepper') { |
| 23 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 24 | } |
Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 25 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 26 | stage('Update Reclass model') { |
| 27 | result = salt.runSaltCommand(pepperEnv, 'local', target, 'state.apply', null, 'reclass.storage') |
| 28 | result = salt.runSaltCommand(pepperEnv, 'local', target, 'state.apply', null, 'reclass.storage.node') |
| 29 | salt.checkResult(result) |
| 30 | } |
| 31 | |
| 32 | } catch (Throwable e) { |
| 33 | currentBuild.result = 'FAILURE' |
| 34 | throw e |
Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 35 | } |
Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 36 | } |
| 37 | } |