blob: 75349a4c0956edf0d8a6c81e71dcc79f3c76ebaa [file] [log] [blame]
Jakub Josef79ecec32017-02-17 14:36:28 +01001package com.mirantis.mk
2
Jakub Josefbceaa322017-06-13 18:28:27 +02003import com.cloudbees.groovy.cps.NonCPS
Jakub Josefb77c0812017-03-27 14:11:01 +02004import java.util.stream.Collectors
Jakub Josef79ecec32017-02-17 14:36:28 +01005/**
6 * Salt functions
7 *
8*/
9
10/**
11 * Salt connection and context parameters
12 *
13 * @param url Salt API server URL
14 * @param credentialsID ID of credentials store entry
15 */
16def connection(url, credentialsId = "salt") {
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +010017 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +010018 params = [
19 "url": url,
20 "credentialsId": credentialsId,
21 "authToken": null,
22 "creds": common.getCredentials(credentialsId)
23 ]
24 params["authToken"] = saltLogin(params)
25
26 return params
27}
28
29/**
30 * Login to Salt API, return auth token
31 *
32 * @param master Salt connection object
33 */
34def saltLogin(master) {
Tomáš Kukrál7bec0532017-02-20 15:39:31 +010035 def http = new com.mirantis.mk.Http()
Jakub Josef79ecec32017-02-17 14:36:28 +010036 data = [
37 'username': master.creds.username,
38 'password': master.creds.password.toString(),
39 'eauth': 'pam'
40 ]
Tomáš Kukrál7bec0532017-02-20 15:39:31 +010041 authToken = http.restGet(master, '/login', data)['return'][0]['token']
Jakub Josef79ecec32017-02-17 14:36:28 +010042 return authToken
43}
44
45/**
46 * Run action using Salt API
47 *
48 * @param master Salt connection object
49 * @param client Client type
50 * @param target Target specification, eg. for compound matches by Pillar
51 * data: ['expression': 'I@openssh:server', 'type': 'compound'])
52 * @param function Function to execute (eg. "state.sls")
Jakub Josef2f25cf22017-03-28 13:34:57 +020053 * @param batch Batch param to salt (integer or string with percents)
Jakub Josef79ecec32017-02-17 14:36:28 +010054 * @param args Additional arguments to function
55 * @param kwargs Additional key-value arguments to function
56 */
57@NonCPS
58def runSaltCommand(master, client, target, function, batch = null, args = null, kwargs = null) {
iberezovskiyd4240b52017-02-20 17:18:28 +040059 def http = new com.mirantis.mk.Http()
Jakub Josef79ecec32017-02-17 14:36:28 +010060
61 data = [
62 'tgt': target.expression,
63 'fun': function,
64 'client': client,
65 'expr_form': target.type,
66 ]
67
Jakub Josef5f838212017-04-06 12:43:58 +020068 if(batch != null && ( (batch instanceof Integer && batch > 0) || (batch instanceof String && batch.contains("%")))){
Jakub Josef2f25cf22017-03-28 13:34:57 +020069 data['client']= "local_batch"
70 data['batch'] = batch
Jakub Josef79ecec32017-02-17 14:36:28 +010071 }
72
73 if (args) {
74 data['arg'] = args
75 }
76
77 if (kwargs) {
78 data['kwarg'] = kwargs
79 }
80
81 headers = [
82 'X-Auth-Token': "${master.authToken}"
83 ]
84
85 return http.sendHttpPostRequest("${master.url}/", data, headers)
86}
87
Jakub Josef5ade54c2017-03-10 16:14:01 +010088/**
89 * Return pillar for given master and target
90 * @param master Salt connection object
91 * @param target Get pillar target
92 * @param pillar pillar name (optional)
93 * @return output of salt command
94 */
Ales Komarekcec24d42017-03-08 10:25:45 +010095def getPillar(master, target, pillar = null) {
Tomáš Kukráld2589702017-03-10 16:30:46 +010096 if (pillar != null) {
Jakub Josef5ade54c2017-03-10 16:14:01 +010097 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'pillar.get', null, [pillar.replace('.', ':')])
Tomáš Kukráld2589702017-03-10 16:30:46 +010098 } else {
Jakub Josef5ade54c2017-03-10 16:14:01 +010099 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'pillar.data')
Ales Komareka3c7e502017-03-13 11:20:44 +0100100 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100101}
102
Jakub Josef5ade54c2017-03-10 16:14:01 +0100103/**
104 * Return grain for given master and target
105 * @param master Salt connection object
106 * @param target Get grain target
107 * @param grain grain name (optional)
108 * @return output of salt command
109 */
Ales Komarekcec24d42017-03-08 10:25:45 +0100110def getGrain(master, target, grain = null) {
111 if(grain != null) {
Jiri Broulik852dfd52017-05-16 13:38:55 +0200112 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'grains.item', null, [grain])
Jakub Josef5ade54c2017-03-10 16:14:01 +0100113 } else {
Jiri Broulik852dfd52017-05-16 13:38:55 +0200114 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'grains.items')
Ales Komarekcec24d42017-03-08 10:25:45 +0100115 }
Ales Komarekcec24d42017-03-08 10:25:45 +0100116}
117
Jakub Josef5ade54c2017-03-10 16:14:01 +0100118/**
119 * Enforces state on given master and target
120 * @param master Salt connection object
121 * @param target State enforcing target
122 * @param state Salt state
123 * @param output print output (optional, default true)
124 * @param failOnError throw exception on salt state result:false (optional, default true)
Jakub Josef2f25cf22017-03-28 13:34:57 +0200125 * @param batch salt batch parameter integer or string with percents (optional, default null - disable batch)
Jakub Josef5ade54c2017-03-10 16:14:01 +0100126 * @return output of salt command
127 */
Jakub Josef2f25cf22017-03-28 13:34:57 +0200128def enforceState(master, target, state, output = true, failOnError = true, batch = null) {
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100129 def common = new com.mirantis.mk.Common()
Jakub Josef79ecec32017-02-17 14:36:28 +0100130 def run_states
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100131
Jakub Josef79ecec32017-02-17 14:36:28 +0100132 if (state instanceof String) {
133 run_states = state
134 } else {
135 run_states = state.join(',')
136 }
137
Tomáš Kukráldfd4b492017-03-02 12:08:50 +0100138 common.infoMsg("Enforcing state ${run_states} on ${target}")
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100139
Jakub Josef2f25cf22017-03-28 13:34:57 +0200140 def out = runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'state.sls', batch, [run_states])
Tomáš Kukráladb4ecd2017-03-02 10:06:36 +0100141
Jakub Josef374beb72017-04-27 15:45:09 +0200142 checkResult(out, failOnError, output)
Jakub Josef79ecec32017-02-17 14:36:28 +0100143 return out
144}
145
Jakub Josef5ade54c2017-03-10 16:14:01 +0100146/**
147 * Run command on salt minion (salt cmd.run wrapper)
148 * @param master Salt connection object
149 * @param target Get pillar target
150 * @param cmd command
Jakub Josef053df392017-05-03 15:51:05 +0200151 * @param checkResponse test command success execution (default true)
Jakub Josef2f25cf22017-03-28 13:34:57 +0200152 * @param batch salt batch parameter integer or string with percents (optional, default null - disable batch)
Jakub Josef5ade54c2017-03-10 16:14:01 +0100153 * @return output of salt command
154 */
Jiri Broulik16e9ce72017-05-17 13:28:31 +0200155def cmdRun(master, target, cmd, checkResponse = true, batch=null, output = true) {
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100156 def common = new com.mirantis.mk.Common()
Jakub Josef053df392017-05-03 15:51:05 +0200157 def originalCmd = cmd
Tomáš Kukráldfd4b492017-03-02 12:08:50 +0100158 common.infoMsg("Running command ${cmd} on ${target}")
Jakub Josef053df392017-05-03 15:51:05 +0200159 if (checkResponse) {
160 cmd = cmd + " && echo Salt command execution success"
161 }
Jiri Broulik16e9ce72017-05-17 13:28:31 +0200162 def out = runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'cmd.run', batch, [cmd])
Jakub Josef053df392017-05-03 15:51:05 +0200163 if (checkResponse) {
164 // iterate over all affected nodes and check success return code
Jiri Broulik16e9ce72017-05-17 13:28:31 +0200165 if (out["return"]){
166 for(int i=0;i<out["return"].size();i++){
167 def node = out["return"][i];
Jakub Josef053df392017-05-03 15:51:05 +0200168 for(int j=0;j<node.size();j++){
169 def nodeKey = node.keySet()[j]
170 if (!node[nodeKey].contains("Salt command execution success")) {
171 throw new Exception("Execution of cmd ${originalCmd} failed. Server returns: ${node[nodeKey]}")
172 }
173 }
174 }
175 }else{
176 throw new Exception("Salt Api response doesn't have return param!")
177 }
178 }
Jiri Broulik16e9ce72017-05-17 13:28:31 +0200179 if (output == true) {
180 printSaltCommandResult(out)
181 }
182 return out
Jakub Josef79ecec32017-02-17 14:36:28 +0100183}
184
Jakub Josef5ade54c2017-03-10 16:14:01 +0100185/**
186 * Perform complete salt sync between master and target
187 * @param master Salt connection object
188 * @param target Get pillar target
189 * @return output of salt command
190 */
Jakub Josef79ecec32017-02-17 14:36:28 +0100191def syncAll(master, target) {
Filip Pytloun5a7f7fd2017-02-27 18:50:25 +0100192 return runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'saltutil.sync_all')
Jakub Josef79ecec32017-02-17 14:36:28 +0100193}
194
Jakub Josef5ade54c2017-03-10 16:14:01 +0100195/**
196 * Enforce highstate on given targets
197 * @param master Salt connection object
198 * @param target Highstate enforcing target
199 * @param output print output (optional, default true)
200 * @param failOnError throw exception on salt state result:false (optional, default true)
Jakub Josef2f25cf22017-03-28 13:34:57 +0200201 * @param batch salt batch parameter integer or string with percents (optional, default null - disable batch)
Jakub Josef5ade54c2017-03-10 16:14:01 +0100202 * @return output of salt command
203 */
Jakub Josef2f25cf22017-03-28 13:34:57 +0200204def enforceHighstate(master, target, output = false, failOnError = true, batch = null) {
205 def out = runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'state.highstate', batch)
Jakub Josef374beb72017-04-27 15:45:09 +0200206 checkResult(out, failOnError, output)
Jakub Josef79ecec32017-02-17 14:36:28 +0100207 return out
208}
209
Jakub Josef5ade54c2017-03-10 16:14:01 +0100210/**
Ales Komarek5276ebe2017-03-16 08:46:34 +0100211 * Get running minions IDs according to the target
212 * @param master Salt connection object
213 * @param target Get minions target
214 * @return list of active minions fitin
215 */
216def getMinions(master, target) {
217 def minionsRaw = runSaltCommand(master, 'local', target, 'test.ping')
218 return new ArrayList<String>(minionsRaw['return'][0].keySet())
219}
220
221
222/**
Jakub Josef5ade54c2017-03-10 16:14:01 +0100223 * Generates node key using key.gen_accept call
224 * @param master Salt connection object
225 * @param target Key generating target
226 * @param host Key generating host
227 * @param keysize generated key size (optional, default 4096)
228 * @return output of salt command
229 */
Jakub Josef79ecec32017-02-17 14:36:28 +0100230def generateNodeKey(master, target, host, keysize = 4096) {
Jakub Josef5ade54c2017-03-10 16:14:01 +0100231 return runSaltCommand(master, 'wheel', target, 'key.gen_accept', [host], ['keysize': keysize])
Jakub Josef79ecec32017-02-17 14:36:28 +0100232}
233
Jakub Josef5ade54c2017-03-10 16:14:01 +0100234/**
Jakub Josef2f25cf22017-03-28 13:34:57 +0200235 * Generates node reclass metadata
Jakub Josef5ade54c2017-03-10 16:14:01 +0100236 * @param master Salt connection object
237 * @param target Metadata generating target
238 * @param host Metadata generating host
239 * @param classes Reclass classes
240 * @param parameters Reclass parameters
241 * @return output of salt command
242 */
Jakub Josef79ecec32017-02-17 14:36:28 +0100243def generateNodeMetadata(master, target, host, classes, parameters) {
Jakub Josef5ade54c2017-03-10 16:14:01 +0100244 return runSaltCommand(master, 'local', target, 'reclass.node_create', [host, '_generated'], ['classes': classes, 'parameters': parameters])
Jakub Josef79ecec32017-02-17 14:36:28 +0100245}
246
Jakub Josef5ade54c2017-03-10 16:14:01 +0100247/**
248 * Run salt orchestrate on given targets
249 * @param master Salt connection object
250 * @param target Orchestration target
251 * @param orchestrate Salt orchestrate params
252 * @return output of salt command
253 */
Jakub Josef79ecec32017-02-17 14:36:28 +0100254def orchestrateSystem(master, target, orchestrate) {
255 return runSaltCommand(master, 'runner', target, 'state.orchestrate', [orchestrate])
256}
257
Jakub Josef5ade54c2017-03-10 16:14:01 +0100258/**
259 * Run salt process step
260 * @param master Salt connection object
261 * @param tgt Salt process step target
262 * @param fun Salt process step function
263 * @param arg process step arguments (optional, default [])
Jakub Josef2f25cf22017-03-28 13:34:57 +0200264 * @param batch salt batch parameter integer or string with percents (optional, default null - disable batch)
Jakub Josef5ade54c2017-03-10 16:14:01 +0100265 * @param output print output (optional, default false)
266 * @return output of salt command
267 */
Tomáš Kukrálf5dda642017-03-02 14:22:59 +0100268def runSaltProcessStep(master, tgt, fun, arg = [], batch = null, output = false) {
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100269 def common = new com.mirantis.mk.Common()
Tomáš Kukráladb4ecd2017-03-02 10:06:36 +0100270 def out
271
Tomas Kukrale90bb342017-03-02 21:30:35 +0000272 common.infoMsg("Running step ${fun} on ${tgt}")
Tomáš Kukrál6c04bd02017-03-01 22:18:52 +0100273
Filip Pytlounf0435c02017-03-02 17:48:54 +0100274 if (batch == true) {
Tomáš Kukráladb4ecd2017-03-02 10:06:36 +0100275 out = runSaltCommand(master, 'local_batch', ['expression': tgt, 'type': 'compound'], fun, String.valueOf(batch), arg)
276 } else {
277 out = runSaltCommand(master, 'local', ['expression': tgt, 'type': 'compound'], fun, batch, arg)
Jakub Josef79ecec32017-02-17 14:36:28 +0100278 }
Tomáš Kukráladb4ecd2017-03-02 10:06:36 +0100279
Tomáš Kukrálf5dda642017-03-02 14:22:59 +0100280 if (output == true) {
Jakub Josef5ade54c2017-03-10 16:14:01 +0100281 printSaltCommandResult(out)
Jakub Josef79ecec32017-02-17 14:36:28 +0100282 }
Jiri Broulikae19c262017-05-16 19:06:52 +0200283 return out
Jakub Josef79ecec32017-02-17 14:36:28 +0100284}
285
286/**
287 * Check result for errors and throw exception if any found
288 *
289 * @param result Parsed response of Salt API
Jakub Josef8021c002017-03-27 15:41:28 +0200290 * @param failOnError Do you want to throw exception if salt-call fails (optional, default true)
Jakub Josefa87941c2017-04-20 17:14:58 +0200291 * @param printResults Do you want to print salt results (optional, default true)
Jakub Josefa87941c2017-04-20 17:14:58 +0200292 * @param printOnlyChanges If true (default), print only changed resources
Jakub Josef79ecec32017-02-17 14:36:28 +0100293 */
Jakub Josef374beb72017-04-27 15:45:09 +0200294def checkResult(result, failOnError = true, printResults = true, printOnlyChanges = true) {
Jakub Josef5ade54c2017-03-10 16:14:01 +0100295 def common = new com.mirantis.mk.Common()
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100296 if(result != null){
297 if(result['return']){
298 for (int i=0;i<result['return'].size();i++) {
299 def entry = result['return'][i]
300 if (!entry) {
301 if (failOnError) {
302 throw new Exception("Salt API returned empty response: ${result}")
303 } else {
304 common.errorMsg("Salt API returned empty response: ${result}")
Jakub Josefece32af2017-03-14 19:20:08 +0100305 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100306 }
307 for (int j=0;j<entry.size();j++) {
308 def nodeKey = entry.keySet()[j]
309 def node=entry[nodeKey]
Jakub Josefa87941c2017-04-20 17:14:58 +0200310 def outputResources = []
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100311 common.infoMsg("Node ${nodeKey} changes:")
312 if(node instanceof Map || node instanceof List){
313 for (int k=0;k<node.size();k++) {
314 def resource;
315 def resKey;
316 if(node instanceof Map){
317 resKey = node.keySet()[k]
318 }else if(node instanceof List){
319 resKey = k
320 }
321 resource = node[resKey]
Jakub Josefc4c40202017-04-28 12:04:24 +0200322 // print
Jakub Josefa87941c2017-04-20 17:14:58 +0200323 if(printResults){
324 if(resource instanceof Map && resource.keySet().contains("result")){
325 //clean unnesaccary fields
326 if(resource.keySet().contains("__run_num__")){
327 resource.remove("__run_num__")
328 }
329 if(resource.keySet().contains("__id__")){
330 resource.remove("__id__")
331 }
332 if(resource.keySet().contains("pchanges")){
333 resource.remove("pchanges")
334 }
335 if(!resource["result"] || (resource["result"] instanceof String && resource["result"] != "true")){
336 if(resource["result"] != null){
Jakub Josefbceaa322017-06-13 18:28:27 +0200337 outputResources.add(String.format("Resource: %s\n\u001B[31m%s\u001B[0m", resKey, common.prettify(resource)))
Jakub Josefa87941c2017-04-20 17:14:58 +0200338 }else{
Jakub Josefbceaa322017-06-13 18:28:27 +0200339 outputResources.add(String.format("Resource: %s\n\u001B[33m%s\u001B[0m", resKey, common.prettify(resource)))
Jakub Josefa87941c2017-04-20 17:14:58 +0200340 }
341 }else{
342 if(!printOnlyChanges || resource.changes.size() > 0){
Jakub Josefbceaa322017-06-13 18:28:27 +0200343 outputResources.add(String.format("Resource: %s\n\u001B[32m%s\u001B[0m", resKey, common.prettify(resource)))
Jakub Josefa87941c2017-04-20 17:14:58 +0200344 }
345 }
346 }else{
Jakub Josefbceaa322017-06-13 18:28:27 +0200347 outputResources.add(String.format("Resource: %s\n\u001B[36m%s\u001B[0m", resKey, common.prettify(resource)))
Jakub Josefa87941c2017-04-20 17:14:58 +0200348 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100349 }
Jakub Josefc4c40202017-04-28 12:04:24 +0200350 common.debugMsg("checkResult: checking resource: ${resource}")
351 if(resource instanceof String || (resource["result"] != null && !resource["result"]) || (resource["result"] instanceof String && resource["result"] == "false")){
Jakub Josefbceaa322017-06-13 18:28:27 +0200352 def prettyResource = common.prettify(resource)
Jakub Josefc4c40202017-04-28 12:04:24 +0200353 if(env["ASK_ON_ERROR"] && env["ASK_ON_ERROR"] == "true"){
354 timeout(time:1, unit:'HOURS') {
355 input message: "False result on ${nodeKey} found, resource ${prettyResource}. \nDo you want to continue?"
356 }
357 }else{
Jakub Josefd97d7db2017-05-11 19:11:53 +0200358 common.errorMsg(String.format("Resource: %s\n%s", resKey, prettyResource))
Jakub Josefd9001df2017-05-11 16:45:28 +0200359 def errorMsg = "Salt state on node ${nodeKey} failed: ${prettyResource}."
Jakub Josefc4c40202017-04-28 12:04:24 +0200360 if (failOnError) {
361 throw new Exception(errorMsg)
362 } else {
363 common.errorMsg(errorMsg)
364 }
365 }
366 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100367 }
Jakub Josefa87941c2017-04-20 17:14:58 +0200368 }else if(node!=null && node!=""){
Jakub Josefbceaa322017-06-13 18:28:27 +0200369 outputResources.add(String.format("Resource: %s\n\u001B[36m%s\u001B[0m", resKey, common.prettify(node)))
Jakub Josefa87941c2017-04-20 17:14:58 +0200370 }
371 if(printResults && !outputResources.isEmpty()){
Jakub Josefb77c0812017-03-27 14:11:01 +0200372 wrap([$class: 'AnsiColorBuildWrapper']) {
373 print outputResources.stream().collect(Collectors.joining("\n"))
374 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100375 }
376 }
Jakub Josef52f69f72017-03-14 15:18:08 +0100377 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100378 }else{
379 common.errorMsg("Salt result hasn't return attribute! Result: ${result}")
Jakub Josef79ecec32017-02-17 14:36:28 +0100380 }
Jakub Josef52f69f72017-03-14 15:18:08 +0100381 }else{
Jakub Josefa87941c2017-04-20 17:14:58 +0200382 common.errorMsg("Cannot check salt result, given result is null")
Jakub Josef79ecec32017-02-17 14:36:28 +0100383 }
384}
385
386/**
Jakub Josef7852fe12017-03-15 16:02:41 +0100387 * Print salt command run results in human-friendly form
Jakub Josef79ecec32017-02-17 14:36:28 +0100388 *
389 * @param result Parsed response of Salt API
Jakub Josef79ecec32017-02-17 14:36:28 +0100390 */
Filip Pytlound2f1bbe2017-02-27 19:03:51 +0100391def printSaltCommandResult(result) {
Jakub Josef871bf152017-03-14 20:13:41 +0100392 def common = new com.mirantis.mk.Common()
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100393 if(result != null){
394 if(result['return']){
395 for (int i=0; i<result['return'].size(); i++) {
396 def entry = result['return'][i]
397 for (int j=0; j<entry.size(); j++) {
398 common.debugMsg("printSaltCommandResult: printing salt command entry: ${entry}")
399 def nodeKey = entry.keySet()[j]
400 def node=entry[nodeKey]
Jakub Josefbceaa322017-06-13 18:28:27 +0200401 common.infoMsg(String.format("Node %s changes:\n%s",nodeKey, common.prettify(node)))
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100402 }
Jakub Josef8a715bf2017-03-14 21:39:01 +0100403 }
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100404 }else{
405 common.errorMsg("Salt result hasn't return attribute! Result: ${result}")
Jakub Josef79ecec32017-02-17 14:36:28 +0100406 }
Jakub Josef8a715bf2017-03-14 21:39:01 +0100407 }else{
Jakub Josefd9afd0e2017-03-15 19:19:23 +0100408 common.errorMsg("Cannot print salt command result, given result is null")
Jakub Josef52f69f72017-03-14 15:18:08 +0100409 }
Jakub Josef79ecec32017-02-17 14:36:28 +0100410}
Tomáš Kukrálb12eedd2017-04-21 10:45:13 +0200411
412
413/**
414 * Return content of file target
415 *
416 * @param master Salt master object
417 * @param target Compound target (should target only one host)
418 * @param file File path to read (/etc/hosts for example)
419 */
420
421def getFileContent(master, target, file) {
422 result = cmdRun(master, target, "cat ${file}")
423 return result['return'][0].values()[0]
424}