Support assigning IPMI credentials in ironic-discoverd-ramdisk

When setting IPMI credentials is requested, ironic-discoverd
will return ipmi_setup_credentials=true, ipmi_username and ipmi_password
in response. Use ipmitool to set credentials in this case.

Change-Id: I8ace9e817e5ce9dbfb8564feec4a3ce6c0e1b233
This commit is contained in:
Dmitry Tantsur 2015-02-12 14:20:56 +01:00
parent a9b07487ef
commit 3a0cdeb310
3 changed files with 24 additions and 1 deletions

View File

@ -2,5 +2,6 @@ curl
dmidecode
fdisk
ipmitool
jq
lscpu
wc

View File

@ -65,7 +65,28 @@ DISK_SIZE=$(($disk_bytes/1024/1024/1024 - 1))
NODE_DATA="'{\"ipmi_address\":\"$BMC_ADDRESS\",\"local_gb\":$DISK_SIZE,\"memory_mb\":$RAM,\"cpus\":$CPUS,\"cpu_arch\":\"$CPU_ARCH\""
NODE_DATA="$NODE_DATA,\"interfaces\":$IFACES,\"boot_interface\":\"$BOOTIF\"}'"
echo Collected $NODE_DATA
NODE_RESP=$(request_curl POST $DISCOVERD_URL $NODE_DATA)
NODE_RESP=$(request_curl POST $DISCOVERD_URL $NODE_DATA | tail -n1)
JSON_RESP=$(echo "$NODE_RESP" | tr '\r' '\n' | tail -n1) # drop HTTP headers
if echo "$JSON_RESP" | jq '.ipmi_setup_credentials' | grep -q true; then
USERNAME=$(echo "$JSON_RESP" | jq -r '.ipmi_username')
if [ -z "$USERNAME" ]; then
echo "Empty IPMI user name"
troubleshoot
fi
PASSWORD=$(echo "$JSON_RESP" | jq -r '.ipmi_password')
if [ -z "$PASSWORD" ]; then
echo "Empty IPMI password"
troubleshoot
fi
echo "Assigning IPMI credentials: user $USERNAME"
ipmitool user set name 2 $USERNAME
ipmitool user set password 2 $PASSWORD
# Assign priviledges just in case
ipmitool channel setaccess 1 2 link=on ipmi=on callin=on privilege=4
ipmitool user enable 2
fi
echo "Node is now discovered! Halting..."
# Give user a chance of seeing the output

View File

@ -1,4 +1,5 @@
curl:
dmidecoded:
ipmitool:
jq:
util-linux: