Add a new adapter for containerized Compass installer
[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_container 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.deployment.daisy import adapter as daisy_adapter
16 from opnfv.utils import opnfv_logger as logger
17
18 logger = logger.Logger(__name__).getLogger()
19
20
21 class Factory(object):
22
23     INSTALLERS = ["fuel", "apex", "compass", "joid", "daisy", "osa"]
24
25     def __init__(self):
26         pass
27
28     @staticmethod
29     def get_handler(installer,
30                     installer_ip,
31                     installer_user,
32                     installer_pwd=None,
33                     pkey_file=None):
34
35         if installer not in Factory.INSTALLERS:
36             raise Exception("This is not an OPNFV installer.")
37
38         if installer.lower() == "apex":
39             return apex_adapter.ApexAdapter(installer_ip=installer_ip,
40                                             installer_user=installer_user,
41                                             pkey_file=pkey_file)
42         elif installer.lower() == "fuel":
43             return fuel_adapter.FuelAdapter(installer_ip=installer_ip,
44                                             installer_user=installer_user,
45                                             installer_pwd=installer_pwd)
46         elif installer.lower() == "compass":
47             return compass_adapter.ContainerizedCompassAdapter(
48                 installer_ip=installer_ip,
49                 installer_user=installer_user,
50                 pkey_file=pkey_file)
51         elif installer.lower() == "osa":
52             return osa_adapter.OSAAdapter(installer_ip=installer_ip,
53                                           installer_user=installer_user,
54                                           pkey_file=pkey_file)
55         elif installer.lower() == "daisy":
56             return daisy_adapter.DaisyAdapter(installer_ip=installer_ip,
57                                               installer_user=installer_user,
58                                               installer_pwd=installer_pwd)
59         else:
60             raise Exception("Installer adapter is not implemented for "
61                             "the given installer.")