def child_devices_state_update(self, parent_device_id, oper_status=None, connect_status=None): id = ID() id.id = parent_device_id o_status = IntType() if oper_status or oper_status == OperStatus.UNKNOWN: o_status.val = oper_status else: o_status.val = -1 c_status = IntType() if connect_status or connect_status == ConnectStatus.UNKNOWN: c_status.val = connect_status else: c_status.val = -1 to_topic = createSubTopic(self.core_topic, parent_device_id) reply_topic = createSubTopic(self.listening_topic, parent_device_id) res = yield self.invoke(rpc="child_devices_state_update", to_topic=to_topic, reply_topic=reply_topic, parent_device_id=id, oper_status=o_status, connect_status=c_status) returnValue(res)
def port_created(self, device_id, port): log.debug("port_created") proto_id = ID() proto_id.id = device_id to_topic = createSubTopic(self.core_topic, device_id) reply_topic = createSubTopic(self.listening_topic, device_id) res = yield self.invoke(rpc="PortCreated", to_topic=to_topic, reply_topic=reply_topic, device_id=proto_id, port=port) returnValue(res)
def get_ports(self, device_id, port_type): id = ID() id.id = device_id p_type = IntType() p_type.val = port_type to_topic = createSubTopic(self.core_topic, device_id) reply_topic = createSubTopic(self.listening_topic, device_id) res = yield self.invoke(rpc="GetPorts", to_topic=to_topic, reply_topic=reply_topic, device_id=id, port_type=p_type) returnValue(res)
def get_device(self, device_id): log.debug("get-device") id = ID() id.id = device_id # Once we have a device being managed, all communications between the # the adapter and the core occurs over a topic associated with that # device to_topic = createSubTopic(self.core_topic, device_id) reply_topic = createSubTopic(self.listening_topic, device_id) res = yield self.invoke(rpc="GetDevice", to_topic=to_topic, reply_topic=reply_topic, device_id=id) returnValue(res)
def send_packet_in(self, device_id, port, packet): log.debug("send_packet_in", device_id=device_id) proto_id = ID() proto_id.id = device_id p = IntType() p.val = port pac = Packet() pac.payload = packet to_topic = createSubTopic(self.core_topic, device_id) reply_topic = createSubTopic(self.listening_topic, device_id) res = yield self.invoke(rpc="PacketIn", to_topic=to_topic, reply_topic=reply_topic, device_id=proto_id, port=p, packet=pac) returnValue(res)
def port_state_update(self, device_id, port_type, port_no, oper_status): id = ID() id.id = device_id pt = IntType() pt.val = port_type pNo = IntType() pNo.val = port_no o_status = IntType() o_status.val = oper_status to_topic = createSubTopic(self.core_topic, device_id) reply_topic = createSubTopic(self.listening_topic, device_id) res = yield self.invoke(rpc="PortStateUpdate", to_topic=to_topic, reply_topic=reply_topic, device_id=id, port_type=pt, port_no=pNo, oper_status=o_status) returnValue(res)
def child_device_detected(self, parent_device_id, parent_port_no, child_device_type, channel_id, **kw): id = ID() id.id = parent_device_id ppn = IntType() ppn.val = parent_port_no cdt = StrType() cdt.val = child_device_type channel = IntType() channel.val = channel_id to_topic = createSubTopic(self.core_topic, parent_device_id) reply_topic = createSubTopic(self.listening_topic, parent_device_id) args = self._to_proto(**kw) res = yield self.invoke(rpc="ChildDeviceDetected", to_topic=to_topic, reply_topic=reply_topic, parent_device_id=id, parent_port_no=ppn, child_device_type=cdt, channel_id=channel, **args) returnValue(res)