def reboot_device(self, device): d = Device() if device: device.Unpack(d) return (True, self.adapter.reboot_device(d)) else: return False, Error(code=ErrorCode.INVALID_PARAMETERS, reason="device-invalid")
def get_ofp_device_info(self, device): d = Device() if device: device.Unpack(d) return True, self.adapter.get_ofp_device_info(d) else: return False, Error(code=ErrorCode.INVALID_PARAMETERS, reason="device-invalid")
def get_ofp_port_info(self, device, port_no): d = Device() if device: device.Unpack(d) else: return False, Error(code=ErrorCode.INVALID_PARAMETERS, reason="device-invalid") p = IntType() if port_no: port_no.Unpack(p) else: return False, Error(code=ErrorCode.INVALID_PARAMETERS, reason="port-no-invalid") return True, self.adapter.get_ofp_port_info(d, p.val)
def update_flows_incrementally(self, device, flow_changes, group_changes): d = Device() if device: device.Unpack(d) else: return False, Error(code=ErrorCode.INVALID_PARAMETERS, reason="device-invalid") f = FlowChanges() if flow_changes: flow_changes.Unpack(f) g = FlowGroupChanges() if group_changes: group_changes.Unpack(g) return (True, self.adapter.update_flows_incrementally(d, f, g))
def update_flows_bulk(self, device, flows, groups): d = Device() if device: device.Unpack(d) else: return False, Error(code=ErrorCode.INVALID_PARAMETERS, reason="device-invalid") f = Flows() if flows: flows.Unpack(f) g = FlowGroups() if groups: groups.Unpack(g) return (True, self.adapter.update_flows_bulk(d, f, g))
def adopt_device(self, device): d = Device() if device: device.Unpack(d) # Start the creation of a device specific topic to handle all # subsequent requests from the Core. This adapter instance will # handle all requests for that device. reactor.callLater(0, self.createKafkaDeviceTopic, d.id) result = self.adapter.adopt_device(d) # return True, self.adapter.adopt_device(d) return True, result else: return False, Error(code=ErrorCode.INVALID_PARAMETERS, reason="device-invalid")
def delete_device(self, device): d = Device() if device: device.Unpack(d) result = self.adapter.delete_device(d) # return (True, self.adapter.delete_device(d)) # Before we return, delete the device specific topic as we will no # longer receive requests from the Core for that device kafka_proxy = get_messaging_proxy() device_topic = kafka_proxy.get_default_topic() + "/" + d.id kafka_proxy.unsubscribe(topic=device_topic) return (True, result) else: return False, Error(code=ErrorCode.INVALID_PARAMETERS, reason="device-invalid")