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, deploy_timeout):
33 self.dea = DeploymentEnvironmentAdapter(dea_file)
34 self.no_health_check = no_health_check
35 self.deploy_timeout = deploy_timeout
36 self.macs_per_blade = {}
37 self.blades = self.dea.get_node_ids()
38 self.blade_node_dict = self.dea.get_blade_node_map()
39 self.node_roles_dict = {}
41 self.wanted_release = self.dea.get_property('wanted_release')
43 def assign_roles_to_cluster_node_ids(self):
44 self.node_roles_dict = {}
45 for blade, node in self.blade_node_dict.iteritems():
46 if self.dea.get_node_role(blade):
47 roles = commafy(self.dea.get_node_role(blade))
48 self.node_roles_dict[node] = (roles, blade)
50 def configure_environment(self):
51 release_list = parse(exec_cmd('fuel release -l'))
52 for release in release_list:
53 if release[R['name']] == self.wanted_release:
55 config_env = ConfigureEnvironment(self.dea, YAML_CONF_DIR,
58 config_env.configure_environment()
59 self.env_id = config_env.env_id
61 def deploy_cloud(self):
62 dep = Deployment(self.dea, YAML_CONF_DIR, self.env_id,
63 self.node_roles_dict, self.no_health_check,
69 self.assign_roles_to_cluster_node_ids()
71 self.configure_environment()
76 def parse_arguments():
77 parser = ArgParser(prog='python %s' % __file__)
78 parser.add_argument('-nh', dest='no_health_check', action='store_true',
80 help='Don\'t run health check after deployment')
81 parser.add_argument('-dt', dest='deploy_timeout', action='store',
82 default=240, help='Deployment timeout (in minutes) '
84 parser.add_argument('dea_file', action='store',
85 help='Deployment Environment Adapter: dea.yaml')
86 args = parser.parse_args()
87 check_file_exists(args.dea_file)
89 kwargs = {'dea_file': args.dea_file,
90 'no_health_check': args.no_health_check,
91 'deploy_timeout': args.deploy_timeout}
96 kwargs = parse_arguments()
97 deploy = Deploy(**kwargs)
100 if __name__ == '__main__':