Cloudify REST 脚本

#!/bin/bash
 
bootOutput="bl.out"
rm -f $bootOutput//删除b1.out文件
./cloudify.sh "bootstrap-cloud ec2" > $bootOutput 2>&1//运行./cloudify.sh bootstrap-cloud ec2并将输出到b1.out和标准输入重定向到标准输出。
searchString="Rest service is"
selectedText=`grep "${searchString}" $bootOutput`//查找b1.out中"Rest service is"的行赋给selectedText
rawValue=`echo ${selectedText} | awk '{print $6}'`//将selectedText中第六个域(以空格或tab分割)赋给rawValue
restURL="${rawValue%?}"//linux字符串操作,删除rawValue的最后一个字符后执行,即提取restURL
echo "1st restURL is ${restURL}" >> $bootOutput 2>&1//打印并重定向到b1.out和标准输出
 
# If there are two management machines (and in production, we recommend it...), 
# you'll have two Rest URLs
rawValue=`echo ${selectedText} | awk '{print $12}'`//和上面一样
rest2URL="${rawValue%?}"
echo "2nd restURL is ${rest2URL}" >> $bootOutput 2>&1
 
# Now set the restURL value in the service context attributes (global scope ,
# so it'll be available for all applications) : 
# e.g. : set-attributes -scope global '{"restURL":"${restURL}", "rest2URL":"${rest2URL}"}'
./cloudify.sh "connect ${restURL};set-attributes -scope global '{\"restURL\":\"${restURL}\", \"rest2URL\":\"${rest2URL}\"}'" >> $bootOutput 2>&1//连接restURL并将restURL设为所有应用的全局属性
 
# Just checking that it's there :) 
./cloudify.sh "connect ${restURL};list-attributes" >> $bootOutput 2>&1//测试连接并显示所有属性
 
# Now you can install any application 
# and access the restURL attribute (or "rest2URL") 
# e.g.: In a groovy lifecycle event handler : 
#  def restURL = context.attributes.global["restURL"]
# ./cloudify.sh "connect ${restURL};install-application PATH_TO_APPLICATION" >> $bootOutput 2>&1

转载于:https://my.oschina.net/OQKuDOtsbYT2/blog/129637

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值