2 min read

OpenStack Ironic Node Enrollment

OpenStack Ironic Node Enrollment

Enroll your first node into ironic

Enrolling a node into Ironic is quite simple though its non-trival. It's only a couple of API calls to make all of it come together but does require a bit of information. In the after now the Ironic Inspector should make life a lot simpler however until then the following example is the best I've got. This assumes you've already created flavors, have images uploaded, and have IPMI access. If you need to create images and flavors have a read here on how that can be done.

The example presents itself as a script. Simply adjust the values of the variables found at the top of the script to suit your needs.

To run the following set of commands login to a utility node (container) and then source the openrc file in the root users home directory giving you access to the admin API.

# Node details
inventory_hostname=node-hostname
Port1NIC_MACAddress="aa:bb:cc:dd:ee:ff"

# IPMI details
ipmi_address="127.1.1.1"
ipmi_password="secrete"
ipmi_user="root"

# Image details belonging to a particular node 
image_vcpu=48
image_ram=254802
image_disk=80
image_total_disk_size=3600
image_cpu_arch="x86_64"

KERNEL_IMAGE=$(glance image-list | awk '/ubuntu-user-image.vmlinuz/ {print $2}')
INITRAMFS_IMAGE=$(glance image-list | awk '/ubuntu-user-image.initrd/ {print $2}')
DEPLOY_RAMDISK=$(glance image-list | awk '/ironic-deploy.initramfs/ {print $2}')
DEPLOY_KERNEL=$(glance image-list | awk '/ironic-deploy.kernel/ {print $2}')


if ironic node-list | grep "$inventory_hostname"; then
    NODE_UUID=$(ironic node-list | awk "/$inventory_hostname/ {print \$2}")
else
    NODE_UUID=$(ironic node-create \
      -d agent_ipmitool \
      -i ipmi_address="$ipmi_address" \
      -i ipmi_password="$ipmi_password" \
      -i ipmi_username="$ipmi_user" \
      -i deploy_ramdisk="${DEPLOY_RAMDISK}" \
      -i deploy_kernel="${DEPLOY_KERNEL}" \
      -n $inventory_hostname | awk '/ uuid / {print $4}')
    ironic port-create -n "$NODE_UUID" \
                       -a $Port1NIC_MACAddress
fi
ironic node-update "$NODE_UUID" add \
          driver_info/deploy_kernel=$DEPLOY_KERNEL \
          driver_info/deploy_ramdisk=$DEPLOY_RAMDISK \
          instance_info/deploy_kernel=$KERNEL_IMAGE \
          instance_info/deploy_ramdisk=$INITRAMFS_IMAGE \
          instance_info/root_gb=40 \
          properties/cpus=$image_vcpu \
          properties/memory_mb=$image_ram \
          properties/local_gb=$image_disk \
          properties/size=$image_total_disk_size \
          properties/cpu_arch=$image_cpu_arch
          properties/capabilities=memory_mb:$image_ram,local_gb:$image_disk,cpu_arch:$image_cpu_arch,cpus:$image_vcpu,boot_option:local,disk_label:gpt

With node(s) enrolled into Ironic you're now ready to provision your first node using nova and Ironic baremetal provisioning system.