sh Openstack:使用python-novaclient命令将浮动IP与实例解除关联/重新关联,以纠正连接问题。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Openstack:使用python-novaclient命令将浮动IP与实例解除关联/重新关联,以纠正连接问题。相关的知识,希望对你有一定的参考价值。

!/bin/bash


togglefloaterByUUID() { 
floater=$(nova show $1 | grep network | awk -F "|" '{printf $3}' | awk -F ", " '{printf $NF}' | sed -e 's/ //g' | sed ':a;N;$!ba;s/\n/ /g'); 
if [ -z $floater ]; then 
echo $1": No floating IP association found.";
else 
name=$(nova show $1 | grep ' name ' | awk -F "|" '{printf $3}' | sed -e 's/ //g' | sed ':a;N;$!ba;s/\n/ /g'); 
echo "Dis-associating floating IP" $floater "from instance" $name "("$1")..."; 
nova floating-ip-disassociate $1 $floater; 
echo "Done." 
echo "Associating floating IP" $floater "to instance" $name "("$1")...";
nova floating-ip-associate $1 $floater; 
echo "Done.";
unset name;
unset floater;
fi
}
export -f togglefloaterByUUID

togglefloaterByIP() { 
instance=$(nova list | grep $1 | awk -F "|" '{printf $2}'| sed -e 's/ //g' | sed ':a;N;$!ba;s/\n/ /g'); 
if [ -z $instance ]; then 
echo $1": No instance association found.";
else 
name=$(nova show $instance | grep ' name ' | awk -F "|" '{printf $3}' | sed -e 's/ //g' | sed ':a;N;$!ba;s/\n/ /g'); 
echo "Dis-associating floating IP" $1 "from instance" $name "("$instance")..."; 
nova floating-ip-disassociate $instance $1; 
echo "Done." 
echo "Associating floating IP" $1 "to instance" $name "("$instance")...";
nova floating-ip-associate $instance $1; 
echo "Done.";
unset name;
unset instance;
fi
}
export -f togglefloaterByIP

以上是关于sh Openstack:使用python-novaclient命令将浮动IP与实例解除关联/重新关联,以纠正连接问题。的主要内容,如果未能解决你的问题,请参考以下文章

sh Openstack CLI命令使用标识V3(包含组)创建新项目/租户和网络

openstack中利用screen命令重启服务

sh Openstack:使用python-novaclient命令将浮动IP与实例解除关联/重新关联,以纠正连接问题。

sh Openstack:使用python-novaclient命令将浮动IP与实例解除关联/重新关联,以纠正连接问题。

sh Openstack命令示例

sh openstack keystone端点恢复脚本