NovaCompute: Use variable to avoid calling crudini a second time

We don't need to run crudini twice to get the same config item; instead,
just remember the result of the first time.

Change-Id: I7591f5c7d1474447e29861e499d04b4b5bdb2a27
This commit is contained in:
Vincent Untz 2017-01-30 15:48:23 +01:00
parent 5b5c080a0b
commit 7a01081e73
1 changed files with 3 additions and 2 deletions

View File

@ -323,6 +323,7 @@ nova_validate() {
# we take a chance here and hope that host is either not configured
# or configured in nova.conf
local validate_host=1
NOVA_HOST=$(crudini --get /etc/nova/nova.conf DEFAULT host 2>/dev/null)
if [ $? = 1 ]; then
if [ "x${OCF_RESKEY_domain}" != x ]; then
@ -330,11 +331,11 @@ nova_validate() {
else
NOVA_HOST=$(uname -n)
fi
validate_host=0
fi
# We only need to check a configured value, calculated ones are fine
crudini --get /etc/nova/nova.conf DEFAULT host 2>/dev/null
if [ $? = 0 ]; then
if [ $validate_host -eq 1 ]; then
if [ "x${OCF_RESKEY_domain}" != x ]; then
short_host=$(uname -n | awk -F. '{print $1}')
if [ "x$NOVA_HOST" != "x${short_host}" ]; then