Esempio n. 1
0
 def _wait_on_agent(director_manager, app_name, processes):
     from paasman.director import etcd_client
     try:
         print "trying to create vm (in _wait_on_agent in manager)"
         instances = director_manager.add_vm_instances(1)
         ip = instances[0].private_ip_address
         print "_wait_on_agent-1"
         r = etcd_client.watch("services/agents/%s" %
                               hashlib.sha1(ip).hexdigest(),
                               timeout=60)
         print "_wait_on_agent-2"
         publish_queue.put_nowait({
             "task":
             "deploy",
             "remove":
             False,
             "app_name":
             task.get("app_name"),
             "deploy_instruction": {
                 ip: processes
             }
         })
     except Exception as e:
         print "event_listener", e
         traceback.print_exc(file=sys.stdout)
         return
Esempio n. 2
0
 def _wait_on_agent(app_name, ip):
     try:
         print "_wait_on_agent-1"
         r = etcd_client.watch("services/agents/%s" % hashlib.sha1(ip).hexdigest(), timeout=60)
         print "_wait_on_agent-2"
         for x in xrange(3):
             tasks.put_nowait({
                 "task": "add_min_instance_processes",
                 "app_name": app_name,
                 "target": ip
             })
     except:
         return
Esempio n. 3
0
def cluster_listener():
    while True:
        r = etcd_client.watch("services/agents") # blocking
        if r.action == "SET": # adding a node to the cluster
            tasks.put_nowait({
                "task": "add_node",
                "name": r.key.split("/")[-1],
                "ip": r.value
            })
        elif r.action == "DELETE": # a node has gone away
            tasks.put_nowait({
                "task": "delete_node",
                "name": r.key.split("/")[-1],
                #"ip": r.value
            })
        gevent.sleep(0)
Esempio n. 4
0
 def _wait_on_agent(director_manager, app_name, processes):
     from paasman.director import etcd_client
     try:
         print "trying to create vm (in _wait_on_agent in manager)"
         instances = director_manager.add_vm_instances(1)
         ip = instances[0].private_ip_address
         print "_wait_on_agent-1"
         r = etcd_client.watch("services/agents/%s" % hashlib.sha1(ip).hexdigest(), timeout=60)
         print "_wait_on_agent-2"
         publish_queue.put_nowait({
             "task": "deploy",
             "remove": False,
             "app_name": task.get("app_name"),
             "deploy_instruction": {ip: processes}
         })
     except Exception as e:
         print "event_listener", e
         traceback.print_exc(file=sys.stdout)
         return