Merge "Add OSA adapter for XCI"
[releng.git] / modules / opnfv / deployment / factory.py
1 ##############################################################################
2 # Copyright (c) 2017 Ericsson AB and others.
3 # Author: Jose Lausuch (jose.lausuch@ericsson.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 ##############################################################################
9
10
11 from opnfv.deployment.apex import adapter as apex_adapter
12 from opnfv.deployment.compass import adapter as compass_adapter
13 from opnfv.deployment.fuel import adapter as fuel_adapter
14 from opnfv.deployment.OSA import adapter as osa_adapter
15 from opnfv.utils import opnfv_logger as logger
16
17 logger = logger.Logger(__name__).getLogger()
18
19
20 class Factory(object):
21
22     INSTALLERS = ["fuel", "apex", "compass", "joid", "daisy", "OSA"]
23
24     def __init__(self):
25         pass
26
27     @staticmethod
28     def get_handler(installer,
29                     installer_ip,
30                     installer_user,
31                     installer_pwd=None,
32                     pkey_file=None):
33
34         if installer not in Factory.INSTALLERS:
35             raise Exception("This is not an OPNFV installer.")
36
37         if installer.lower() == "apex":
38             return apex_adapter.ApexAdapter(installer_ip=installer_ip,
39                                             installer_user=installer_user,
40                                             pkey_file=pkey_file)
41         elif installer.lower() == "fuel":
42             return fuel_adapter.FuelAdapter(installer_ip=installer_ip,
43                                             installer_user=installer_user,
44                                             installer_pwd=installer_pwd)
45         elif installer.lower() == "compass":
46             return compass_adapter.CompassAdapter(
47                 installer_ip=installer_ip,
48                 installer_user=installer_user,
49                 installer_pwd=installer_pwd)
50         elif installer.lower() == "osa":
51             return osa_adapter.OSAAdapter(installer_ip=installer_ip,
52                                           installer_user=installer_user,
53                                           pkey_file=pkey_file)
54         else:
55             raise Exception("Installer adapter is not implemented for "
56                             "the given installer.")