def on_mngr_msg(client, body, routing_key): self.mngr_msg_count += 1 report = Entity.from_json(body) on_report(report) self.assertEqual(report.reporter_oid, self.node_oid) if self.mngr_msg_count == 1: # got NodeOnline Report self.assertEqual(report.__class__.__name__, 'NodeOnlineReport') client.send_task(TestConnectTask(node_oid=self.node_oid)) if self.mngr_msg_count == 2: # TaskUpdated reports self.assertEqual(report.task.node_oid, self.node_oid) self.assertEqual(report.task.status, 'accepted') if self.mngr_msg_count == 3: self.assertEqual(report.task.status, 'inprogress') self.assertEqual(report.task.progress, 50) if self.mngr_msg_count == 4: self.assertEqual(report.__class__.__name__, 'TaskSuccess') self.assertEqual(report.task.status, 'success') self.stop()
def on_msg(client, body, routing_key): try: entity = Entity.from_json(body) assert isinstance(entity, BaseTask) worker = TaskThreadWorker(client, entity) worker.start() except Exception: log.error("on msg processing", exc_info=True)
def on_mngr_msg(client, body, routing_key): from swarm.reports.base_report import BaseReport global CLIENT CLIENT = client entity = Entity.from_json(body) log.debug("got msg %s, client is %s" % (entity.__class__.__name__, CLIENT)) if isinstance(entity, BaseReport): return on_report(entity)
def on_mngr_msg(client, body, routing_key): default_mngr_callback(client, body, routing_key) event = Entity.from_json(body) if isinstance(event, NodeOnlineReport): node = Cluster.instance().get(self.node_oid) self.assertEqual(len(node.storages), 2) for mount_point in node.storages: if mount_point.storage_oid == self.storage1_oid: self.assertEqual(mount_point.path, self.storage1_path) self.stop()
def on_mngr_msg(client, body, routing_key): report = Entity.from_json(body) on_report(report) self.assertEqual(report.reporter_oid, self.node_oid) if report.__class__.__name__ == 'NodeOnlineReport': on_report(IFConfigReport.create(self.node_oid, raw_data=IFCONFIG_DATA)) client.send_task(VMInventoryTask(node_oid=self.node_oid)) if report.__class__.__name__ == 'VmXMLReport': cluster = Cluster.instance() vm_config = cluster.entities_by_class('VmConfig')[0] self.assertEqual(vm_config.oid, 'c2127a40-eb4c-4e3c-af5b-ab455fd8bb40') self.stop()
def on_mngr_msg(client, body, routing_key): event = Entity.from_json(body) self.assertEqual(event.__class__.__name__, 'NodeOnlineReport') self.assertEqual(event.node_oid, self.node_oid) self.stop()
def __init__(self, name, **kw): self.name = name Entity.__init__(self, **kw)
def entity_from_json(self, json_str): "Return Entity instance for given json str" return Entity.from_json(json_str)
def on_node_msg(client, body, routing_key): task = Entity.from_json(body) self.assertEqual(task.node_oid, self.node_oid) worker = TaskThreadWorker(client, task) worker.start()