From 0d4a1f4143d71fc616f456a3708d5c8c2a24ec3f Mon Sep 17 00:00:00 2001 From: Jonas Bjurel Date: Fri, 2 Oct 2015 13:29:56 +0200 Subject: Move of genesis/fuel master branch: commit 563547b4a9f44090f32c0e17d040114854563760 Note: other installers and /common are removed Change-Id: Ie5a2b0b7f3e7fa2eda191710c98456eeec17ed61 Signed-off-by: Jonas Bjurel --- fuel/deploy/execution_environment.py | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 fuel/deploy/execution_environment.py (limited to 'fuel/deploy/execution_environment.py') diff --git a/fuel/deploy/execution_environment.py b/fuel/deploy/execution_environment.py new file mode 100644 index 000000000..e671463e4 --- /dev/null +++ b/fuel/deploy/execution_environment.py @@ -0,0 +1,46 @@ +############################################################################### +# Copyright (c) 2015 Ericsson AB and others. +# szilard.cserey@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################### + + +import yaml +import io +import os + +import common +from environments.libvirt_environment import LibvirtEnvironment +from environments.virtual_fuel import VirtualFuel + +exec_cmd = common.exec_cmd +err = common.err +log = common.log +check_dir_exists = common.check_dir_exists +check_file_exists = common.check_file_exists +check_if_root = common.check_if_root +ArgParser = common.ArgParser + + +class ExecutionEnvironment(object): + + def __new__(cls, storage_dir, pxe_bridge, dha_path, dea): + + with io.open(dha_path) as yaml_file: + dha_struct = yaml.load(yaml_file) + + type = dha_struct['adapter'] + + root_dir = os.path.dirname(os.path.realpath(__file__)) + + if cls is ExecutionEnvironment: + if type == 'libvirt': + return LibvirtEnvironment(storage_dir, dha_path, dea, root_dir) + + if type == 'ipmi' or type == 'hp': + return VirtualFuel(storage_dir, pxe_bridge, dha_path, root_dir) + + return super(ExecutionEnvironment, cls).__new__(cls) -- cgit 1.2.3-korg