def delete_child_device(self, child_device): self.log.debug('sending-deactivate-onu', olt_device_id=self.device_id, onu_device=child_device, onu_serial_number=child_device.serial_number) try: self.adapter_agent.delete_child_device(self.device_id, child_device.id, child_device) except Exception as e: self.log.error('adapter_agent error', error=e) try: self.delete_logical_port(child_device.id) except Exception as e: self.log.error('logical_port delete error', error=e) try: self.delete_port(child_device.serial_number) except Exception as e: self.log.error('port delete error', error=e) vendor_id = child_device.vendor_id.encode('hex') vendor_specific = child_device.serial_number.replace( child_device.vendor_id, '').encode('hex') serial_number = openolt_pb2.SerialNumber( vendor_id=vendor_id, vendor_specific=vendor_specific) onu = openolt_pb2.Onu(intf_id=child_device.proxy_address.channel_id, onu_id=child_device.proxy_address.onu_id, serial_number=serial_number) self.stub.DeleteOnu(onu)
def delete_child_device(self, child_device): self.log.debug('sending-deactivate-onu', olt_device_id=self.device_id, onu_device=child_device, onu_serial_number=child_device.serial_number) vendor_id = child_device.vendor_id.encode('hex') vendor_specific = child_device.serial_number.replace( child_device.vendor_id, '').encode('hex') serial_number = openolt_pb2.SerialNumber( vendor_id=vendor_id, vendor_specific=vendor_specific) onu = openolt_pb2.Onu(intf_id=child_device.proxy_address.channel_id, onu_id=child_device.proxy_address.onu_id, serial_number=serial_number) self.stub.DeleteOnu(onu)
def destringify_serial_number(self, serial_number_str): serial_number = openolt_pb2.SerialNumber( vendor_id=serial_number_str[:4].encode('utf-8'), vendor_specific=binascii.unhexlify(serial_number_str[4:])) return serial_number