1 from hp.hp_adapter import HpAdapter
2 from libvirt.libvirt_adapter import LibvirtAdapter
4 class DeploymentHardwareAdapter(object):
5 def __new__(cls, server_type, *args):
6 if cls is DeploymentHardwareAdapter:
7 if server_type == 'esxi': return EsxiAdapter(*args)
8 if server_type == 'hp': return HpAdapter(*args)
9 if server_type == 'dell': return DellAdapter(*args)
10 if server_type == 'libvirt': return LibvirtAdapter(*args)
11 return super(DeploymentHardwareAdapter, cls).__new__(cls)
14 class HardwareAdapter(object):
16 def power_off_blades(self, shelf, blade_list):
17 raise NotImplementedError
19 def power_off_blade(self, shelf, blade):
20 raise NotImplementedError
22 def power_on_blades(self, shelf, blade_list):
23 raise NotImplementedError
25 def power_on_blade(self, shelf, blade):
26 raise NotImplementedError
28 def power_cycle_blade(self):
29 raise NotImplementedError
31 def set_boot_order_blades(self, shelf, blade_list):
32 raise NotImplementedError
34 def set_boot_order_blade(self, shelf, blade):
35 raise NotImplementedError
37 def reset_to_factory_defaults(self):
38 raise NotImplementedError
40 def configure_networking(self):
41 raise NotImplementedError
43 def get_blade_mac_addresses(self, shelf, blade):
44 raise NotImplementedError
46 def get_hardware_info(self, shelf, blade):
47 raise NotImplementedError
50 class EsxiAdapter(HardwareAdapter):
53 self.environment = {1: {1: {'mac': ['00:50:56:8c:05:85']},
54 2: {'mac': ['00:50:56:8c:21:92']}}}
56 def get_blade_mac_addresses(self, shelf, blade):
57 return self.environment[shelf][blade]['mac']
60 class DellAdapter(HardwareAdapter):