Browse Source

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
Vincent Untz 2 years ago
parent
commit
7a01081e73
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      ocf/NovaCompute

+ 3
- 2
ocf/NovaCompute View File

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

Loading…
Cancel
Save