sh 查询openstack nova实例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 查询openstack nova实例相关的知识,希望对你有一定的参考价值。
# CTL
source keystonerc;
function nova-show-vm() {
nova show $(nova list --all-tenants |grep $@ | tee /dev/fd/2 |awk '{print $2}')
};
function instance-placement() {
nova-show-vm $1 |egrep "hypervisor|network| id" | awk -F"|" '{print $3}'\
| sed "s,\s*,,g" | xargs
};
# CFG
function instance-check() {
salt $1 cmd.run "tail -n30 /var/lib/nova/instances/*-*-*/console.log;";
salt $1 cmd.run "virsh list --all";
ping -c3 $2;
}
instance-check $(instance-placement $IP)
function getip ()
{
getent hosts $1 | awk '{ print $1 }'
}
nova-show-vm-cache() {
TEMPCAHCE=/tmp/nova-vm-list.$(date "+%Y-%m-%d-%h")
test -e $TEMPCAHCE || {
nova-manage vm list | column -t > $TEMPCAHCE
}
egrep $@ "$TEMPCAHCE" | egrep -v deleted | awk '{print $7,$2,$1,$4}'
}
## associate Floating IPs by instance name
declare PORTS=($(nova list --all-tenants|egrep -i '(gb-ss-vos-node-iyvooqnuxvqj-4jqzkrgqbcbx-r3ey62hav3ge|gb-ss-vos-node-iyvooqnuxvqj-zi3eglyjffrd-n7xcuwcgkjlg|gb-ss-.....)' |awk -F"|" '{print $2}' | xargs neutron port-list --device-id |awk -F"|" '{print $2}'|xargs))
declare -a FFIPS=($(nova floating-ip-list |egrep egress |grep '| - | -'|awk -F"|" '{print $2}'|xargs))
for i in $(seq 1 ${#PORTS[@]}); do echo neutron floatingip-associate ${FFIPS[$i]} ${PORTS[$i]};done
## get logs from stack
nova console-log $(openstack stack resource show 87dd6864-f004-467f-9725-39e67e59dbd2 mcp_salt_master -f json | jq -cr '.attributes.instance')
以上是关于sh 查询openstack nova实例的主要内容,如果未能解决你的问题,请参考以下文章
##5.1 Nova控制节点--openstack
OpenStack 安装:nova服务
##5.2 Nova计算节点--openstack
openstack之nova
如何删除 OpenStack Nova 僵尸实例
在OpenStack环境中创建一个VM实例