Cloudify REST script 01 #! /Bin/bash02 03 bootOutput = "bl. out "04rm-f $ bootOutput // Delete b1.out file 05. /cloudify. sh "bootstrap-cloud ec2"> $ bootOutput 2> & 1 // run. /cloudify. sh bootstrap-cloud ec2 redirects the output to b1.out and standard input to standard output. 06 searchString = "Rest service is" 07 selectedText = 'grep "$ {searchString}" $ bootoutput' // find the line "Rest service is" in b1.out and assign it to selectedText08rawValue = 'echo $ {selectedText} | awk '{print $6} ''// divide the sixth field in selectedText by space or tab) assigned to rawValue09restURL = "$ {rawValue % ?} "// Linux string operation, which is executed after the last character of rawValue is deleted, that is, extract restURL10echo "1st restURL is $ {restURL}" >>$ bootOutput 2> & 1 // print and redirect to b1.out and standard output 11 12 # If there are two management machines (and in production, we recommend it ...), 13 # you'll have two Rest URLs14rawValue = 'echo $ {selectedText} | awk' {print $12} ''// same as above 15rest2URL =" $ {rawValue % ?} "16 echo" 2nd restURL is $ {rest2URL} ">>$ bootOutput 2> & 117 18 # Now set the restURL value in the service context attributes (global scope, 19 # so it'll be available for all applications): 20 # e.g.: set-attributes-scope global '{"restURL": "$ {restURL}", "rest2URL": "$ {rest2URL}"} '21. /cloudify. sh "connect $ {restURL}; set-attributes-scope global '{\" restURL \ ": \" $ {restURL} \ ", \" rest2URL \": \ "$ {rest2URL} \"} '">>$ bootOutput 2> & 1 // connect to the restURL and set the restURL to the global attribute 22 23 # Just checking that it of all applications's there :) 24. /cloudify. sh "connect $ {restURL }; list-attributes ">>$ bootOutput 2> & 1 // test the connection and display all attributes 25 26 # Now you can install any application27 # and access the restURL attribute (or" rest2URL") 28 # e.g.: In a groovy lifecycle event handler: 29 # def restURL = context. attributes. global ["restURL"] 30 #. /cloudify. sh "connect $ {restURL}; install-application PATH_TO_APPLICATION" >>$ bootOutput 2> & 1