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
This commit is contained in:
Ronelle Landy 2016-11-08 17:11:00 -05:00
parent 173ee4dcd1
commit c1e2197113
4 changed files with 34 additions and 3 deletions

View File

@ -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: <virtual> -- can be overwritten with values like 'baremetal' or 'ovb'
- step_root_device_size: <false> -- 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
------------

View File

@ -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

View File

@ -2,4 +2,3 @@
shell: |
{{ working_dir }}/overcloud-prep-images.sh > \
{{ overcloud_prep_images_log }} 2>&1

View File

@ -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.