Merge "Add VnfOnBoarding Abstraction"
[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_base as testcase_base
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):
24         super(AaaVnf, self).__init__()
25         self.case_name = "aaa"
26
27     def deploy_orchestrator(self):
28         self.logger.info("No VNFM needed to deploy a free radius here")
29         return None
30
31 # TODO see how to use build in exception form releng module
32     def deploy_vnf(self):
33         self.logger.info("Freeradius VNF deployment")
34         # TODO apt-get update + config tuning
35         deploy_vnf = {}
36         deploy_vnf['status'] = "PASS"
37         deploy_vnf['result'] = {}
38         return deploy_vnf
39
40     def test_vnf(self):
41         self.logger.info("Run test towards freeradius")
42         # TODO:  once the freeradius is deployed..make some tests
43         test_vnf = {}
44         test_vnf['status'] = "PASS"
45         test_vnf['result'] = {}
46         return test_vnf
47
48     def main(self, **kwargs):
49         self.logger.info("AAA VNF onboarding")
50         self.execute()
51         if self.criteria is "PASS":
52             return self.EX_OK
53         else:
54             return self.EX_RUN_ERROR
55
56     def run(self):
57         kwargs = {}
58         return self.main(**kwargs)
59
60 if __name__ == '__main__':
61     parser = argparse.ArgumentParser()
62     args = vars(parser.parse_args())
63     aaa_vnf = AaaVnf()
64     try:
65         result = aaa_vnf.main(**args)
66         if result != testcase_base.TestcaseBase.EX_OK:
67             sys.exit(result)
68         if args['pushtodb']:
69             sys.exit(aaa_vnf.push_to_db())
70     except Exception:
71         sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR)