update ironic scripts

Thee scripts currently use 'ironic' commands, whhich is deprecated. This
patch converts to openstack commands.

Change-Id: I1a16164a7b8e35a61938ec470def37fa52db9edb
This commit is contained in:
Cameron Loader 2018-08-23 12:54:41 -05:00
parent 8b508a9d90
commit 778ce9895f
2 changed files with 66 additions and 54 deletions

View File

@ -25,26 +25,30 @@ function make-base-image {
scp -o StrictHostKeyChecking=no baremetal-$DISTRO_NAME-$DIB_RELEASE* "${UTILITY01_HOSTNAME}":~/images scp -o StrictHostKeyChecking=no baremetal-$DISTRO_NAME-$DIB_RELEASE* "${UTILITY01_HOSTNAME}":~/images
rm baremetal-$DISTRO_NAME-$DIB_RELEASE* # no reason to keep these around rm baremetal-$DISTRO_NAME-$DIB_RELEASE* # no reason to keep these around
VMLINUZ_UUID=$(ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; glance image-create --name baremetal-$DISTRO_NAME-$DIB_RELEASE.vmlinuz \ VMLINUZ_UUID=$(ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; openstack image create \
--visibility public \ --public \
--disk-format aki \ --disk-format aki \
--property hypervisor_type=baremetal \ --property hypervisor_type=baremetal \
--protected=True \ --protected \
--container-format aki < ~/images/baremetal-$DISTRO_NAME-$DIB_RELEASE.vmlinuz" | awk '/\| id/ {print $4}') --container-format aki \
INITRD_UUID=$(ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; glance image-create --name baremetal-$DISTRO_NAME-$DIB_RELEASE.initrd \ baremetal-$DISTRO_NAME-$DIB_RELEASE.vmlinuz < ~/images/baremetal-$DISTRO_NAME-$DIB_RELEASE.vmlinuz" | awk '/\| id/ {print $4}')
--visibility public \ INITRD_UUID=$(ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; openstack image create \
--public \
--disk-format ari \ --disk-format ari \
--property hypervisor_type=baremetal \ --property hypervisor_type=baremetal \
--protected=True \ --protected \
--container-format ari < ~/images/baremetal-$DISTRO_NAME-$DIB_RELEASE.initrd" | awk '/\| id/ {print $4}') --container-format ari \
ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; glance image-create --name baremetal-$DISTRO_NAME-$DIB_RELEASE \ baremetal-$DISTRO_NAME-$DIB_RELEASE.initrd < ~/images/baremetal-$DISTRO_NAME-$DIB_RELEASE.initrd" | awk '/\| id/ {print $4}')
--visibility public \ ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; openstack image create \
--public \
--disk-format qcow2 \ --disk-format qcow2 \
--container-format bare \ --container-format bare \
--property hypervisor_type=baremetal \ --property hypervisor_type=baremetal \
--property kernel_id=${VMLINUZ_UUID} \ --property kernel_id=${VMLINUZ_UUID} \
--protected=True \ --protected \
--property ramdisk_id=${INITRD_UUID} < ~/images/baremetal-$DISTRO_NAME-$DIB_RELEASE.qcow2" --property ramdisk_id=${INITRD_UUID} \
baremetal-$DISTRO_NAME-$DIB_RELEASE < ~/images/baremetal-$DISTRO_NAME-$DIB_RELEASE.qcow2"
} }
# install needed binaries # install needed binaries
@ -101,7 +105,7 @@ pushd ~/dib
# set up envars for the deploy image ironic agent # set up envars for the deploy image ironic agent
# export DIB_HPSSACLI_URL="http://downloads.hpe.com/pub/softlib2/software1/pubsw-linux/p1857046646/v109216/hpssacli-2.30-6.0.x86_64.rpm" # export DIB_HPSSACLI_URL="http://downloads.hpe.com/pub/softlib2/software1/pubsw-linux/p1857046646/v109216/hpssacli-2.30-6.0.x86_64.rpm"
export IRONIC_AGENT_VERSION="stable/ocata" export IRONIC_AGENT_VERSION="stable/rocky"
# create the deploy image # create the deploy image
disk-image-create --install-type source -o ironic-deploy ironic-agent ubuntu proliant-tools ${DEBUG_USER_ELEMENT:-""} disk-image-create --install-type source -o ironic-deploy ironic-agent ubuntu proliant-tools ${DEBUG_USER_ELEMENT:-""}
@ -110,18 +114,21 @@ pushd ~/dib
scp -o StrictHostKeyChecking=no ironic-deploy* "${UTILITY01_HOSTNAME}":~/images scp -o StrictHostKeyChecking=no ironic-deploy* "${UTILITY01_HOSTNAME}":~/images
rm ironic-deploy* # no reason to keep these around rm ironic-deploy* # no reason to keep these around
ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; glance image-create --name ironic-deploy.kernel \ ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; openstack image create \
--visibility public \ --public \
--disk-format aki \ --disk-format aki \
--property hypervisor_type=baremetal \ --property hypervisor_type=baremetal \
--protected=True \ --protected \
--container-format aki < ~/images/ironic-deploy.kernel" --container-format aki < ~/images/ironic-deploy.kernel \
ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; glance image-create --name ironic-deploy.initramfs \ ironic-deploy.kernel"
--visibility public \
ssh -o StrictHostKeyChecking=no "${UTILITY01_HOSTNAME}" "source ~/openrc; openstack image create \
--public \
--disk-format ari \ --disk-format ari \
--property hypervisor_type=baremetal \ --property hypervisor_type=baremetal \
--protected=True \ --protected \
--container-format ari < ~/images/ironic-deploy.initramfs" --container-format ari < ~/images/ironic-deploy.initramfs \
ironic-deploy.initramfs"
# Ubuntu Xenial final image # Ubuntu Xenial final image
make-base-image make-base-image

View File

@ -21,46 +21,51 @@ RESOURCE_CLASS="baremetal.general"
NOVA_RESOURCE_FLAVOR_NAME=${RESOURCE_CLASS//./_} NOVA_RESOURCE_FLAVOR_NAME=${RESOURCE_CLASS//./_}
NOVA_RESOURCE_FLAVOR_NAME=$(echo ${NOVA_RESOURCE_FLAVOR_NAME//-/_} | awk '{print toupper($0)}') NOVA_RESOURCE_FLAVOR_NAME=$(echo ${NOVA_RESOURCE_FLAVOR_NAME//-/_} | awk '{print toupper($0)}')
KERNEL_IMAGE=$(glance image-list | awk '/baremetal-ubuntu-xenial.vmlinuz/ {print $2}') KERNEL_IMAGE=$(openstack image-list | awk '/baremetal-ubuntu-xenial.vmlinuz/ {print $2}')
INITRAMFS_IMAGE=$(glance image-list | awk '/baremetal-ubuntu-xenial.initrd/ {print $2}') INITRAMFS_IMAGE=$(openstack image-list | awk '/baremetal-ubuntu-xenial.initrd/ {print $2}')
DEPLOY_RAMDISK=$(glance image-list | awk '/ironic-deploy.initramfs/ {print $2}') DEPLOY_RAMDISK=$(openstack image-list | awk '/ironic-deploy.initramfs/ {print $2}')
DEPLOY_KERNEL=$(glance image-list | awk '/ironic-deploy.kernel/ {print $2}') DEPLOY_KERNEL=$(openstack image-list | awk '/ironic-deploy.kernel/ {print $2}')
if ironic node-list | grep "$inventory_hostname"; then if openstack baremetal node-list | grep "$inventory_hostname"; then
NODE_UUID=$(ironic --ironic-api-version 1.22 node-list | awk "/$inventory_hostname/ {print \$2}") NODE_UUID=$(openstack baremetal --os-baremetal-api-version 1.22 node-list | awk "/$inventory_hostname/ {print \$2}")
else else
NODE_UUID=$(ironic --ironic-api-version 1.22 node-create \ NODE_UUID=$(openstack baremetal --os-baremetal-api-version 1.22 node create \
-d agent_ipmitool \ --driver agent_ipmitool \
-i ipmi_address="$ipmi_address" \ --driver-info ipmi_address="$ipmi_address" \
-i ipmi_password="$ipmi_password" \ --driver-info ipmi_password="$ipmi_password" \
-i ipmi_username="$ipmi_user" \ --driver-info ipmi_username="$ipmi_user" \
-i deploy_ramdisk="${DEPLOY_RAMDISK}" \ --driver-info deploy_ramdisk="${DEPLOY_RAMDISK}" \
-i deploy_kernel="${DEPLOY_KERNEL}" \ --driver-info deploy_kernel="${DEPLOY_KERNEL}" \
-p cpus=$image_vcpu \ --property cpus=$image_vcpu \
-p memory_mb=$image_ram \ --property memory_mb=$image_ram \
-p local_gb=$ironic_disk_available \ --property local_gb=$ironic_disk_available \
-p size=$image_total_disk_size \ --property size=$image_total_disk_size \
-p cpu_arch=$image_cpu_arch \ --property cpu_arch=$image_cpu_arch \
-p capabilities=boot_option:local,disk_label:gpt \ --property capabilities=boot_option:local,disk_label:gpt \
-n $inventory_hostname \ -n $inventory_hostname \
--resource-class ${RESOURCE_CLASS} | awk '/ uuid / {print $4}') --resource-class ${RESOURCE_CLASS} | awk '/ uuid / {print $4}')
ironic --ironic-api-version 1.22 port-create -n "$NODE_UUID" \ openstack baremetal --os-baremetal-api-version 1.22 port create --node "$NODE_UUID" \
-a $Port1NIC_MACAddress $Port1NIC_MACAddress
fi fi
# flavor creation # flavor creation
if ! nova flavor-list | grep "${RESOURCE_CLASS}"; then if ! openstack flavor list | grep "${RESOURCE_CLASS}"; then
FLAVOR_ID=$(cat /proc/sys/kernel/random/uuid) openstack flavor create \
nova flavor-create ${RESOURCE_CLASS} ${FLAVOR_ID} ${image_ram} ${image_disk_root} ${image_vcpu} --ram ${image_ram} \
nova flavor-key ${RESOURCE_CLASS} set cpu_arch=x86_64 --disk ${image_disk_root} \
nova flavor-key ${RESOURCE_CLASS} set capabilities:boot_option="local" --vcpus ${image_vcpu} \
nova flavor-key ${RESOURCE_CLASS} set capabilities:disk_label="gpt" ${RESOURCE_CLASS}
nova flavor-key ${RESOURCE_CLASS} set resources:VCPU=0 openstack flavor set \
nova flavor-key ${RESOURCE_CLASS} set resources:MEMORY_MB=0 --property cpu_arch=x86_64 \
nova flavor-key ${RESOURCE_CLASS} set resources:DISK_GB=0 --property capabilities:boot_option="local" \
nova flavor-key ${RESOURCE_CLASS} set resources:CUSTOM_${NOVA_RESOURCE_FLAVOR_NAME}=1 --property capabilities:disk_label="gpt" \
--property resources:VCPU=0 \
--property resources:MEMORY_MB=0 \
--property resources:DISK_GB=0 \
--property resources:CUSTOM_${NOVA_RESOURCE_FLAVOR_NAME}=1 \
${RESOURCE_CLASS}
fi fi
ironic --ironic-api-version 1.22 node-set-provision-state "${NODE_UUID}" manage openstack baremetal --os-baremetal-api-version 1.22 node manage "${NODE_UUID}"
sleep 1m # necessary to get power state sleep 1m # necessary to get power state
ironic --ironic-api-version 1.22 node-set-provision-state "${NODE_UUID}" provide openstack baremetal --os-baremetal-api-version 1.22 node provide "${NODE_UUID}"