Merge "Ignore .tox"
[functest.git] / functest / opnfv_tests / openstack / refstack_client / tempest_conf.py
1 #!/usr/bin/env python
2
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
8 import logging
9 import os
10
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
15 """ logging configuration """
16 logger = logging.getLogger(__name__)
17
18
19 class TempestConf(object):
20     def __init__(self):
21         self.VERIFIER_ID = conf_utils.get_verifier_id()
22         self.VERIFIER_REPO_DIR = conf_utils.get_verifier_repo_dir(
23             self.VERIFIER_ID)
24         self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id()
25         self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir(
26             self.VERIFIER_ID, self.DEPLOYMENT_ID)
27         self.confpath = os.path.join(
28             CONST.__getattribute__('dir_functest_test'),
29             CONST.__getattribute__('refstack_tempest_conf_path'))
30
31     def generate_tempestconf(self):
32         try:
33             openstack_utils.source_credentials(
34                 CONST.__getattribute__('openstack_creds'))
35             img_flavor_dict = conf_utils.create_tempest_resources(
36                 use_custom_images=True, use_custom_flavors=True)
37             conf_utils.configure_tempest_defcore(
38                 self.DEPLOYMENT_DIR, img_flavor_dict)
39         except Exception as e:
40             logger.error("error with generating refstack client "
41                          "reference tempest conf file: %s", e)
42
43     def main(self):
44         try:
45             self.generate_tempestconf()
46             logger.info("a reference tempest conf file generated "
47                         "at %s", self.confpath)
48         except Exception as e:
49             logger.error('Error with run: %s', e)
50
51
52 if __name__ == '__main__':
53     logging.basicConfig()
54     tempestconf = TempestConf()
55     tempestconf.main()