summaryrefslogtreecommitdiffstats
path: root/utils/openstack_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/openstack_utils.py')
-rwxr-xr-xutils/openstack_utils.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py
index ff9b54a58..8c2e00cb1 100755
--- a/utils/openstack_utils.py
+++ b/utils/openstack_utils.py
@@ -16,6 +16,7 @@ import time
from cinderclient import client as cinderclient
import functest.utils.functest_logger as ft_logger
+import functest.utils.functest_utils as ft_utils
from glanceclient import client as glanceclient
from keystoneclient.v2_0 import client as keystoneclient
from neutronclient.v2_0 import client as neutronclient
@@ -235,6 +236,14 @@ def get_hypervisors(nova_client):
def create_flavor(nova_client, flavor_name, ram, disk, vcpus):
try:
flavor = nova_client.flavors.create(flavor_name, ram, vcpus, disk)
+ try:
+ extra_specs = ft_utils.get_functest_config(
+ 'general.flavor_extra_specs')
+ flavor.update(extra_specs)
+ except ValueError:
+ # flavor extra specs are not configured, therefore skip the update
+ pass
+
except Exception, e:
logger.error("Error [create_flavor(nova_client, '%s', '%s', '%s', "
"'%s')]: %s" % (flavor_name, ram, disk, vcpus, e))
@@ -902,11 +911,19 @@ def create_glance_image(glance_client, image_name, file_path, disk="qcow2",
if logger:
logger.info("Creating image '%s' from '%s'..." % (image_name,
file_path))
+ try:
+ properties = ft_utils.get_functest_config(
+ 'general.image_properties')
+ except ValueError:
+ # image properties are not configured
+ # therefore don't add any properties
+ properties = {}
with open(file_path) as fimage:
image = glance_client.images.create(name=image_name,
is_public=public,
disk_format=disk,
container_format=container,
+ properties=properties,
data=fimage)
image_id = image.id
return image_id