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 ###############################################################################
16 from environments.libvirt_environment import LibvirtEnvironment
17 from environments.virtual_fuel import VirtualFuel
19 exec_cmd = common.exec_cmd
22 check_dir_exists = common.check_dir_exists
23 check_file_exists = common.check_file_exists
24 check_if_root = common.check_if_root
25 ArgParser = common.ArgParser
28 class ExecutionEnvironment(object):
30 def __new__(cls, storage_dir, pxe_bridge, dha_path, dea):
32 with io.open(dha_path) as yaml_file:
33 dha_struct = yaml.load(yaml_file)
35 type = dha_struct['adapter']
37 root_dir = os.path.dirname(os.path.realpath(__file__))
39 if cls is ExecutionEnvironment:
41 return LibvirtEnvironment(storage_dir, dha_path, dea, root_dir)
43 if type == 'ipmi' or type == 'hp':
44 return VirtualFuel(storage_dir, pxe_bridge, dha_path, root_dir)
46 return super(ExecutionEnvironment, cls).__new__(cls)