Merge "Obtain pod_name by CONST instead of get function"
[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 import functest_utils
14 from functest.utils.constants import CONST
15
16 from snaps.openstack import create_flavor
17 from snaps.openstack.tests import openstack_tests
18
19
20 class SnapsTestRunner(unit.Suite):
21     """
22     This test executes the SNAPS Python Tests
23     """
24     def __init__(self, **kwargs):
25         super(SnapsTestRunner, self).__init__(**kwargs)
26         self.logger = logging.getLogger(__name__)
27
28         if 'os_creds' in kwargs:
29             self.os_creds = kwargs['os_creds']
30         else:
31             creds_override = None
32             if hasattr(CONST, 'snaps_os_creds_override'):
33                 creds_override = CONST.__getattribute__(
34                     'snaps_os_creds_override')
35             self.os_creds = openstack_tests.get_credentials(
36                 os_env_file=CONST.__getattribute__('openstack_creds'),
37                 proxy_settings_str=None, ssh_proxy_cmd=None,
38                 overrides=creds_override)
39
40         if 'ext_net_name' in kwargs:
41             self.ext_net_name = kwargs['ext_net_name']
42         else:
43             self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
44
45         self.use_fip = CONST.__getattribute__('snaps_use_floating_ips')
46         self.use_keystone = CONST.__getattribute__('snaps_use_keystone')
47         scenario = functest_utils.get_scenario()
48
49         self.flavor_metadata = None
50         if 'ovs' in scenario or 'fdio' in scenario:
51             self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
52
53         self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)
54
55         self.image_metadata = None
56         if hasattr(CONST, 'snaps_images'):
57             self.image_metadata = CONST.__getattribute__('snaps_images')