def locator(self):
     if self._locator:
         return self._locator
     else:
         try:
             locator = Locator()
             locator.connect(self.host, self.port, self.timeout, blocking=True)
             self._locator = locator
             return locator
         except Exception as err:
             raise ToolsError(err)
Beispiel #2
0
def group_refresh(name, response):
    try:
        hosts = yield hostdb.hosts()
        for host in hosts:
            l = Locator()
            l.connect(host, 10053, 120, True)
            yield group.Refresh(l, storage, name).execute()
    except Exception as err:
        log.error(repr(err))
        response.error(-100, "Unable to refresh %s" % err)
    finally:
        response.close()
Beispiel #3
0
 def locator(self):
     if self._locator:
         return self._locator
     else:
         try:
             locator = Locator()
             locator.connect(self.host,
                             self.port,
                             self.timeout,
                             blocking=True)
             self._locator = locator
             return locator
         except Exception as err:
             raise ToolsError(err)
Beispiel #4
0
from cocaine.tools.actions import runlist
from cocaine.tools.actions import group
from cocaine.tools.actions import crashlog
from cocaine.tools.actions import app


from userdb import UserDB
from hostdb import HostDB
from nodecluster import NodeCluster

ITEM_IS_ABSENT = -100
VERSION_DELEMITER = "_"

log = Logger()
storage = Service("storage")
locator = Locator()

LOGS_NAMESPACE = "flow_upload_logs"
HOSTS_NAMESPACE = "flow_hosts"
db = UserDB(storage, "KEY", "flow_users")
hostdb = HostDB(storage, HOSTS_NAMESPACE)


class UploadLog(object):
    def __init__(self, depth=10, on_flush=None):
        self.current = list()
        self.buffer = cStringIO.StringIO()
        self.depth = depth
        self.on_flush = on_flush

    def write(self, value):
import json
from django.http import HttpResponse
from django.shortcuts import render
from cocaine.tools.actions import common
from cocaine.asio.service import Service, Locator


locator = Locator()
locator.connect('localhost', 10053, 1.0, blocking=True)
node = Service('node')


def apps(request):
    node = Service('node')
    list_ = yield node.list()
    yield render(request, 'list.html', {
        'apps': list_
    })


def info(request):
    info = yield common.NodeInfo(node, locator).execute()
    yield HttpResponse(json.dumps(info))