3 # Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
11 """configuration params to run snaps tests"""
15 import os_client_config
17 from xtesting.core import unit
19 from functest.opnfv_tests.openstack.snaps import snaps_utils
20 from functest.utils import config
21 from functest.utils import functest_utils
24 class SnapsTestRunner(unit.Suite):
25 # pylint: disable=too-many-instance-attributes
27 This test executes the SNAPS Python Tests
30 def __init__(self, **kwargs):
31 super(SnapsTestRunner, self).__init__(**kwargs)
32 self.logger = logging.getLogger(__name__)
33 self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
35 if 'ext_net_name' in kwargs:
36 self.ext_net_name = kwargs['ext_net_name']
38 self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
40 self.netconf_override = None
41 if hasattr(config.CONF, 'snaps_network_config'):
42 self.netconf_override = getattr(
43 config.CONF, 'snaps_network_config')
46 getattr(config.CONF, 'snaps_use_floating_ips') == 'True')
48 getattr(config.CONF, 'snaps_use_keystone') == 'True')
50 self.flavor_metadata = getattr(config.CONF, 'snaps_flavor_extra_specs',
52 self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)
54 self.image_metadata = None
55 if hasattr(config.CONF, 'snaps_images'):
56 self.image_metadata = getattr(config.CONF, 'snaps_images')
58 def check_requirements(self):
59 """Skip if OpenStack Rocky or newer."""
61 cloud_config = os_client_config.get_config()
62 cloud = shade.OpenStackCloud(cloud_config=cloud_config)
63 if functest_utils.get_nova_version(cloud) > (2, 60):
64 self.is_skipped = True
65 except Exception: # pylint: disable=broad-except