Set non-0 disk sizes for tempest flavors
Nova change https://review.openstack.org/603910/ is going to change the default rule on policy os_compute_api:servers:create:zero_disk_flavor to admin-only, which will prevent non-admins from creating image-backed servers with a flavor that has disk=0 since it's a potential security exposure. Therefore we need the test flavors that are created for tempest to use non-0 disk values. Since the flavor_ref and flavor_ref_alt can be aligned to the image_ref and image_ref_alt in tempest.conf, we get the image sizes from glance (in bytes) and convert those to GiB disk sizes for each flavor, respectively. Since we're using Cirros images by default, we need to make sure to round up otherwise we'd still have a 0-disk flavor. There are lots of ways the math could be done here using numfmt, bash, awk, bc, etc, but it's simplest to write and probably easiest to read by using python for the size conversion code. Change-Id: I537c299b0cd400982189f35b31df74755422737e Related-Bug: #1739646
This commit is contained in:
parent
0c6208c6a0
commit
23d33a8b5b
17
lib/tempest
17
lib/tempest
@ -102,6 +102,14 @@ function remove_disabled_extensions {
|
||||
remove_disabled_services "$extensions_list" "$disabled_exts"
|
||||
}
|
||||
|
||||
# image_size_in_gib - converts an image size from bytes to GiB, rounded up
|
||||
# Takes an image ID parameter as input
|
||||
function image_size_in_gib {
|
||||
local size
|
||||
size=$(openstack image show $1 -c size -f value)
|
||||
echo $size | python -c "import math; print int(math.ceil(float(int(raw_input()) / 1024.0 ** 3)))"
|
||||
}
|
||||
|
||||
# configure_tempest() - Set config files, create data dirs, etc
|
||||
function configure_tempest {
|
||||
if [[ "$INSTALL_TEMPEST" == "True" ]]; then
|
||||
@ -125,6 +133,7 @@ function configure_tempest {
|
||||
local public_network_id
|
||||
local public_router_id
|
||||
local ssh_connect_method="floating"
|
||||
local disk
|
||||
|
||||
# Save IFS
|
||||
ifs=$IFS
|
||||
@ -190,11 +199,15 @@ function configure_tempest {
|
||||
available_flavors=$(nova flavor-list)
|
||||
if [[ -z "$DEFAULT_INSTANCE_TYPE" ]]; then
|
||||
if [[ ! ( $available_flavors =~ 'm1.nano' ) ]]; then
|
||||
openstack flavor create --id 42 --ram 64 --disk 0 --vcpus 1 m1.nano
|
||||
# Determine the flavor disk size based on the image size.
|
||||
disk=$(image_size_in_gib $image_uuid)
|
||||
openstack flavor create --id 42 --ram 64 --disk $disk --vcpus 1 m1.nano
|
||||
fi
|
||||
flavor_ref=42
|
||||
if [[ ! ( $available_flavors =~ 'm1.micro' ) ]]; then
|
||||
openstack flavor create --id 84 --ram 128 --disk 0 --vcpus 1 m1.micro
|
||||
# Determine the alt flavor disk size based on the alt image size.
|
||||
disk=$(image_size_in_gib $image_uuid_alt)
|
||||
openstack flavor create --id 84 --ram 128 --disk $disk --vcpus 1 m1.micro
|
||||
fi
|
||||
flavor_ref_alt=84
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user