summaryrefslogtreecommitdiffstats
path: root/fuel/deploy/dha.py
blob: 87ac6e26d50d22c363d8803e6da40cb4a4325f6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from hardware_adapters.hp.hp_adapter import HpAdapter

class DeploymentHardwareAdapter(object):
    def __new__(cls, server_type, *args):
        if cls is DeploymentHardwareAdapter:
            if server_type == 'esxi':  return EsxiAdapter(*args)
            if server_type == 'hp': return HpAdapter(*args)
            if server_type == 'dell': return DellAdapter(*args)
            if server_type == 'libvirt': return LibvirtAdapter(*args)
        return super(DeploymentHardwareAdapter, cls).__new__(cls)


class HardwareAdapter(object):

    def power_off_blades(self, shelf, blade_list):
        raise NotImplementedError

    def power_off_blade(self, shelf, blade):
        raise NotImplementedError

    def power_on_blades(self, shelf, blade_list):
        raise NotImplementedError

    def power_on_blade(self, shelf, blade):
        raise NotImplementedError

    def power_cycle_blade(self):
        raise NotImplementedError

    def set_boot_order_blades(self, shelf, blade_list):
        raise NotImplementedError

    def set_boot_order_blade(self, shelf, blade):
        raise NotImplementedError

    def reset_to_factory_defaults(self):
        raise NotImplementedError

    def configure_networking(self):
        raise NotImplementedError

    def get_blade_mac_addresses(self, shelf, blade):
        raise NotImplementedError

    def get_hardware_info(self, shelf, blade):
        raise NotImplementedError


class EsxiAdapter(HardwareAdapter):

    def __init__(self):
        self.environment = {1: {1: {'mac': ['00:50:56:8c:05:85']},
                                2: {'mac': ['00:50:56:8c:21:92']}}}

    def get_blade_mac_addresses(self, shelf, blade):
        return self.environment[shelf][blade]['mac']

class LibvirtAdapter(HardwareAdapter):
    pass

class DellAdapter(HardwareAdapter):
    pass