image_file_name: cirros-0.3.4-x86_64-disk.img
image_disk_format: qcow2
+ flavor_name: opnfv_flavor
+ flavor_ram: 512
+ flavor_disk: 1
+ flavor_vcpus: 1
+
# Private network for functest. Will be created by config_functest.py
neutron_private_net_name: functest-net
neutron_private_subnet_name: functest-subnet
private_subnet_name: tempest-subnet
private_subnet_cidr: 192.168.150.0/24
router_name: tempest-router
+ use_custom_images: False
+ use_custom_flavors: False
rally:
deployment_name: opnfv-rally
fdio:
general:
flavor_extra_specs: {'hw:mem_page_size':'large'}
- image_properties: {'hw_mem_page_size':'large'}
\ No newline at end of file
+ image_properties: {'hw_mem_page_size':'large'}
+ tempest:
+ use_custom_images: True
+ use_custom_flavors: True
\ No newline at end of file
GLANCE_IMAGE_PATH = \
ft_utils.get_functest_config('general.directories.dir_functest_data') + \
"/" + GLANCE_IMAGE_FILENAME
+IMAGE_ID = None
+IMAGE_ID_ALT = None
+
+FLAVOR_NAME = \
+ ft_utils.get_functest_config('general.openstack.flavor_name')
+FLAVOR_RAM = ft_utils.get_functest_config('general.openstack.flavor_ram')
+FLAVOR_DISK = ft_utils.get_functest_config('general.openstack.flavor_disk')
+FLAVOR_VCPUS = ft_utils.get_functest_config('general.openstack.flavor_vcpus')
+FLAVOR_ID = None
+FLAVOR_ID_ALT = None
PRIVATE_NET_NAME = \
ft_utils.get_functest_config('tempest.private_net_name')
ft_utils.get_functest_config('tempest.identity.user_password')
SSH_TIMEOUT = \
ft_utils.get_functest_config('tempest.validation.ssh_timeout')
+USE_CUSTOM_IMAGES = \
+ ft_utils.get_functest_config('tempest.use_custom_images')
+USE_CUSTOM_FLAVORS = \
+ ft_utils.get_functest_config('tempest.use_custom_flavors')
+
DEPLOYMENT_MAME = \
ft_utils.get_functest_config('rally.deployment_name')
RALLY_INSTALLATION_DIR = \
if not network_dic:
exit(1)
- logger.debug("Creating image for Tempest suite")
- _, image_id = os_utils.get_or_create_image(GLANCE_IMAGE_NAME,
- GLANCE_IMAGE_PATH,
- GLANCE_IMAGE_FORMAT)
- if not image_id:
- exit(-1)
+ if USE_CUSTOM_IMAGES:
+ # adding alternative image should be trivial should we need it
+ logger.debug("Creating image for Tempest suite")
+ global IMAGE_ID
+ _, IMAGE_ID = os_utils.get_or_create_image(GLANCE_IMAGE_NAME,
+ GLANCE_IMAGE_PATH,
+ GLANCE_IMAGE_FORMAT)
+ if not IMAGE_ID:
+ exit(-1)
+
+ if USE_CUSTOM_FLAVORS:
+ # adding alternative flavor should be trivial should we need it
+ logger.debug("Creating flavor for Tempest suite")
+ global FLAVOR_ID
+ _, FLAVOR_ID = os_utils.get_or_create_flavor(FLAVOR_NAME,
+ FLAVOR_RAM,
+ FLAVOR_DISK,
+ FLAVOR_VCPUS)
+ if not FLAVOR_ID:
+ exit(-1)
def configure_tempest(deployment_dir):
config = ConfigParser.RawConfigParser()
config.read(tempest_conf_file)
config.set('compute', 'fixed_network_name', PRIVATE_NET_NAME)
+ if USE_CUSTOM_IMAGES:
+ if IMAGE_ID is not None:
+ config.set('compute', 'image_ref', IMAGE_ID)
+ if IMAGE_ID_ALT is not None:
+ config.set('compute', 'image_ref_alt', IMAGE_ID_ALT)
+ if USE_CUSTOM_FLAVORS:
+ if FLAVOR_ID is not None:
+ config.set('compute', 'flavor_ref', FLAVOR_ID)
+ if FLAVOR_ID_ALT is not None:
+ config.set('compute', 'flavor_ref_alt', FLAVOR_ID_ALT)
config.set('identity', 'tenant_name', TENANT_NAME)
config.set('identity', 'username', USER_NAME)
config.set('identity', 'password', USER_PASSWORD)
return id
+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.set_keys(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))
+ return None
+ return flavor.id
+
+
+def get_or_create_flavor(flavor_name, ram, disk, vcpus):
+ flavor_exists = False
+ nova_client = get_nova_client()
+
+ flavor_id = get_flavor_id(nova_client, flavor_name)
+ if flavor_id != '':
+ logger.info("Using existing flavor '%s'..." % flavor_name)
+ flavor_exists = True
+ else:
+ logger.info("Creating flavor '%s' with '%s' RAM, '%s' disk size, "
+ "'%s' vcpus..." % (flavor_name, ram, disk, vcpus))
+ flavor_id = create_flavor(nova_client, flavor_name, ram, disk, vcpus)
+ if not flavor_id:
+ logger.error("Failed to create flavor '%s'..." % (flavor_name))
+ else:
+ logger.debug("Flavor '%s' with ID=%s created successfully."
+ % (flavor_name, flavor_id))
+
+ return flavor_exists, flavor_id
+
+
def get_floating_ips(nova_client):
try:
floating_ips = nova_client.floating_ips.list()
return None
-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.set_keys(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))
- return None
- return flavor.id
-
-
def create_instance(flavor_name,
image_id,
network_id,