Merge "Check a rule existence for a specific security group"
[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 sys
9
10 from functest.core import testcase
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 import functest.utils.functest_logger as ft_logger
15
16 """ logging configuration """
17 logger = ft_logger.Logger("refstack_defcore").getLogger()
18
19
20 class TempestConf(object):
21     def __init__(self):
22         self.VERIFIER_ID = conf_utils.get_verifier_id()
23         self.VERIFIER_REPO_DIR = conf_utils.get_verifier_repo_dir(
24             self.VERIFIER_ID)
25         self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id()
26         self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir(
27             self.VERIFIER_ID, self.DEPLOYMENT_ID)
28
29     def generate_tempestconf(self):
30         try:
31             openstack_utils.source_credentials(CONST.openstack_creds)
32             img_flavor_dict = conf_utils.create_tempest_resources(
33                 use_custom_images=True, use_custom_flavors=True)
34             conf_utils.configure_tempest_defcore(
35                 self.DEPLOYMENT_DIR, img_flavor_dict)
36         except KeyError as e:
37             logger.error("defcore prepare env error with: %s", e)
38
39     def main(self):
40         try:
41             self.generate_tempestconf()
42             res = testcase.TestCase.EX_OK
43         except Exception as e:
44             logger.error('Error with run: %s', e)
45             res = testcase.TestCase.EX_RUN_ERROR
46
47         return res
48
49 if __name__ == '__main__':
50     tempestconf = TempestConf()
51     result = tempestconf.main()
52     if result != testcase.TestCase.EX_OK:
53         sys.exit(result)