From c1e2197113bf7b180a914b0e85a034013dd4ba9e Mon Sep 17 00:00:00 2001 From: Ronelle Landy Date: Tue, 8 Nov 2016 17:11:00 -0500 Subject: [PATCH] Add disk-size-hint to prep-images repo Previously this code lived in prep-baremetal repo. Since this repo is called often before introspection is run, the disk-size-hints are called before they can impact the correct values. disk-size-hints is historically used only on some baremetal environments but can be included in validation tests on virt environments as well. Related-To: Idfca0da41275922f4b846cc167980e95f4fe8321 Related-To: If4dd41baa38639a7c0965049651641d489870983 Change-Id: I3c0fe67d2b4adcafa65057a8536e2629c62491e7 --- README.md | 2 ++ defaults/main.yml | 4 ++-- tasks/overcloud-prep-images.yml | 1 - templates/overcloud-prep-images.sh.j2 | 30 +++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6a5bb14ca..463752efc 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ Role Variables - baremetal_instackenv: <"{{ working_dir }}/instackenv.json"> -- location of instackenv.json to copy over - baremetal_network_environment: <"{{ working_dir }}/network-isolation.yml"> -- location of network-environment file to copy over - undercloud_type: -- can be overwritten with values like 'baremetal' or 'ovb' +- step_root_device_size: -- add disk size hints if needed for the environment under test +- disk_root_device_size: <1843> -- size hint for selecting the correct disk during introspection Dependencies ------------ diff --git a/defaults/main.yml b/defaults/main.yml index c8901d31f..1f0450d7c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,5 +4,5 @@ overcloud_prep_images_log: "{{ working_dir }}/overcloud_prep_images.log" step_introspect: false bash_deploy_ramdisk: false step_install_undercloud: true - - +step_root_device_size: false +disk_root_device_size: 1843 diff --git a/tasks/overcloud-prep-images.yml b/tasks/overcloud-prep-images.yml index 9725d3887..da86b6a16 100644 --- a/tasks/overcloud-prep-images.yml +++ b/tasks/overcloud-prep-images.yml @@ -2,4 +2,3 @@ shell: | {{ working_dir }}/overcloud-prep-images.sh > \ {{ overcloud_prep_images_log }} 2>&1 - diff --git a/templates/overcloud-prep-images.sh.j2 b/templates/overcloud-prep-images.sh.j2 index a6e2a0bed..30a2da1dc 100644 --- a/templates/overcloud-prep-images.sh.j2 +++ b/templates/overcloud-prep-images.sh.j2 @@ -30,6 +30,36 @@ sudo systemctl restart openstack-ironic-conductor && sleep 30 openstack baremetal import --json instackenv.json openstack baremetal configure boot +{% if step_root_device_size|bool %} + +## * Get nodes UUID +## :: + +export items="$( ironic node-list | awk '/power/ {print $2}' )" + +## * Find disk size from instackenv.json +## :: + +export DISK_SIZE="$( jq '.["nodes"][]["disk"] | tonumber' instackenv.json )" + +## * Update nodes with disk size hint +## :: + +count=0 +ARRAY_DISK_SIZE=($(echo $DISK_SIZE)) +ROOT_DEVICE_SIZE={{ disk_root_device_size }} +for item in $items; do + if [ $ROOT_DEVICE_SIZE -ge ${ARRAY_DISK_SIZE[$count]} ]; then + declare i ADS + ADS=${ARRAY_DISK_SIZE[$count]} + ironic node-update $item add properties/root_device='{"size": '$ADS'}' + fi + count=$((count+1)) +done + +{% endif %} + + {% if step_introspect %} ## * Introspect hardware attributes of nodes.