Faster nova fixed key generation
Using bc 64 times in loop is too verbose and slow,
replacing the echo/bc loop with hexdump and urandom.
The hexdump approach is 75 times faster and
does not floods the debug logs.
Using the common function for generating,
this kind of string with lib/heat and by the read_password.
Change-Id: If6a86dfaf0c21e2635c6de0a7b96a8ed7ec5b507
diff --git a/stack.sh b/stack.sh
index 6c4bde7..2f93ab5 100755
--- a/stack.sh
+++ b/stack.sh
@@ -426,7 +426,7 @@
echo "Invalid chars in password. Try again:"
done
if [ ! $pw ]; then
- pw=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 20)
+ pw=$(generate_hex_string 10)
fi
eval "$var=$pw"
echo "$var=$pw" >> $localrc
@@ -1211,11 +1211,7 @@
# Create a randomized default value for the keymgr's fixed_key
if is_service_enabled nova; then
- FIXED_KEY=""
- for i in $(seq 1 64); do
- FIXED_KEY+=$(echo "obase=16; $(($RANDOM % 16))" | bc);
- done;
- iniset $NOVA_CONF keymgr fixed_key "$FIXED_KEY"
+ iniset $NOVA_CONF keymgr fixed_key $(generate_hex_string 32)
fi
if is_service_enabled zeromq; then