summaryrefslogtreecommitdiffstats
path: root/fuel/deploy/cloud/deployment.py
diff options
context:
space:
mode:
authorSzilard Cserey <szilard.cserey@ericsson.com>2015-08-18 19:47:50 +0200
committerSzilard Cserey <szilard.cserey@ericsson.com>2015-09-16 11:33:23 +0200
commit49aacd62348d7edf91c5b9bbd40d31708610e1e5 (patch)
tree0dc637b67d2c56ea71c995ca26113df6c81ce16f /fuel/deploy/cloud/deployment.py
parent54f12d2bdd72ae12061ebf62c5b70f357850c411 (diff)
Autodeployer support for ODL Plugin installation + Fuel 6.1
- Opendaylight plugin installation - Adapting Autodeployer to Fuel 6.1 - restarting blades that couldn't be discovered Fuel in time BGS-87 Autodeployment restarts blade if that has not been discovered by Fuel BGS-90 Fuel 6.1 and Opendaylight Fuel plugin install support for Autodeployer Change-Id: I83aab3f8caf368a70fd3f2b67c7ba1b6191993c6 Signed-off-by: Szilard Cserey <szilard.cserey@ericsson.com>
Diffstat (limited to 'fuel/deploy/cloud/deployment.py')
-rw-r--r--fuel/deploy/cloud/deployment.py87
1 files changed, 70 insertions, 17 deletions
diff --git a/fuel/deploy/cloud/deployment.py b/fuel/deploy/cloud/deployment.py
index 0054c5b..43bd4b6 100644
--- a/fuel/deploy/cloud/deployment.py
+++ b/fuel/deploy/cloud/deployment.py
@@ -1,3 +1,13 @@
+###############################################################################
+# 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 common
import os
import shutil
@@ -15,20 +25,26 @@ run_proc = common.run_proc
parse = common.parse
err = common.err
log = common.log
+literal_unicode = common.literal_unicode
+literal_unicode_representer = common.literal_unicode_representer
+yaml.add_representer(literal_unicode, literal_unicode_representer)
+backup = common.backup
class Deployment(object):
- def __init__(self, dea, yaml_config_dir, env_id, node_id_roles_dict):
+ def __init__(self, dea, yaml_config_dir, env_id, node_id_roles_dict,
+ no_health_check):
self.dea = dea
self.yaml_config_dir = yaml_config_dir
self.env_id = env_id
self.node_id_roles_dict = node_id_roles_dict
+ self.no_health_check = no_health_check
def download_deployment_info(self):
log('Download deployment info for environment %s' % self.env_id)
- deployment_dir = '%s/deployment_%s' \
- % (self.yaml_config_dir, self.env_id)
+ deployment_dir = ('%s/deployment_%s'
+ % (self.yaml_config_dir, self.env_id))
if os.path.exists(deployment_dir):
shutil.rmtree(deployment_dir)
exec_cmd('fuel deployment --env %s --download --dir %s'
@@ -39,21 +55,54 @@ class Deployment(object):
exec_cmd('fuel --env %s deployment --upload --dir %s'
% (self.env_id, self.yaml_config_dir))
+ def __update_opnfv_dict(self, opnfv_dict, key, node_type, val):
+ if val:
+ if key not in opnfv_dict:
+ opnfv_dict.update({key: {}})
+ opnfv_dict[key].update({node_type: val})
+
def config_opnfv(self):
log('Configure OPNFV settings on environment %s' % self.env_id)
- opnfv_compute = self.dea.get_opnfv('compute')
- opnfv_controller = self.dea.get_opnfv('controller')
self.download_deployment_info()
+
+ opnfv = {'opnfv': {}}
+ dns_list = self.dea.get_dns_list()
+ host_list = self.dea.get_hosts()
+
+ ntp_list_for_controller = ''
+ for ntp in self.dea.get_ntp_list():
+ ntp_list_for_controller += 'server %s\n' % ntp
+
+ ntp_list_for_compute = ''
+ for controller_file in glob.glob(
+ '%s/deployment_%s/*controller*.yaml'
+ % (self.yaml_config_dir, self.env_id)):
+ with io.open(controller_file) as stream:
+ controller = yaml.load(stream)
+ ntp_list_for_compute += 'server %s\n' % controller['fqdn']
+
+ self.__update_opnfv_dict(
+ opnfv['opnfv'], 'dns', 'controller', dns_list[:])
+ self.__update_opnfv_dict(
+ opnfv['opnfv'], 'dns', 'compute', dns_list[:])
+ self.__update_opnfv_dict(
+ opnfv['opnfv'], 'ntp', 'controller',
+ literal_unicode(ntp_list_for_controller))
+ self.__update_opnfv_dict(
+ opnfv['opnfv'], 'ntp', 'compute',
+ literal_unicode(ntp_list_for_compute))
+
+ if host_list:
+ opnfv['opnfv'].update({'hosts': host_list})
+
for node_file in glob.glob('%s/deployment_%s/*.yaml'
% (self.yaml_config_dir, self.env_id)):
- with io.open(node_file) as stream:
- node = yaml.load(stream)
- if node['role'] == 'compute':
- node.update(opnfv_compute)
- else:
- node.update(opnfv_controller)
- with io.open(node_file, 'w') as stream:
- yaml.dump(node, stream, default_flow_style=False)
+ with io.open(node_file) as stream:
+ node = yaml.load(stream)
+ node.update(opnfv)
+ with io.open(node_file, 'w') as stream:
+ yaml.dump(node, stream, default_flow_style=False)
+
self.upload_deployment_info()
def run_deploy(self):
@@ -103,11 +152,15 @@ class Deployment(object):
def health_check(self):
log('Now running sanity and smoke health checks')
- log(exec_cmd('fuel health --env %s --check sanity,smoke --force'
- % self.env_id))
-
+ r = exec_cmd('fuel health --env %s --check sanity,smoke --force'
+ % self.env_id)
+ log(r)
+ if 'failure' in r:
+ err('Healthcheck failed!')
+
def deploy(self):
self.config_opnfv()
self.run_deploy()
self.verify_node_status()
- self.health_check() \ No newline at end of file
+ if not self.no_health_check:
+ self.health_check()