Merge "Remove tacker library from functest"
[functest.git] / functest / opnfv_tests / openstack / snaps / snaps_test_runner.py
1 # Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
2 #
3 # This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8
9 import logging
10
11 from functest.core import unit
12 from functest.opnfv_tests.openstack.snaps import snaps_utils
13 from functest.utils.constants import CONST
14
15 from snaps.openstack import create_flavor
16 from snaps.openstack.tests import openstack_tests
17
18
19 class SnapsTestRunner(unit.Suite):
20     """
21     This test executes the SNAPS Python Tests
22     """
23     def __init__(self, **kwargs):
24         super(SnapsTestRunner, self).__init__(**kwargs)
25         self.logger = logging.getLogger(__name__)
26
27         if 'os_creds' in kwargs:
28             self.os_creds = kwargs['os_creds']
29         else:
30             creds_override = None
31             if hasattr(CONST, 'snaps_os_creds_override'):
32                 creds_override = CONST.__getattribute__(
33                     'snaps_os_creds_override')
34             self.os_creds = openstack_tests.get_credentials(
35                 os_env_file=CONST.__getattribute__('openstack_creds'),
36                 proxy_settings_str=None, ssh_proxy_cmd=None,
37                 overrides=creds_override)
38
39         if 'ext_net_name' in kwargs:
40             self.ext_net_name = kwargs['ext_net_name']
41         else:
42             self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
43
44         self.use_fip = CONST.__getattribute__('snaps_use_floating_ips')
45         self.use_keystone = CONST.__getattribute__('snaps_use_keystone')
46         scenario = CONST.__getattribute__('DEPLOY_SCENARIO')
47
48         self.flavor_metadata = None
49         if 'ovs' in scenario or 'fdio' in scenario:
50             self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
51
52         self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)
53
54         self.image_metadata = None
55         if hasattr(CONST, 'snaps_images'):
56             self.image_metadata = CONST.__getattribute__('snaps_images')