70327ff8954423fe327644b82a412ff5fcc0cf98
[functest.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 """configuration params to run snaps tests"""
12
13 import logging
14
15 from xtesting.core import unit
16
17 from functest.opnfv_tests.openstack.snaps import snaps_utils
18 from functest.utils import config
19
20
21 class SnapsTestRunner(unit.Suite):
22     # pylint: disable=too-many-instance-attributes
23     """
24     This test executes the SNAPS Python Tests
25     """
26
27     def __init__(self, **kwargs):
28         super(SnapsTestRunner, self).__init__(**kwargs)
29         self.logger = logging.getLogger(__name__)
30         self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
31
32         if 'ext_net_name' in kwargs:
33             self.ext_net_name = kwargs['ext_net_name']
34         else:
35             self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
36
37         self.netconf_override = None
38         if hasattr(config.CONF, 'snaps_network_config'):
39             self.netconf_override = getattr(
40                 config.CONF, 'snaps_network_config')
41
42         self.use_fip = (
43             getattr(config.CONF, 'snaps_use_floating_ips') == 'True')
44         self.use_keystone = (
45             getattr(config.CONF, 'snaps_use_keystone') == 'True')
46
47         self.flavor_metadata = getattr(config.CONF, 'snaps_flavor_extra_specs',
48                                        None)
49         self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)
50
51         self.image_metadata = None
52         if hasattr(config.CONF, 'snaps_images'):
53             self.image_metadata = getattr(config.CONF, 'snaps_images')