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>
... | ... |
@@ -503,13 +503,13 @@ function ping_check { |
503 | 503 |
function get_instance_ip { |
504 | 504 |
local vm_id=$1 |
505 | 505 |
local network_name=$2 |
506 |
- local nova_result |
|
506 |
+ local addresses |
|
507 | 507 |
local ip |
508 | 508 |
|
509 |
- nova_result="$(nova show $vm_id)" |
|
510 |
- ip=$(echo "$nova_result" | grep "$network_name" | get_field 2) |
|
509 |
+ addresses=$(openstack server show -c addresses -f value "$vm_id") |
|
510 |
+ ip=$(echo $addresses | sed -n "s/^.*$network_name=\([0-9\.]*\).*$/\1/p") |
|
511 | 511 |
if [[ $ip = "" ]];then |
512 |
- echo "$nova_result" |
|
512 |
+ echo "addresses of server $vm_id : $addresses" |
|
513 | 513 |
die $LINENO "[Fail] Couldn't get ipaddress of VM" |
514 | 514 |
fi |
515 | 515 |
echo $ip |