Installer adapters
[releng.git] / utils / installer-adapter / InstallerHandler.py
1 ##############################################################################
2 # Copyright (c) 2015 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 from FuelAdapter import FuelAdapter
11 from ApexAdapter import ApexAdapter
12 from CompassAdapter import CompassAdapter
13 from JoidAdapter import JoidAdapter
14
15
16 INSTALLERS = ["fuel", "apex", "compass", "joid"]
17
18
19 class InstallerHandler:
20
21     def __init__(self,
22                  installer,
23                  installer_ip,
24                  installer_user,
25                  installer_pwd=None):
26         self.installer = installer.lower()
27         self.installer_ip = installer_ip
28         self.installer_user = installer_user
29         self.installer_pwd = installer_pwd
30
31         if self.installer == INSTALLERS[0]:
32             self.InstallerAdapter = FuelAdapter(self.installer_ip,
33                                                 self.installer_user,
34                                                 self.installer_pwd)
35         elif self.installer == INSTALLERS[1]:
36             self.InstallerAdapter = ApexAdapter(self.installer_ip)
37         elif self.installer == INSTALLERS[2]:
38             self.InstallerAdapter = CompassAdapter(self.installer_ip)
39         elif self.installer == INSTALLERS[3]:
40             self.InstallerAdapter = JoidAdapter(self.installer_ip)
41         else:
42             print("Installer %s is  not valid. "
43                   "Please use one of the followings: %s"
44                   % (self.installer, INSTALLERS))
45             exit(1)
46
47     def get_deployment_info(self):
48         return self.InstallerAdapter.get_deployment_info()
49
50     def get_nodes(self, options=None):
51         return self.InstallerAdapter.get_nodes(options=options)
52
53     def get_controller_ips(self, options=None):
54         return self.InstallerAdapter.get_controller_ips(options=options)
55
56     def get_compute_ips(self, options=None):
57         return self.InstallerAdapter.get_compute_ips(options=options)
58
59     def get_file_from_installer(self,
60                                 remote_path,
61                                 local_path,
62                                 options=None):
63         return self.InstallerAdapter.get_file_from_installer(remote_path,
64                                                              local_path,
65                                                              options=options)
66
67     def get_file_from_controller(self,
68                                  remote_path,
69                                  local_path,
70                                  ip=None,
71                                  options=None):
72         return self.InstallerAdapter.get_file_from_controller(remote_path,
73                                                               local_path,
74                                                               ip=ip,
75                                                               options=options)
76
77     def get_all(self):
78         pass