歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Cloudify REST腳本

Cloudify REST腳本

日期:2017/3/1 14:50:28   编辑:關於Linux
Cloudify REST腳本 01 #!/bin/bash 02 03 bootOutput="bl.out" 04 rm -f $bootOutput//刪除b1.out文件 05 ./cloudify.sh "bootstrap-cloud ec2" > $bootOutput 2>&1//運行./cloudify.sh bootstrap-cloud ec2並將輸出到b1.out和標准輸入重定向到標准輸出。 06 searchString="Rest service is" 07 selectedText=`grep "${searchString}" $bootOutput`//查找b1.out中"Rest service is"的行賦給selectedText 08 rawValue=`echo ${selectedText} | awk '{print $6}'`//將selectedText中第六個域(以空格或tab分割)賦給rawValue 09 restURL="${rawValue%?}"//linux字符串操作,刪除rawValue的最後一個字符後執行,即提取restURL 10 echo "1st restURL is ${restURL}" >> $bootOutput 2>&1//打印並重定向到b1.out和標准輸出 11 12 # If there are two management machines (and in production, we recommend it...), 13 # you'll have two Rest URLs 14 rawValue=`echo ${selectedText} | awk '{print $12}'`//和上面一樣 15 rest2URL="${rawValue%?}" 16 echo "2nd restURL is ${rest2URL}" >> $bootOutput 2>&1 17 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//連接restURL並將restURL設為所有應用的全局屬性 22 23 # Just checking that it's there :) 24 ./cloudify.sh "connect ${restURL};list-attributes" >> $bootOutput 2>&1//測試連接並顯示所有屬性 25 26 # Now you can install any application 27 # 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
Copyright © Linux教程網 All Rights Reserved