-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-agent_ipmitool.sh
More file actions
executable file
·68 lines (49 loc) · 2.23 KB
/
deploy-agent_ipmitool.sh
File metadata and controls
executable file
·68 lines (49 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#
# deploy_node - helper script to deploy using IPMI/PXE and ironic-python-agent
#
# Change these settings to match your environment
export NAME="xxxxxx" # what you want to refer to your node as
export MAC="xx:xx:xx:xx:xx:xx" # PXE bootable MAC on the node
export IPMIADDRESS="xxx.xxx.xxx.xxx" # your node's drac/ilo IP addr
export IPMIUSER="xxxx"
export IPMIPASSWORD="xxxxxx" # Remember to escape $ and \
export IPMIPORT="xxxx"
export HTTPADDRESS="xxx.xxx.xxx.xxx" # ironic-api node IP addr
export DEPLOYRAMDISK="http://${HTTPADDRESS}/images/deploy/coreos_production_pxe_image-oem.cpio.gz"
export DEPLOYKERNEL="http://${HTTPADDRESS}/images/deploy/coreos_production_pxe.vmlinuz"
export USERIMAGE="http://${HTTPADDRESS}/images/user/my-image.qcow2"
export USERIMAGEMD5="a52a1cb7efe8ee336f7e9b1a5ecb5a46"
# Should we watch the provisioning state changes?
WATCH=1
export IRONIC='ironic'
export IPMITOOL='ipmitool'
export WATCH_CMD='watch'
__check_cmd_avail ()
{
if [ z$(which $1) == "z" ]; then
echo "The command '$1' could not be found, exiting"
exit 1
fi
}
# Verify we have the commands we need
__check_cmd_avail ${IPMITOOL}
__check_cmd_avail ${IRONIC}
__check_cmd_avail ${WATCH_CMD}
# Unenroll and delete the node if it's there
${IRONIC} node-set-maintenance ${NAME} on
${IRONIC} node-delete ${NAME}
# Turn off the node and start from power down
${IPMITOOL} -I lanplus -H ${IPMIADDRESS} -L ADMINISTRATOR -U ${IPMIUSER} -R 12 -N 5 -P ${IPMIPASSWORD} -p ${IPMIPORT} power off
# Enroll the node
${IRONIC} node-create -d agent_${IPMITOOL} -i ipmi_address="${IPMIADDRESS}" -i ipmi_password="${IPMIPASSWORD}" -i ipmi_username="${IPMIUSER}" -p ${IPMIPORT} -i deploy_ramdisk="${DEPLOYRAMDISK}" -i deploy_kernel="${DEPLOYKERNEL}" -n ${NAME}
${IRONIC} node-update ${NAME} add instance_info/image_source="${USERIMAGE}" instance_info/root_gb=20 instance_info/image_checksum="${USERIMAGEMD5}"
NODEUUID=$(${IRONIC} node-list | grep ${NAME} | cut -f 2 -d "|" )
${IRONIC} port-create -n ${NODEUUID} -a ${MAC}
${IRONIC} node-validate ${NAME}
# Start the deploy
${IRONIC} node-set-provision-state ${NAME} active
# Watch what's going on
if [[ ${WATCH} -eq 1 ]]; then
${WATCH_CMD} ${IRONIC} node-show ${NAME}
fi