aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/vnf/aaa/aaa.py
blob: 0030256c287b1a3e415c2734fe77fe57af43aac7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python

# Copyright (c) 2016 Orange and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0

import logging
import sys

import argparse

import functest.core.testcase as testcase
import functest.core.vnf as vnf


class AaaVnf(vnf.VnfOnBoarding):

    logger = logging.getLogger(__name__)

    def __init__(self, **kwargs):
        if "case_name" not in kwargs:
            kwargs["case_name"] = "aaa"
        super(AaaVnf, self).__init__(**kwargs)

    def deploy_orchestrator(self):
        self.logger.info("No VNFM needed to deploy a free radius here")
        return None

# TODO see how to use build in exception form releng module
    def deploy_vnf(self):
        self.logger.info("Freeradius VNF deployment")
        # TODO apt-get update + config tuning
        deploy_vnf = {}
        deploy_vnf['status'] = "PASS"
        deploy_vnf['result'] = {}
        return deploy_vnf

    def test_vnf(self):
        self.logger.info("Run test towards freeradius")
        # TODO:  once the freeradius is deployed..make some tests
        test_vnf = {}
        test_vnf['status'] = "PASS"
        test_vnf['result'] = {}
        return test_vnf

    def main(self, **kwargs):
        self.logger.info("AAA VNF onboarding")
        self.execute()
        if self.result is "PASS":
            return self.EX_OK
        else:
            return self.EX_RUN_ERROR

    def run(self):
        kwargs = {}
        return self.main(**kwargs)


if __name__ == '__main__':
    logging.basicConfig()
    parser = argparse.ArgumentParser()
    args = vars(parser.parse_args())
    aaa_vnf = AaaVnf()
    try:
        result = aaa_vnf.main(**args)
        if result != testcase.TestCase.EX_OK:
            sys.exit(result)
        if args['pushtodb']:
            sys.exit(aaa_vnf.push_to_db())
    except Exception:
        sys.exit(testcase.TestCase.EX_RUN_ERROR)