Merge "docs: Mitaka Build req: Add p7zip-full."
[fuel.git] / 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 from dha_adapters.amt_adapter import AmtAdapter
18 from dha_adapters.zte_adapter import ZteAdapter
19
20 class DeploymentHardwareAdapter(object):
21
22     def __new__(cls, yaml_path):
23         with io.open(yaml_path) as yaml_file:
24             dha_struct = yaml.load(yaml_file)
25         type = dha_struct['adapter']
26
27         if cls is DeploymentHardwareAdapter:
28             if type == 'libvirt':
29                 return LibvirtAdapter(yaml_path)
30             if type == 'ipmi':
31                 return IpmiAdapter(yaml_path)
32             if type == 'hp':
33                 return HpAdapter(yaml_path)
34             if type == 'amt':
35                 return AmtAdapter(yaml_path)
36             if type == 'zte':
37                 return ZteAdapter(yaml_path)
38         return super(DeploymentHardwareAdapter, cls).__new__(cls)