Modify TestCase constructor attributes
[functest.git] / functest / opnfv_tests / vnf / aaa / aaa.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2016 Orange and others.
4 #
5 # All rights reserved. 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 # http://www.apache.org/licenses/LICENSE-2.0
9
10 import sys
11
12 import argparse
13
14 import functest.core.testcase as testcase
15 import functest.core.vnf_base as vnf_base
16 import functest.utils.functest_logger as ft_logger
17
18
19 class AaaVnf(vnf_base.VnfOnBoardingBase):
20
21     logger = ft_logger.Logger("VNF AAA").getLogger()
22
23     def __init__(self, **kwargs):
24         if "case_name" not in kwargs:
25             kwargs["case_name"] = "aaa"
26         super(AaaVnf, self).__init__(**kwargs)
27
28     def deploy_orchestrator(self):
29         self.logger.info("No VNFM needed to deploy a free radius here")
30         return None
31
32 # TODO see how to use build in exception form releng module
33     def deploy_vnf(self):
34         self.logger.info("Freeradius VNF deployment")
35         # TODO apt-get update + config tuning
36         deploy_vnf = {}
37         deploy_vnf['status'] = "PASS"
38         deploy_vnf['result'] = {}
39         return deploy_vnf
40
41     def test_vnf(self):
42         self.logger.info("Run test towards freeradius")
43         # TODO:  once the freeradius is deployed..make some tests
44         test_vnf = {}
45         test_vnf['status'] = "PASS"
46         test_vnf['result'] = {}
47         return test_vnf
48
49     def main(self, **kwargs):
50         self.logger.info("AAA VNF onboarding")
51         self.execute()
52         if self.criteria is "PASS":
53             return self.EX_OK
54         else:
55             return self.EX_RUN_ERROR
56
57     def run(self):
58         kwargs = {}
59         return self.main(**kwargs)
60
61
62 if __name__ == '__main__':
63     parser = argparse.ArgumentParser()
64     args = vars(parser.parse_args())
65     aaa_vnf = AaaVnf()
66     try:
67         result = aaa_vnf.main(**args)
68         if result != testcase.TestCase.EX_OK:
69             sys.exit(result)
70         if args['pushtodb']:
71             sys.exit(aaa_vnf.push_to_db())
72     except Exception:
73         sys.exit(testcase.TestCase.EX_RUN_ERROR)