Merge "Add storperf reportign status page Create associated static storperf page...
[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.fuel import adapter as fuel_adapter
13 from opnfv.utils import opnfv_logger as logger
14
15 logger = logger.Logger(__name__).getLogger()
16
17
18 class Factory(object):
19
20     INSTALLERS = ["fuel", "apex", "compass", "joid", "daisy"]
21
22     def __init__(self):
23         pass
24
25     @staticmethod
26     def get_handler(installer,
27                     installer_ip,
28                     installer_user,
29                     installer_pwd=None,
30                     pkey_file=None):
31
32         if installer not in Factory.INSTALLERS:
33             raise Exception("This is not an OPNFV installer.")
34
35         if installer.lower() == "apex":
36             return apex_adapter.ApexAdapter(installer_ip=installer_ip,
37                                             installer_user=installer_user,
38                                             pkey_file=pkey_file)
39         elif installer.lower() == "fuel":
40             return fuel_adapter.FuelAdapter(installer_ip=installer_ip,
41                                             installer_user=installer_user,
42                                             installer_pwd=installer_pwd)
43         else:
44             raise Exception("Installer adapter is not implemented for "
45                             "the given installer.")