Restructcture of the directory layout
[fuel.git] / deploy / execution_environment.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 import os
14
15 from environments.libvirt_environment import LibvirtEnvironment
16 from environments.virtual_fuel import VirtualFuel
17
18
19 class ExecutionEnvironment(object):
20
21     def __new__(cls, storage_dir, pxe_bridge, dha_path, dea):
22
23         with io.open(dha_path) as yaml_file:
24             dha_struct = yaml.load(yaml_file)
25
26         type = dha_struct['adapter']
27
28         root_dir = os.path.dirname(os.path.realpath(__file__))
29
30         if cls is ExecutionEnvironment:
31             if type == 'libvirt':
32                 return LibvirtEnvironment(storage_dir, dha_path, dea, root_dir)
33
34             if type in ['ipmi', 'hp', 'amt']:
35                 return VirtualFuel(storage_dir, pxe_bridge, dha_path, root_dir)
36
37         return super(ExecutionEnvironment, cls).__new__(cls)