summaryrefslogtreecommitdiffstats
path: root/modules/opnfv/deployment/factory.py
blob: 2788e5eaad391ac2b2bedb7735443f9cb8e05166 (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
##############################################################################
# Copyright (c) 2017 Ericsson AB and others.
# Author: Jose Lausuch (jose.lausuch@ericsson.com)
# 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
##############################################################################


from opnfv.deployment.apex import adapter as apex_adapter
from opnfv.deployment.compass import adapter as compass_adapter
from opnfv.deployment.fuel import adapter as fuel_adapter
from opnfv.deployment.osa import adapter as osa_adapter
from opnfv.deployment.daisy import adapter as daisy_adapter
from opnfv.utils import opnfv_logger as logger

logger = logger.Logger(__name__).getLogger()


class Factory(object):

    INSTALLERS = ["fuel", "apex", "compass", "joid", "daisy", "osa"]

    def __init__(self):
        pass

    @staticmethod
    def get_handler(installer,
                    installer_ip,
                    installer_user,
                    installer_pwd=None,
                    pkey_file=None):

        if installer not in Factory.INSTALLERS:
            raise Exception("This is not an OPNFV installer.")

        if installer.lower() == "apex":
            return apex_adapter.ApexAdapter(installer_ip=installer_ip,
                                            installer_user=installer_user,
                                            pkey_file=pkey_file)
        elif installer.lower() == "fuel":
            return fuel_adapter.FuelAdapter(installer_ip=installer_ip,
                                            installer_user=installer_user,
                                            installer_pwd=installer_pwd)
        elif installer.lower() == "compass":
            return compass_adapter.CompassAdapter(
                installer_ip=installer_ip,
                installer_user=installer_user,
                installer_pwd=installer_pwd)
        elif installer.lower() == "osa":
            return osa_adapter.OSAAdapter(installer_ip=installer_ip,
                                          installer_user=installer_user,
                                          pkey_file=pkey_file)
        elif installer.lower() == "daisy":
            return daisy_adapter.DaisyAdapter(installer_ip=installer_ip,
                                              installer_user=installer_user,
                                              installer_pwd=installer_pwd)
        else:
            raise Exception("Installer adapter is not implemented for "
                            "the given installer.")