diff options
author | 2015-04-07 10:29:42 +0200 | |
---|---|---|
committer | 2015-04-13 22:32:15 +0200 | |
commit | 29d8730686b539af7252e54f10b1bf19be3423e5 (patch) | |
tree | 707bca52a2389189393fdb4d93917118c833c7d8 /fuel/deploy/deploy.py | |
parent | 5ce8b661ea230f0823ebdfcbee19a2b1cf60ae32 (diff) |
Automatic Deployment
- configure environment
- configure initial settings
- configure networking
- hardware adapter for HP
- fuel VM deployment
JIRA: [BGS-2] Create Fuel deployment scrip
Change-Id: If305477833c54547efe7e6ebfddafde0ab31ebd2
Signed-off-by: Szilard Cserey <szilard.cserey@ericsson.com>
Diffstat (limited to 'fuel/deploy/deploy.py')
-rw-r--r-- | fuel/deploy/deploy.py | 112 |
1 files changed, 61 insertions, 51 deletions
diff --git a/fuel/deploy/deploy.py b/fuel/deploy/deploy.py index 4df4f36..4037c1d 100644 --- a/fuel/deploy/deploy.py +++ b/fuel/deploy/deploy.py @@ -1,43 +1,28 @@ -import subprocess -import sys import time import os +import sys + +import common from dha import DeploymentHardwareAdapter from dea import DeploymentEnvironmentAdapter +from configure_environment import ConfigureEnvironment -SUPPORTED_RELEASE = 'Juno on CentOS 6.5' -N = {'id': 0, 'status': 1, 'name': 2, 'cluster': 3, 'ip': 4, 'mac': 5, - 'roles': 6, 'pending_roles': 7, 'online': 8} -E = {'id': 0, 'status': 1, 'name': 2, 'mode': 3, 'release_id': 4, - 'changes': 5, 'pending_release_id': 6} -R = {'id': 0, 'name': 1, 'state': 2, 'operating_system': 3, 'version': 4} -RO = {'name': 0, 'conflicts': 1} - -def exec_cmd(cmd): - process = subprocess.Popen(cmd, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - shell=True) - return process.communicate()[0] - -def parse(printout): - parsed_list = [] - lines = printout.splitlines() - for l in lines[2:]: - parsed = [e.strip() for e in l.split('|')] - parsed_list.append(parsed) - return parsed_list - -def err(error_message): - sys.stderr.write(error_message) - sys.exit(1) +SUPPORTED_RELEASE = 'Juno on CentOS 6.5' +N = common.N +E = common.E +R = common.R +RO = common.RO +exec_cmd = common.exec_cmd +parse = common.parse +err = common.err class Deploy(object): - def __init__(self): + def __init__(self, yaml_config_dir): self.supported_release = None + self.yaml_config_dir = yaml_config_dir def get_id_list(self, list): return [l[0] for l in list] @@ -96,6 +81,18 @@ class Deploy(object): self.check_role_definitions() self.check_previous_installation() + def power_off_blades(self, dha, shelf_blades_dict): + for shelf, blade_list in shelf_blades_dict.iteritems(): + dha.power_off_blades(shelf, blade_list) + + def power_on_blades(self, dha, shelf_blades_dict): + for shelf, blade_list in shelf_blades_dict.iteritems(): + dha.power_on_blades(shelf, blade_list) + + def set_boot_order(self, dha, shelf_blades_dict): + for shelf, blade_list in shelf_blades_dict.iteritems(): + dha.set_boot_order_blades(shelf, blade_list) + def count_discovered_nodes(self, node_list): discovered_nodes = 0 for node in node_list: @@ -122,7 +119,7 @@ class Deploy(object): def assign_cluster_node_ids(self, dha, dea, controllers, compute_hosts): node_list= parse(exec_cmd('fuel node list')) for shelf_id in dea.get_shelf_ids(): - for blade_id in dea.get_blade_ids(shelf_id): + for blade_id in dea.get_blade_ids_per_shelf(shelf_id): blade_mac_list = dha.get_blade_mac_addresses( shelf_id, blade_id) @@ -142,27 +139,36 @@ class Deploy(object): "with MACs %s or blade is not in " "discover status\n" % blade_mac_list) - def env_exists(self, env_name): - env_list = parse(exec_cmd('fuel env --list')) - for env in env_list: - if env[E['name']] == env_name and env[E['status']] == 'new': - return True - return False def configure_environment(self, dea): - env_name = dea.get_environment_name() - exec_cmd('fuel env -c --name %s --release %s --mode ha --net neutron ' - '--nst vlan' % (env_name, self.supported_release[R['id']])) + config_env = ConfigureEnvironment(dea, self.yaml_config_dir) + + + + def provision(self): + + + + def fix_power_address(self): + + + + + def deploy(self): + + if id in self.get_id_list(parse(exec_cmd('fuel env list'))): + + self.fix_power_address() - if not self.env_exists(env_name): - err("Failed to create environment %s" % env_name) def main(): yaml_path = exec_cmd('pwd').strip() + '/dea.yaml' - deploy = Deploy() + yaml_config_dir = '/var/lib/opnfv/pre_deploy' + + deploy = Deploy(yaml_config_dir) dea = DeploymentEnvironmentAdapter() @@ -172,30 +178,34 @@ def main(): dea.parse_yaml(yaml_path) - dha = DeploymentHardwareAdapter(dea.get_server_type()) + server_type, mgmt_ip, username, password = dea.get_server_info() + shelf_blades_dict = dea.get_blade_ids_per_shelves() - deploy.check_prerequisites() - - dha.power_off_blades() + dha = DeploymentHardwareAdapter(server_type, mgmt_ip, username, password) - dha.configure_networking() + deploy.check_prerequisites() - dha.reset_to_factory_defaults() + deploy.power_off_blades(dha, shelf_blades_dict) - dha.set_boot_order() + deploy.set_boot_order(dha, shelf_blades_dict) - dha.power_on_blades() + deploy.power_on_blades(dha, shelf_blades_dict) - dha.get_blade_mac_addresses() + macs = dha.get_blade_mac_addresses() deploy.wait_for_discovered_blades(dea.get_no_of_blades()) + controllers = [] compute_hosts = [] deploy.assign_cluster_node_ids(dha, dea, controllers, compute_hosts) + + deploy.configure_environment(dea) + deploy.deploy(dea) + if __name__ == '__main__': |