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 ###############################################################################
14 from dea import DeploymentEnvironmentAdapter
15 from configure_environment import ConfigureEnvironment
16 from deployment import Deployment
27 YAML_CONF_DIR = '/var/lib/opnfv'
32 def __init__(self, dea_file, no_health_check):
33 self.dea = DeploymentEnvironmentAdapter(dea_file)
34 self.no_health_check = no_health_check
35 self.macs_per_blade = {}
36 self.blades = self.dea.get_node_ids()
37 self.blade_node_dict = self.dea.get_blade_node_map()
38 self.node_roles_dict = {}
40 self.wanted_release = self.dea.get_property('wanted_release')
42 def assign_roles_to_cluster_node_ids(self):
43 self.node_roles_dict = {}
44 for blade, node in self.blade_node_dict.iteritems():
45 roles = commafy(self.dea.get_node_role(blade))
46 self.node_roles_dict[node] = (roles, blade)
48 def configure_environment(self):
49 release_list = parse(exec_cmd('fuel release -l'))
50 for release in release_list:
51 if release[R['name']] == self.wanted_release:
53 config_env = ConfigureEnvironment(self.dea, YAML_CONF_DIR,
56 config_env.configure_environment()
57 self.env_id = config_env.env_id
59 def deploy_cloud(self):
60 dep = Deployment(self.dea, YAML_CONF_DIR, self.env_id,
61 self.node_roles_dict, self.no_health_check)
66 self.assign_roles_to_cluster_node_ids()
68 self.configure_environment()
73 def parse_arguments():
74 parser = ArgParser(prog='python %s' % __file__)
75 parser.add_argument('-nh', dest='no_health_check', action='store_true',
77 help='Don\'t run health check after deployment')
78 parser.add_argument('dea_file', action='store',
79 help='Deployment Environment Adapter: dea.yaml')
80 args = parser.parse_args()
81 check_file_exists(args.dea_file)
83 kwargs = {'dea_file': args.dea_file,
84 'no_health_check': args.no_health_check}
89 kwargs = parse_arguments()
90 deploy = Deploy(**kwargs)
93 if __name__ == '__main__':