Merge "Revert "Cleanup dirty daisy build workspace directory""
[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.utils import opnfv_logger as logger
15
16 logger = logger.Logger(__name__).getLogger()
17
18
19 class Factory(object):
20
21     INSTALLERS = ["fuel", "apex", "compass", "joid", "daisy"]
22
23     def __init__(self):
24         pass
25
26     @staticmethod
27     def get_handler(installer,
28                     installer_ip,
29                     installer_user,
30                     installer_pwd=None,
31                     pkey_file=None):
32
33         if installer not in Factory.INSTALLERS:
34             raise Exception("This is not an OPNFV installer.")
35
36         if installer.lower() == "apex":
37             return apex_adapter.ApexAdapter(installer_ip=installer_ip,
38                                             installer_user=installer_user,
39                                             pkey_file=pkey_file)
40         elif installer.lower() == "fuel":
41             return fuel_adapter.FuelAdapter(installer_ip=installer_ip,
42                                             installer_user=installer_user,
43                                             installer_pwd=installer_pwd)
44         elif installer.lower() == "compass":
45             return compass_adapter.CompassAdapter(
46                 installer_ip=installer_ip,
47                 installer_user=installer_user,
48                 installer_pwd=installer_pwd)
49         else:
50             raise Exception("Installer adapter is not implemented for "
51                             "the given installer.")