blob: 59a9123c45f014e39dd5aeb0565e8db7ada7cf0c [file] [log] [blame]
Jakub Josef79ecec32017-02-17 14:36:28 +01001package com.mirantis.mk
2
Jakub Josefb77c0812017-03-27 14:11:01 +02003import java.util.stream.Collectors
Jakub Josef79ecec32017-02-17 14:36:28 +01004/**
5 * Salt functions
6 *
7*/
8
9/**
10 * Salt connection and context parameters
11 *
12 * @param url Salt API server URL
13 * @param credentialsID ID of credentials store entry
14 */
15def connection(url, credentialsId = "salt") {
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +010016 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +010017 params = [
18 "url": url,
19 "credentialsId": credentialsId,
20 "authToken": null,
21 "creds": common.getCredentials(credentialsId)
22 ]
23 params["authToken"] = saltLogin(params)
24
25 return params
26}
27
28/**
29 * Login to Salt API, return auth token
30 *
31 * @param master Salt connection object
32 */
33def saltLogin(master) {
Tomáš Kukrál7bec0532017-02-20 15:39:31 +010034 def http = new com.mirantis.mk.Http()
Jakub Josef79ecec32017-02-17 14:36:28 +010035 data = [
36 'username': master.creds.username,
37 'password': master.creds.password.toString(),
38 'eauth': 'pam'
39 ]
Tomáš Kukrál7bec0532017-02-20 15:39:31 +010040 authToken = http.restGet(master, '/login', data)['return'][0]['token']
Jakub Josef79ecec32017-02-17 14:36:28 +010041 return authToken
42}
43
44/**
45 * Run action using Salt API
46 *
47 * @param master Salt connection object
48 * @param client Client type
49 * @param target Target specification, eg. for compound matches by Pillar
50 * data: ['expression': 'I@openssh:server', 'type': 'compound'])
51 * @param function Function to execute (eg. "state.sls")
Jakub Josef2f25cf22017-03-28 13:34:57 +020052 * @param batch Batch param to salt (integer or string with percents)
Jakub Josef79ecec32017-02-17 14:36:28 +010053 * @param args Additional arguments to function
54 * @param kwargs Additional key-value arguments to function
55 */
56@NonCPS
57def runSaltCommand(master, client, target, function, batch = null, args = null, kwargs = null) {
iberezovskiyd4240b52017-02-20 17:18:28 +040058 def http = new com.mirantis.mk.Http()
Jakub Josef79ecec32017-02-17 14:36:28 +010059
60 data = [
61 'tgt': target.expression,
62 'fun': function,
63 'client': client,
64 'expr_form': target.type,
65 ]
66
Jakub Josef2f25cf22017-03-28 13:34:57 +020067 if(batch != null && (batch > 0 || (batch instanceof String && batch.contains("%")))){
68 data['client']= "local_batch"
69 data['batch'] = batch
Jakub Josef79ecec32017-02-17 14:36:28 +010070 }
71
72 if (args) {
73 data['arg'] = args
74 }
75
76 if (kwargs) {
77 data['kwarg'] = kwargs
78 }
79
80 headers = [
81 'X-Auth-Token': "${master.authToken}"
82 ]
83
84 return http.sendHttpPostRequest("${master.url}/", data, headers)
85}
86
Jakub Josef5ade54c2017-03-10 16:14:01 +010087/**
88 * Return pillar for given master and target
89 * @param master Salt connection object
90 * @param target Get pillar target
91 * @param pillar pillar name (optional)
92 * @return output of salt command
93 */
Ales Komarekcec24d42017-03-08 10:25:45 +010094def getPillar(master, target, pillar = null) {
Tomáš Kukráld2589702017-03-10 16:30:46 +010095 if (pillar != null) {
Jakub Josef5ade54c2017-03-10 16:14:01 +010096 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'pillar.get', null, [pillar.replace('.', ':')])
Tomáš Kukráld2589702017-03-10 16:30:46 +010097 } else {
Jakub Josef5ade54c2017-03-10 16:14:01 +010098 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'pillar.data')
Ales Komareka3c7e502017-03-13 11:20:44 +010099 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100100}
101
Jakub Josef5ade54c2017-03-10 16:14:01 +0100102/**
103 * Return grain for given master and target
104 * @param master Salt connection object
105 * @param target Get grain target
106 * @param grain grain name (optional)
107 * @return output of salt command
108 */
Ales Komarekcec24d42017-03-08 10:25:45 +0100109def getGrain(master, target, grain = null) {
110 if(grain != null) {
Jakub Josef5ade54c2017-03-10 16:14:01 +0100111 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'grain.item', null, [grain])
112 } else {
113 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'grain.items')
Ales Komarekcec24d42017-03-08 10:25:45 +0100114 }
Ales Komarekcec24d42017-03-08 10:25:45 +0100115}
116
Jakub Josef5ade54c2017-03-10 16:14:01 +0100117/**
118 * Enforces state on given master and target
119 * @param master Salt connection object
120 * @param target State enforcing target
121 * @param state Salt state
122 * @param output print output (optional, default true)
123 * @param failOnError throw exception on salt state result:false (optional, default true)
Jakub Josef2f25cf22017-03-28 13:34:57 +0200124 * @param batch salt batch parameter integer or string with percents (optional, default null - disable batch)
Jakub Josef5ade54c2017-03-10 16:14:01 +0100125 * @return output of salt command
126 */
Jakub Josef2f25cf22017-03-28 13:34:57 +0200127def enforceState(master, target, state, output = true, failOnError = true, batch = null) {
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100128 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100129 def run_states
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100130
Jakub Josef79ecec32017-02-17 14:36:28 +0100131 if (state instanceof String) {
132 run_states = state
133 } else {
134 run_states = state.join(',')
135 }
136
Tomáš Kukráldfd4b492017-03-02 12:08:50 +0100137 common.infoMsg("Enforcing state ${run_states} on ${target}")
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100138
Jakub Josef2f25cf22017-03-28 13:34:57 +0200139 def out = runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'state.sls', batch, [run_states])
Tomáš Kukráladb4ecd2017-03-02 10:06:36 +0100140
Jakub Josefc952e5a2017-03-23 15:02:12 +0100141 if (output == true) {
142 printSaltStateResult(out)
Jakub Josef79ecec32017-02-17 14:36:28 +0100143 }
Jakub Josef8021c002017-03-27 15:41:28 +0200144 checkResult(out, failOnError, !output)
Jakub Josef79ecec32017-02-17 14:36:28 +0100145 return out
146}
147
Jakub Josef5ade54c2017-03-10 16:14:01 +0100148/**
149 * Run command on salt minion (salt cmd.run wrapper)
150 * @param master Salt connection object
151 * @param target Get pillar target
152 * @param cmd command
Jakub Josef2f25cf22017-03-28 13:34:57 +0200153 * @param batch salt batch parameter integer or string with percents (optional, default null - disable batch)
Jakub Josef5ade54c2017-03-10 16:14:01 +0100154 * @return output of salt command
155 */
Jakub Josef2f25cf22017-03-28 13:34:57 +0200156def cmdRun(master, target, cmd, batch=null) {
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100157 def common = new com.mirantis.mk.Common()
158
Tomáš Kukráldfd4b492017-03-02 12:08:50 +0100159 common.infoMsg("Running command ${cmd} on ${target}")
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100160
Jakub Josef2f25cf22017-03-28 13:34:57 +0200161 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'cmd.run', batch, [cmd])
Jakub Josef79ecec32017-02-17 14:36:28 +0100162}
163
Jakub Josef5ade54c2017-03-10 16:14:01 +0100164/**
165 * Perform complete salt sync between master and target
166 * @param master Salt connection object
167 * @param target Get pillar target
168 * @return output of salt command
169 */
Jakub Josef79ecec32017-02-17 14:36:28 +0100170def syncAll(master, target) {
Filip Pytloun5a7f7fd2017-02-27 18:50:25 +0100171 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'saltutil.sync_all')
Jakub Josef79ecec32017-02-17 14:36:28 +0100172}
173
Jakub Josef5ade54c2017-03-10 16:14:01 +0100174/**
175 * Enforce highstate on given targets
176 * @param master Salt connection object
177 * @param target Highstate enforcing target
178 * @param output print output (optional, default true)
179 * @param failOnError throw exception on salt state result:false (optional, default true)
Jakub Josef2f25cf22017-03-28 13:34:57 +0200180 * @param batch salt batch parameter integer or string with percents (optional, default null - disable batch)
Jakub Josef5ade54c2017-03-10 16:14:01 +0100181 * @return output of salt command
182 */
Jakub Josef2f25cf22017-03-28 13:34:57 +0200183def enforceHighstate(master, target, output = false, failOnError = true, batch = null) {
184 def out = runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'state.highstate', batch)
Jakub Josefc952e5a2017-03-23 15:02:12 +0100185 if (output == true) {
186 printSaltStateResult(out)
Jakub Josef79ecec32017-02-17 14:36:28 +0100187 }
Jakub Josef8021c002017-03-27 15:41:28 +0200188 checkResult(out, failOnError, !output)
Jakub Josef79ecec32017-02-17 14:36:28 +0100189 return out
190}
191
Jakub Josef5ade54c2017-03-10 16:14:01 +0100192/**
Ales Komarek5276ebe2017-03-16 08:46:34 +0100193 * Get running minions IDs according to the target
194 * @param master Salt connection object
195 * @param target Get minions target
196 * @return list of active minions fitin
197 */
198def getMinions(master, target) {
199 def minionsRaw = runSaltCommand(master, 'local', target, 'test.ping')
200 return new ArrayList<String>(minionsRaw['return'][0].keySet())
201}
202
203
204/**
Jakub Josef5ade54c2017-03-10 16:14:01 +0100205 * Generates node key using key.gen_accept call
206 * @param master Salt connection object
207 * @param target Key generating target
208 * @param host Key generating host
209 * @param keysize generated key size (optional, default 4096)
210 * @return output of salt command
211 */
Jakub Josef79ecec32017-02-17 14:36:28 +0100212def generateNodeKey(master, target, host, keysize = 4096) {
Jakub Josef5ade54c2017-03-10 16:14:01 +0100213 return runSaltCommand(master, 'wheel', target, 'key.gen_accept', [host], ['keysize': keysize])
Jakub Josef79ecec32017-02-17 14:36:28 +0100214}
215
Jakub Josef5ade54c2017-03-10 16:14:01 +0100216/**
Jakub Josef2f25cf22017-03-28 13:34:57 +0200217 * Generates node reclass metadata
Jakub Josef5ade54c2017-03-10 16:14:01 +0100218 * @param master Salt connection object
219 * @param target Metadata generating target
220 * @param host Metadata generating host
221 * @param classes Reclass classes
222 * @param parameters Reclass parameters
223 * @return output of salt command
224 */
Jakub Josef79ecec32017-02-17 14:36:28 +0100225def generateNodeMetadata(master, target, host, classes, parameters) {
Jakub Josef5ade54c2017-03-10 16:14:01 +0100226 return runSaltCommand(master, 'local', target, 'reclass.node_create', [host, '_generated'], ['classes': classes, 'parameters': parameters])
Jakub Josef79ecec32017-02-17 14:36:28 +0100227}
228
Jakub Josef5ade54c2017-03-10 16:14:01 +0100229/**
230 * Run salt orchestrate on given targets
231 * @param master Salt connection object
232 * @param target Orchestration target
233 * @param orchestrate Salt orchestrate params
234 * @return output of salt command
235 */
Jakub Josef79ecec32017-02-17 14:36:28 +0100236def orchestrateSystem(master, target, orchestrate) {
237 return runSaltCommand(master, 'runner', target, 'state.orchestrate', [orchestrate])
238}
239
Jakub Josef5ade54c2017-03-10 16:14:01 +0100240/**
241 * Run salt process step
242 * @param master Salt connection object
243 * @param tgt Salt process step target
244 * @param fun Salt process step function
245 * @param arg process step arguments (optional, default [])
Jakub Josef2f25cf22017-03-28 13:34:57 +0200246 * @param batch salt batch parameter integer or string with percents (optional, default null - disable batch)
Jakub Josef5ade54c2017-03-10 16:14:01 +0100247 * @param output print output (optional, default false)
248 * @return output of salt command
249 */
Tomáš Kukrálf5dda642017-03-02 14:22:59 +0100250def runSaltProcessStep(master, tgt, fun, arg = [], batch = null, output = false) {
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100251 def common = new com.mirantis.mk.Common()
Tomáš Kukráladb4ecd2017-03-02 10:06:36 +0100252 def out
253
Tomas Kukrale90bb342017-03-02 21:30:35 +0000254 common.infoMsg("Running step ${fun} on ${tgt}")
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100255
Filip Pytlounf0435c02017-03-02 17:48:54 +0100256 if (batch == true) {
Tomáš Kukráladb4ecd2017-03-02 10:06:36 +0100257 out = runSaltCommand(master, 'local_batch', ['expression': tgt, 'type': 'compound'], fun, String.valueOf(batch), arg)
258 } else {
259 out = runSaltCommand(master, 'local', ['expression': tgt, 'type': 'compound'], fun, batch, arg)
Jakub Josef79ecec32017-02-17 14:36:28 +0100260 }
Tomáš Kukráladb4ecd2017-03-02 10:06:36 +0100261
Tomáš Kukrálf5dda642017-03-02 14:22:59 +0100262 if (output == true) {
Jakub Josef5ade54c2017-03-10 16:14:01 +0100263 printSaltCommandResult(out)
Jakub Josef79ecec32017-02-17 14:36:28 +0100264 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100265}
266
267/**
268 * Check result for errors and throw exception if any found
269 *
270 * @param result Parsed response of Salt API
Jakub Josef8021c002017-03-27 15:41:28 +0200271 * @param failOnError Do you want to throw exception if salt-call fails (optional, default true)
272 * @param printStateOnError Do you want to print failed state on error (optional, default true)
Jakub Josef79ecec32017-02-17 14:36:28 +0100273 */
Jakub Josef8021c002017-03-27 15:41:28 +0200274def checkResult(result, failOnError = true, printStateOnError = true) {
Jakub Josef5ade54c2017-03-10 16:14:01 +0100275 def common = new com.mirantis.mk.Common()
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100276 if(result != null){
277 if(result['return']){
278 for (int i=0;i<result['return'].size();i++) {
279 def entry = result['return'][i]
280 if (!entry) {
281 if (failOnError) {
282 throw new Exception("Salt API returned empty response: ${result}")
283 } else {
284 common.errorMsg("Salt API returned empty response: ${result}")
Jakub Josefece32af2017-03-14 19:20:08 +0100285 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100286 }
287 for (int j=0;j<entry.size();j++) {
288 def nodeKey = entry.keySet()[j]
289 def node=entry[nodeKey]
290 for (int k=0;k<node.size();k++) {
291 def resource;
292 def resKey;
293 if(node instanceof Map){
294 resKey = node.keySet()[k]
295 }else if(node instanceof List){
296 resKey = k
297 }
298 resource = node[resKey]
299 common.debugMsg("checkResult: checking resource: ${resource}")
300 if(resource instanceof String || !resource["result"] || (resource["result"] instanceof String && resource["result"] != "true")){
Jakub Josef43f62bc2017-03-24 14:13:09 +0100301 if(env["ASK_ON_ERROR"] && env["ASK_ON_ERROR"] == "true"){
Jakub Josefb41c8d52017-03-24 13:52:24 +0100302 def prettyResource = common.prettyPrint(resource)
Jakub Josefc952e5a2017-03-23 15:02:12 +0100303 timeout(time:1, unit:'HOURS') {
Jakub Josef77ba3b22017-03-23 15:55:14 +0100304 input message: "False result on ${nodeKey} found, resource ${prettyResource}. \nDo you want to continue?"
Jakub Josefc952e5a2017-03-23 15:02:12 +0100305 }
306 }else{
Jakub Josef8021c002017-03-27 15:41:28 +0200307 def errorMsg
308 if(printStateOnError){
309 errorMsg = "Salt state on node ${nodeKey} failed: ${resource}. State output: ${node}"
310 }else{
311 errorMsg = "Salt state on node ${nodeKey} failed. Look on error upper."
312 }
Jakub Josefc952e5a2017-03-23 15:02:12 +0100313 if (failOnError) {
Jakub Josef8021c002017-03-27 15:41:28 +0200314 throw new Exception(errorMsg)
Jakub Josefc952e5a2017-03-23 15:02:12 +0100315 } else {
Jakub Josef8021c002017-03-27 15:41:28 +0200316 common.errorMsg(errorMsg)
Jakub Josefc952e5a2017-03-23 15:02:12 +0100317 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100318 }
Jakub Josef52f69f72017-03-14 15:18:08 +0100319 }
Jakub Josef5ade54c2017-03-10 16:14:01 +0100320 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100321 }
322 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100323 }else{
324 common.errorMsg("Salt result hasn't return attribute! Result: ${result}")
Jakub Josef79ecec32017-02-17 14:36:28 +0100325 }
Jakub Josef52f69f72017-03-14 15:18:08 +0100326 }else{
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100327 common.errorMsg("Cannot check salt result, given result is null")
Jakub Josef79ecec32017-02-17 14:36:28 +0100328 }
329}
330
331/**
332 * Print Salt state run results in human-friendly form
333 *
334 * @param result Parsed response of Salt API
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100335 * @param onlyChanges If true (default), print only changed resources
Jakub Josef79ecec32017-02-17 14:36:28 +0100336 */
337def printSaltStateResult(result, onlyChanges = true) {
Tomáš Kukrál6eb45f82017-03-08 18:26:16 +0100338 def common = new com.mirantis.mk.Common()
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100339 if(result != null){
340 if(result['return']){
341 for (int i=0; i<result['return'].size(); i++) {
342 def entry = result['return'][i]
343 for (int j=0; j<entry.size(); j++) {
344 common.debugMsg("printSaltStateResult: printing salt command entry: ${entry}")
345 def nodeKey = entry.keySet()[j]
346 def node=entry[nodeKey]
347 common.infoMsg("Node ${nodeKey} changes:")
348 if(node instanceof Map || node instanceof List){
Jakub Josefb77c0812017-03-27 14:11:01 +0200349 def outputResources = []
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100350 for (int k=0;k<node.size();k++) {
351 def resource;
352 def resKey;
353 if(node instanceof Map){
354 resKey = node.keySet()[k]
355 }else if(node instanceof List){
356 resKey = k
357 }
358 resource = node[resKey]
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100359 if(resource instanceof Map && resource.keySet().contains("result")){
Jakub Joseff1fb4472017-03-16 14:11:54 +0100360 //clean unnesaccary fields
361 if(resource.keySet().contains("__run_num__")){
362 resource.remove("__run_num__")
363 }
364 if(resource.keySet().contains("__id__")){
365 resource.remove("__id__")
366 }
367 if(resource.keySet().contains("pchanges")){
368 resource.remove("pchanges")
369 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100370 if(!resource["result"] || (resource["result"] instanceof String && resource["result"] != "true")){
Jakub Josef0e7bd632017-03-16 16:25:05 +0100371 if(resource["result"] != null){
Jakub Josef8021c002017-03-27 15:41:28 +0200372 outputResources.add(String.format("Resource: %s\n\u001B[31m%s\u001B[0m", resKey, common.prettyPrint(resource)))
Jakub Josef0e7bd632017-03-16 16:25:05 +0100373 }else{
Jakub Josef8021c002017-03-27 15:41:28 +0200374 outputResources.add(String.format("Resource: %s\n\u001B[33m%s\u001B[0m", resKey, common.prettyPrint(resource)))
Jakub Josef0e7bd632017-03-16 16:25:05 +0100375 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100376 }else{
377 if(!onlyChanges || resource.changes.size() > 0){
Jakub Josef8021c002017-03-27 15:41:28 +0200378 outputResources.add(String.format("Resource: %s\n\u001B[32m%s\u001B[0m", resKey, common.prettyPrint(resource)))
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100379 }
380 }
381 }else{
Jakub Josef8021c002017-03-27 15:41:28 +0200382 outputResources.add(String.format("Resource: %s\n\u001B[36m%s\u001B[0m", resKey, common.prettyPrint(resource)))
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100383 }
384 }
Jakub Josefb77c0812017-03-27 14:11:01 +0200385 wrap([$class: 'AnsiColorBuildWrapper']) {
386 print outputResources.stream().collect(Collectors.joining("\n"))
387 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100388 }else{
Jakub Josefb41c8d52017-03-24 13:52:24 +0100389 common.infoMsg(common.prettyPrint(node))
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100390 }
391 }
Jakub Josef52f69f72017-03-14 15:18:08 +0100392 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100393 }else{
394 common.errorMsg("Salt result hasn't return attribute! Result: ${result}")
Jakub Josef79ecec32017-02-17 14:36:28 +0100395 }
Jakub Josef52f69f72017-03-14 15:18:08 +0100396 }else{
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100397 common.errorMsg("Cannot print salt state result, given result is null")
Jakub Josef79ecec32017-02-17 14:36:28 +0100398 }
399}
400
401/**
Jakub Josef7852fe12017-03-15 16:02:41 +0100402 * Print salt command run results in human-friendly form
Jakub Josef79ecec32017-02-17 14:36:28 +0100403 *
404 * @param result Parsed response of Salt API
Jakub Josef79ecec32017-02-17 14:36:28 +0100405 */
Filip Pytlound2f1bbe2017-02-27 19:03:51 +0100406def printSaltCommandResult(result) {
Jakub Josef871bf152017-03-14 20:13:41 +0100407 def common = new com.mirantis.mk.Common()
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100408 if(result != null){
409 if(result['return']){
410 for (int i=0; i<result['return'].size(); i++) {
411 def entry = result['return'][i]
412 for (int j=0; j<entry.size(); j++) {
413 common.debugMsg("printSaltCommandResult: printing salt command entry: ${entry}")
414 def nodeKey = entry.keySet()[j]
415 def node=entry[nodeKey]
Jakub Josefb41c8d52017-03-24 13:52:24 +0100416 common.infoMsg(String.format("Node %s changes:\n%s",nodeKey, common.prettyPrint(node)))
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100417 }
Jakub Josef8a715bf2017-03-14 21:39:01 +0100418 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100419 }else{
420 common.errorMsg("Salt result hasn't return attribute! Result: ${result}")
Jakub Josef79ecec32017-02-17 14:36:28 +0100421 }
Jakub Josef8a715bf2017-03-14 21:39:01 +0100422 }else{
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100423 common.errorMsg("Cannot print salt command result, given result is null")
Jakub Josef52f69f72017-03-14 15:18:08 +0100424 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100425}