Пример #1
0
def on_report_from_offline_node(report):
    """Handle situation when we got any report from 
    node and we have no any info about that node

    """
    raise log.warn("Report %s for offline node %s" % (
            report, report.node_oid))
Пример #2
0
 def wrapper(self, *args, **kwargs):
     import base64
     try:
         auth_type, auth_data = self.request.headers[
             "Authorization"].split()
         assert auth_type == "Basic"
         usr, pwd = base64.b64decode(auth_data).split(":", 1)
         if usr == options.user:
             assert pwd == options.password, 'wrong password'
         else:
             assert False, "no such user, %s" % usr
     except (KeyError, AssertionError), exc:
         log.warn(
             "No auth request %s, %s" % (
                 self.request.headers, str(exc)))
         self.set_header('WWW-Authenticate', 'Basic realm=VGDCloud')
         self.set_status(401)
         self.finish()
Пример #3
0
def on_node_online(report):
    from swarm.stuff import Storage
    from swarm.tasks import VMInventoryTask
    cluster = Cluster.instance()
    if not cluster.is_stored(report.node_oid):
        node = Node(oid=report.node_oid, 
                    hostname=report.hostname,
                    state='online')
        cluster.store(node)
        if CLIENT:
            task = VMInventoryTask(node_oid=node.oid)
            cluster.store(task)
            CLIENT.send_task(task)
        else:
            log.warn("No client available in on_node_online")
    else:
        node = cluster.get(report.node_oid)
        node.state = 'online'
    Storage.update_points(node, report.storages)