use openstack command instead of nova command

In function 'get_instance_ip', 'nova' client command is used to get
instance information in order to retrive IP address of the instance.

There is no need to use the nova command, since 'openstack' client
already supports such basic operation.

Moreover, 'openstack' client has an option to get value of specified
column. That brings more accurate way of retriving IP address.

This patch replaces nova command in 'get_instance_ip' by 'openstack'
command. Note, this nova command is the only one in devstack tree.

Change-Id: Iee0b81a994a4da5b3f4572c2e8eb30514cd43f89
Signed-off-by: Ryota MIBU <r-mibu@cq.jp.nec.com>
This commit is contained in:
Ryota MIBU 2017-12-25 16:28:50 +09:00
parent 614cab33c4
commit 842d54a299

View File

@ -503,13 +503,13 @@ function ping_check {
function get_instance_ip {
local vm_id=$1
local network_name=$2
local nova_result
local addresses
local ip
nova_result="$(nova show $vm_id)"
ip=$(echo "$nova_result" | grep "$network_name" | get_field 2)
addresses=$(openstack server show -c addresses -f value "$vm_id")
ip=$(echo $addresses | sed -n "s/^.*$network_name=\([0-9\.]*\).*$/\1/p")
if [[ $ip = "" ]];then
echo "$nova_result"
echo "addresses of server $vm_id : $addresses"
die $LINENO "[Fail] Couldn't get ipaddress of VM"
fi
echo $ip