Merge "Faster nova fixed key generation"

This commit is contained in:
Jenkins 2014-09-02 22:06:15 +00:00 committed by Gerrit Code Review
commit 0a8c555079
3 changed files with 10 additions and 7 deletions

View File

@ -695,6 +695,13 @@ function get_default_host_ip {
echo $host_ip echo $host_ip
} }
# Generates hex string from ``size`` byte of pseudo random data
# generate_hex_string size
function generate_hex_string {
local size=$1
hexdump -n "$size" -v -e '/1 "%02x"' /dev/urandom
}
# Grab a numbered field from python prettytable output # Grab a numbered field from python prettytable output
# Fields are numbered starting with 1 # Fields are numbered starting with 1
# Reverse syntax is supported: -1 is the last field, -2 is second to last, etc. # Reverse syntax is supported: -1 is the last field, -2 is second to last, etc.

View File

@ -98,7 +98,7 @@ function configure_heat {
iniset $HEAT_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition iniset $HEAT_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition
iniset $HEAT_CONF DEFAULT heat_watch_server_url http://$HEAT_API_CW_HOST:$HEAT_API_CW_PORT iniset $HEAT_CONF DEFAULT heat_watch_server_url http://$HEAT_API_CW_HOST:$HEAT_API_CW_PORT
iniset $HEAT_CONF database connection `database_connection_url heat` iniset $HEAT_CONF database connection `database_connection_url heat`
iniset $HEAT_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/urandom` iniset $HEAT_CONF DEFAULT auth_encryption_key $(generate_hex_string 16)
iniset $HEAT_CONF DEFAULT region_name_for_services "$REGION_NAME" iniset $HEAT_CONF DEFAULT region_name_for_services "$REGION_NAME"

View File

@ -426,7 +426,7 @@ function read_password {
echo "Invalid chars in password. Try again:" echo "Invalid chars in password. Try again:"
done done
if [ ! $pw ]; then if [ ! $pw ]; then
pw=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 20) pw=$(generate_hex_string 10)
fi fi
eval "$var=$pw" eval "$var=$pw"
echo "$var=$pw" >> $localrc echo "$var=$pw" >> $localrc
@ -1211,11 +1211,7 @@ fi
# Create a randomized default value for the keymgr's fixed_key # Create a randomized default value for the keymgr's fixed_key
if is_service_enabled nova; then if is_service_enabled nova; then
FIXED_KEY="" iniset $NOVA_CONF keymgr fixed_key $(generate_hex_string 32)
for i in $(seq 1 64); do
FIXED_KEY+=$(echo "obase=16; $(($RANDOM % 16))" | bc);
done;
iniset $NOVA_CONF keymgr fixed_key "$FIXED_KEY"
fi fi
if is_service_enabled zeromq; then if is_service_enabled zeromq; then