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 |
| 18 | |
| 19 | node("python") { |
| 20 | try { |
| 21 | |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 22 | stage('Setup virtualenv for Pepper') { |
Dmitrii Kabanov | f31c896 | 2017-10-12 21:00:30 -0700 | [diff] [blame] | 23 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | stage('Update Reclass model') { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 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') |
Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 29 | salt.checkResult(result) |
| 30 | } |
| 31 | |
| 32 | } catch (Throwable e) { |
| 33 | currentBuild.result = 'FAILURE' |
| 34 | throw e |
| 35 | } |
| 36 | } |