Commit 77886590 authored by Spiros Koulouzis's avatar Spiros Koulouzis

Handle deployer errors

parent 9e000fff
...@@ -45,6 +45,7 @@ def install_manager(vm): ...@@ -45,6 +45,7 @@ def install_manager(vm):
print "%s: ========= Kubernetes Master Installed =========" % (vm.ip) print "%s: ========= Kubernetes Master Installed =========" % (vm.ip)
except Exception as e: except Exception as e:
print '%s: %s' % (vm.ip, e) print '%s: %s' % (vm.ip, e)
return "ERROR:"+vm.ip+" "+str(e)
ssh.close() ssh.close()
return retstr[-1] return retstr[-1]
...@@ -68,14 +69,21 @@ def install_worker(join_cmd, vm): ...@@ -68,14 +69,21 @@ def install_worker(join_cmd, vm):
print "%s: ========= Kubernetes Slave Installed =========" % (vm.ip) print "%s: ========= Kubernetes Slave Installed =========" % (vm.ip)
except Exception as e: except Exception as e:
print '%s: %s' % (vm.ip, e) print '%s: %s' % (vm.ip, e)
return "ERROR:"+vm.ip+" "+str(e)
ssh.close() ssh.close()
return ""
def run(vm_list): def run(vm_list):
for i in vm_list: for i in vm_list:
if i.role == "master": join_cmd = install_manager(i) if i.role == "master": join_cmd = install_manager(i)
if "ERROR" in join_cmd:
return join_cmd
else:
join_cmd = join_cmd.encode() join_cmd = join_cmd.encode()
join_cmd = join_cmd.strip() join_cmd = join_cmd.strip()
for i in vm_list: for i in vm_list:
if i.role == "slave": install_worker(join_cmd, i) if i.role == "slave": worker_cmd = install_worker(join_cmd, i)
if "ERROR" in worker_cmd:
return worker_cmd
return ""
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import pika import pika
import json import json
import os import os
import time
from vm_info import VmInfo from vm_info import VmInfo
import docker_kubernetes import docker_kubernetes
...@@ -30,14 +30,18 @@ def handleDelivery(message): ...@@ -30,14 +30,18 @@ def handleDelivery(message):
fo.close() fo.close()
vm = VmInfo(ip, user, key, role) vm = VmInfo(ip, user, key, role)
vm_list.append(vm) vm_list.append(vm)
docker_kubernetes.run(vm_list) return docker_kubernetes.run(vm_list)
def on_request(ch, method, props, body): def on_request(ch, method, props, body):
handleDelivery(body) ret = handleDelivery(body)
print ret
print(" Message %s" % body) if "ERROR" in ret:
kuber_string = ret
res_name = "error"
#print(" Message %s" % body)
else:
res_name = "credential"
kuber_file = open(path + "admin.conf", "r") kuber_file = open(path + "admin.conf", "r")
kuber_string = kuber_file.read() kuber_string = kuber_file.read()
kuber_file.close() kuber_file.close()
...@@ -50,7 +54,7 @@ def on_request(ch, method, props, body): ...@@ -50,7 +54,7 @@ def on_request(ch, method, props, body):
par = {} par = {}
par["url"] = "null" par["url"] = "null"
par["encoding"] = "UTF-8" par["encoding"] = "UTF-8"
par["name"] = "credential" par["name"] = res_name
par["value"] = kuber_string par["value"] = kuber_string
par["attributes"] = "null" par["attributes"] = "null"
response["parameters"].append(par) response["parameters"].append(par)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment