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()
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)
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):