6 SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
9 # Get variables from the config file
10 if [ -z "${CONFIG:-}" ]; then
11 # See if there's a config_$USER.sh in the SCRIPTDIR
12 if [ ! -f ${SCRIPTDIR}/../config_${USER}.sh ]; then
13 cp ${SCRIPTDIR}/../config_example.sh ${SCRIPTDIR}/../config_${USER}.sh
14 echo "Automatically created config_${USER}.sh with default contents."
16 CONFIG="${SCRIPTDIR}/../config_${USER}.sh"
22 ADDN_DNS=${ADDN_DNS:-}
23 # External interface for routing traffic through the host
25 # Provisioning interface
27 # Does libvirt manage the baremetal bridge (including DNS and DHCP)
28 MANAGE_BR_BRIDGE=${MANAGE_BR_BRIDGE:-y}
29 # Only manage bridges if is set
30 MANAGE_PRO_BRIDGE=${MANAGE_PRO_BRIDGE:-y}
31 MANAGE_INT_BRIDGE=${MANAGE_INT_BRIDGE:-y}
32 # Internal interface, to bridge virbr0
35 CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-"docker"}
37 export EXTERNAL_SUBNET="192.168.111.0/24"
38 #Ironic data directory
39 IRONIC_DATA_DIR=${IRONIC_DATA_DIR:-"/opt/ironic"}
40 export SSH_PUB_KEY=~/.ssh/id_rsa.pub
42 FILESYSTEM=${FILESYSTEM:="/"}
44 WORKING_DIR=${WORKING_DIR:-"/opt/metal3-vm"}
45 NODES_FILE=${NODES_FILE:-"${WORKING_DIR}/ironic_nodes.json"}
46 NODES_PLATFORM=${NODES_PLATFORM:-"libvirt"}
48 export NUM_MASTERS=${NUM_MASTERS:-"1"}
49 export NUM_WORKERS=${NUM_WORKERS:-"1"}
50 export VM_EXTRADISKS=${VM_EXTRADISKS:-"false"}
53 export IRONIC_IMAGE=${IRONIC_IMAGE:-"integratedcloudnative/ironic:v1.0-icn"}
54 export IRONIC_INSPECTOR_IMAGE=${IRONIC_INSPECTOR_IMAGE:-"integratedcloudnative/ironic-inspector:v1.0-icn"}
55 export IRONIC_BAREMETAL_IMAGE=${IRONIC_BAREMETAL_IMAGE:-"integratedcloudnative/baremetal-operator:v2.0-icn"}
56 export IPA_DOWNLOADER_IMAGE=${IPA_DOWNLOADER_IMAGE:-"integratedcloudnative/ironic-ipa-downloader:v1.0-icn"}
58 # Verify requisites/permissions
59 # Connect to system libvirt
60 export LIBVIRT_DEFAULT_URI=qemu:///system
61 if [ "$USER" != "root" -a "${XDG_RUNTIME_DIR:-}" == "/run/user/0" ] ; then
62 echo "Please use a non-root user, WITH a login shell (e.g. su - USER)"
66 # Check if sudo privileges without password
67 if ! sudo -n uptime &> /dev/null ; then
68 echo "sudo without password is required"
73 OS=$(awk -F= '/^ID=/ { print $2 }' /etc/os-release | tr -d '"')
74 if [[ ! $OS =~ ^(centos|rhel|ubuntu)$ ]]; then
79 # Check CentOS version
80 os_version=$(awk -F= '/^VERSION_ID=/ { print $2 }' /etc/os-release | tr -d '"' | cut -f1 -d'.')
81 if [[ ${os_version} -ne 7 ]] && [[ ${os_version} -ne 18 ]]; then
82 echo "Required CentOS 7 or RHEL 7 or Ubuntu 18.04"
86 # Check d_type support
87 FSTYPE=$(df ${FILESYSTEM} --output=fstype | grep -v Type)
93 if [[ $(xfs_info ${FILESYSTEM} | grep -q "ftype=1") ]]; then
94 echo "Filesystem not supported"
99 echo "Filesystem not supported"
104 if [ ! -d "$WORKING_DIR" ]; then
105 echo "Creating Working Dir"
106 sudo mkdir "$WORKING_DIR"
107 sudo chown "${USER}:${USER}" "$WORKING_DIR"
108 chmod 755 "$WORKING_DIR"
111 function list_nodes {
112 # Includes -machine and -machine-namespace
116 .driver + "://" + .driver_info.ipmi_address + (if .driver_info.ipmi_port then ":" + .driver_info.ipmi_port else "" end),
117 .driver_info.ipmi_username,
118 .driver_info.ipmi_password,
124 function node_networkdata {
126 cat $NODES_FILE | jq -r --arg name "$name" '.nodes[] | select(.name==$name) | .net'