a2dadb759eb51ea060233055ded9aa7b71ce9c7f
[functest-xtesting.git] / functest / opnfv_tests / openstack / snaps / snaps_test_runner.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
4 #
5 # This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10
11 # pylint: disable=missing-docstring
12
13 import logging
14
15 from functest.core import unit
16 from functest.opnfv_tests.openstack.snaps import snaps_utils
17 from functest.utils.constants import CONST
18
19 from snaps.openstack import create_flavor
20
21
22 class SnapsTestRunner(unit.Suite):
23     # pylint: disable=too-many-instance-attributes
24     """
25     This test executes the SNAPS Python Tests
26     """
27
28     def __init__(self, **kwargs):
29         super(SnapsTestRunner, self).__init__(**kwargs)
30         self.logger = logging.getLogger(__name__)
31         self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
32
33         if 'ext_net_name' in kwargs:
34             self.ext_net_name = kwargs['ext_net_name']
35         else:
36             self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
37
38         self.netconf_override = None
39         if hasattr(CONST, 'snaps_network_config'):
40             self.netconf_override = CONST.__getattribute__(
41                 'snaps_network_config')
42
43         self.use_fip = (
44             CONST.__getattribute__('snaps_use_floating_ips') == 'True')
45         self.use_keystone = (
46             CONST.__getattribute__('snaps_use_keystone') == 'True')
47         scenario = CONST.__getattribute__('DEPLOY_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')