3 # matthew.lijun@huawei.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
11 from functest.opnfv_tests.openstack.tempest import conf_utils
12 from functest.utils import openstack_utils
13 from functest.utils.constants import CONST
14 from functest.opnfv_tests.openstack.tempest.tempest \
15 import TempestResourcesManager
17 """ logging configuration """
18 logger = logging.getLogger(__name__)
21 class TempestConf(object):
22 def __init__(self, **kwargs):
23 self.VERIFIER_ID = conf_utils.get_verifier_id()
24 self.VERIFIER_REPO_DIR = conf_utils.get_verifier_repo_dir(
26 self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id()
27 self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir(
28 self.VERIFIER_ID, self.DEPLOYMENT_ID)
29 self.confpath = pkg_resources.resource_filename(
31 'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
32 self.resources = TempestResourcesManager(**kwargs)
34 def generate_tempestconf(self):
36 openstack_utils.source_credentials(
37 CONST.__getattribute__('openstack_creds'))
38 resources = self.resources.create(create_project=True,
39 use_custom_images=True,
40 use_custom_flavors=True)
41 conf_utils.configure_tempest_defcore(
43 image_id=resources.get("image_id"),
44 flavor_id=resources.get("flavor_id"),
45 image_id_alt=resources.get("image_id_alt"),
46 flavor_id_alt=resources.get("flavor_id_alt"),
47 tenant_id=resources.get("project_id"))
48 except Exception as e:
49 logger.error("error with generating refstack client "
50 "reference tempest conf file: %s", e)
54 self.generate_tempestconf()
55 logger.info("a reference tempest conf file generated "
56 "at %s", self.confpath)
57 except Exception as e:
58 logger.error('Error with run: %s', e)
61 self.resources.cleanup()
66 tempestconf = TempestConf()