customize_advanced_image(){ # Here we customize an advanced image to make it suitable for the plugin tests. # Note: the advanced image was downloaded and set by neutron_tempest_plugin. # However we can't rely on neutron_tempest_plugin capabilities for customizing # the image since it expects a debian/ubuntu based image which does not fit well # to this plugin tests. # This code modifies the downloaded image by adding packages required by this # plugin, uploads the image to glance and if all passed successfully it updates # tempest.conf with the new image reference instead of the original one. install_package guestfs-tools for image_url in ${IMAGE_URLS//,/ }; do if [[ $image_url =~ $ADVANCED_IMAGE_NAME ]]; then image_file=$(basename $image_url) break fi done if [ -n "$image_file" ] && [ -s "$TOP_DIR/files/$image_file" ]; then cp -f $TOP_DIR/files/$image_file /tmp image_file_custom=/tmp/$image_file timeout 150 sudo virt-customize -a $image_file_custom --install nmap,python3,keepalived,iperf3 --selinux-relabel if [ "$?" == "0" ]; then source $TOP_DIR/openrc admin old_image_id=$(openstack image show $ADVANCED_IMAGE_NAME -c id -f value) new_image_id=$(openstack image create --disk-format qcow2 --container-format bare --public $ADVANCED_IMAGE_NAME --file $image_file_custom -c id -f value) if [ -n "$new_image_id" ]; then iniset $TEMPEST_CONFIG neutron_plugin_options advanced_image_ref $new_image_id openstack image delete $old_image_id fi fi fi } if [[ "$1" == "stack" ]]; then case "$2" in install) if [[ "$INSTALL_TEMPEST" == "True" ]]; then echo "tempest ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/99_tempest fi ;; test-config) customize_advanced_image ;; esac fi