Skip to content

Commit 0a8c555

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Faster nova fixed key generation"
2 parents a672e02 + f71b500 commit 0a8c555

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

functions-common

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,13 @@ function get_default_host_ip {
695695
echo $host_ip
696696
}
697697

698+
# Generates hex string from ``size`` byte of pseudo random data
699+
# generate_hex_string size
700+
function generate_hex_string {
701+
local size=$1
702+
hexdump -n "$size" -v -e '/1 "%02x"' /dev/urandom
703+
}
704+
698705
# Grab a numbered field from python prettytable output
699706
# Fields are numbered starting with 1
700707
# Reverse syntax is supported: -1 is the last field, -2 is second to last, etc.

lib/heat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function configure_heat {
9898
iniset $HEAT_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition
9999
iniset $HEAT_CONF DEFAULT heat_watch_server_url http://$HEAT_API_CW_HOST:$HEAT_API_CW_PORT
100100
iniset $HEAT_CONF database connection `database_connection_url heat`
101-
iniset $HEAT_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/urandom`
101+
iniset $HEAT_CONF DEFAULT auth_encryption_key $(generate_hex_string 16)
102102

103103
iniset $HEAT_CONF DEFAULT region_name_for_services "$REGION_NAME"
104104

stack.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ function read_password {
426426
echo "Invalid chars in password. Try again:"
427427
done
428428
if [ ! $pw ]; then
429-
pw=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 20)
429+
pw=$(generate_hex_string 10)
430430
fi
431431
eval "$var=$pw"
432432
echo "$var=$pw" >> $localrc
@@ -1211,11 +1211,7 @@ fi
12111211

12121212
# Create a randomized default value for the keymgr's fixed_key
12131213
if is_service_enabled nova; then
1214-
FIXED_KEY=""
1215-
for i in $(seq 1 64); do
1216-
FIXED_KEY+=$(echo "obase=16; $(($RANDOM % 16))" | bc);
1217-
done;
1218-
iniset $NOVA_CONF keymgr fixed_key "$FIXED_KEY"
1214+
iniset $NOVA_CONF keymgr fixed_key $(generate_hex_string 32)
12191215
fi
12201216

12211217
if is_service_enabled zeromq; then

0 commit comments

Comments
 (0)