Browse code

Remove the usage of read_password from library files

The read_password function is defined inside stack.sh
and it cannot be used inside the "public library interface"
provided by DevStack.

Move the calls found inside library files to stack.sh,
following the same pattern of the other calls to read_password.

Change-Id: I8adc6723b677dfac2bef735f660e056c498bf773

Luigi Toscano authored on 2019/02/21 18:36:18
Showing 3 changed files
... ...
@@ -87,8 +87,6 @@ function initialize_database_backends {
87 87
 
88 88
     if [ -n "$MYSQL_PASSWORD" ]; then
89 89
         DATABASE_PASSWORD=$MYSQL_PASSWORD
90
-    else
91
-        read_password DATABASE_PASSWORD "ENTER A PASSWORD TO USE FOR THE DATABASE."
92 90
     fi
93 91
 
94 92
     # We configure Nova, Horizon, Glance and Keystone to use MySQL as their
... ...
@@ -59,7 +59,6 @@ function configure_nova_hypervisor {
59 59
         die $LINENO "os-xenapi plugin is not specified. Please enable this plugin in local.conf"
60 60
     fi
61 61
 
62
-    read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
63 62
     iniset $NOVA_CONF DEFAULT compute_driver "xenapi.XenAPIDriver"
64 63
     iniset $NOVA_CONF xenserver connection_url "$XENAPI_CONNECTION_URL"
65 64
     iniset $NOVA_CONF xenserver connection_username "$XENAPI_USER"
... ...
@@ -691,7 +691,14 @@ function read_password {
691 691
 # The available database backends are listed in ``DATABASE_BACKENDS`` after
692 692
 # ``lib/database`` is sourced. ``mysql`` is the default.
693 693
 
694
-initialize_database_backends && echo "Using $DATABASE_TYPE database backend" || echo "No database enabled"
694
+if initialize_database_backends; then
695
+    echo "Using $DATABASE_TYPE database backend"
696
+    # Last chance for the database password. This must be handled here
697
+    # because read_password is not a library function.
698
+    read_password DATABASE_PASSWORD "ENTER A PASSWORD TO USE FOR THE DATABASE."
699
+else
700
+    echo "No database enabled"
701
+fi
695 702
 
696 703
 
697 704
 # Queue Configuration
... ...
@@ -729,6 +736,16 @@ if is_service_enabled keystone; then
729 729
 fi
730 730
 
731 731
 
732
+# Nova
733
+# -----
734
+
735
+if is_service_enabled nova && [[ "$VIRT_DRIVER" == 'xenserver' ]]; then
736
+    # Look for the backend password here because read_password
737
+    # is not a library function.
738
+    read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
739
+fi
740
+
741
+
732 742
 # Swift
733 743
 # -----
734 744