def deserialize(cls, data): deserializer = cls.DESERIALIZER[data[2]] content = deserializer.deserialize(data[3]) packet = Packet(data[2], content) packet.src = Device.deserialize(data[0]) packet.dst = Device.deserialize(data[1]) return packet
def handle_storage(self, key, value, domain, type): if type == Storage.SADD: value = [value] controller = Device.deserialize(key) if domain == self.GLOBAL_CONCERN: for concern_type in value: try: self._global_controllers[concern_type].add(controller) except KeyError: self._global_controllers[concern_type] = set([controller]) self._app.register(concern_type) else: switch_id = domain[len(self.LOCAL_CONCERN) + 1:] switch = Device.deserialize(switch_id) for concern_type in value: try: switches = self._local_controllers[concern_type] except KeyError: switches = {} self._local_controllers[concern_type] = switches try: switches[switch].add(controller) except KeyError: switches[switch] = set([controller]) self._app.register(concern_type, switch)
def deserialize(cls, data): update = [] for controller, path in data[1]: update.append((Device.deserialize(controller), set(path))) remove = [] for controller in data[2]: update.append(Device.deserialize(controller)) return cls(Device.deserialize(data[0]), update, remove)
def deserialize(cls, data): content = cls(Device.deserialize(data[1])) content.port = data[2] content.buffer_id = data[3] content.data = data[4] content.actions = [Action.deserialize(action) for action in data[5]] return content
def deserialize(cls, data): content = cls(Device.deserialize(data[1])) content.idle_timeout = data[2] content.hard_timeout = data[3] content.match = Match.deserialize(data[4]) content.buffer_id = data[5] content.actions = [Action.deserialize(action) for action in data[6]] content.data = data[7] return content
def handle_event(self, event): controllers = core.globalStorage.sget(self.GLOBAL_CONCERN_CONTROLLERS, self.GLOBAL_CONCERN_CONTROLLERS) for controller in controllers: concerns = core.globalStorage.sget(controller, self.GLOBAL_CONCERN) controller = Device.deserialize(controller) for concern in concerns: try: self._global_controllers[concern].add(controller) except KeyError: self._global_controllers[concern] = set([controller]) self._app.register(concern)
def _send_packet(self, listener, key, value, domain, type): packet = Packet(Packet.STORAGE, StoragePacketContent([(key, value, domain, type)])) packet.src = self._myself packet.dst = Device.deserialize(listener) core.forwarding.forward(packet)
def _send_packet(self, listener, tasks): packet = Packet(Packet.STORAGE, StoragePacketContent(tasks)) packet.src = self._myself packet.dst = Device.deserialize(listener) core.forwarding.forward(packet)
def deserialize(cls, data): content = cls(Device.deserialize(data[1])) content.buffer_id = data[2] content.port = data[3] content.data = data[4] return content
def deserialize(cls, data): return cls(Device.deserialize(data[1]))