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)
def init_storages(self): self.storage1_path = '/tmp/storage1' self.storage2_path = '/tmp/storage2' self.storage1_oid = Storage.ensure(self.storage1_path) self.storage2_oid = Storage.ensure(self.storage2_path)