Updates docs for SR1 with final revision
[genesis.git] / fuel / deploy / dha.py
1 ###############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # szilard.cserey@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 import yaml
12 import io
13
14 from dha_adapters.libvirt_adapter import LibvirtAdapter
15 from dha_adapters.ipmi_adapter import IpmiAdapter
16 from dha_adapters.hp_adapter import HpAdapter
17
18
19 class DeploymentHardwareAdapter(object):
20
21     def __new__(cls, yaml_path):
22         with io.open(yaml_path) as yaml_file:
23             dha_struct = yaml.load(yaml_file)
24         type = dha_struct['adapter']
25
26         if cls is DeploymentHardwareAdapter:
27             if type == 'libvirt':
28                 return LibvirtAdapter(yaml_path)
29             if type == 'ipmi':
30                 return IpmiAdapter(yaml_path)
31             if type == 'hp':
32                 return HpAdapter(yaml_path)
33
34         return super(DeploymentHardwareAdapter, cls).__new__(cls)