def adopt_device(self, device): """ Make sure the adapter looks after given device. Called when a device is provisioned top-down and needs to be activated by the adapter. :param device: A voltha.Device object, with possible device-type specific extensions. Such extensions shall be described as part of the device type specification returned by device_types(). :return: (Deferred) Shall be fired to acknowledge device ownership. """ log.info('adopt-device', device=device) self.devices_handlers[device.id] = AdtranOltHandler(self, device.id) reactor.callLater(0, self.devices_handlers[device.id].activate, device) return device
def reconcile_device(self, device): """ Make sure the adapter looks after given device. Called when this device has changed ownership from another Voltha instance to this one (typically, this occurs when the previous voltha instance went down). :param device: A voltha.Device object, with possible device-type specific extensions. Such extensions shall be described as part of the device type specification returned by device_types(). :return: (Deferred) Shall be fired to acknowledge device ownership. """ log.info('reconcile-device', device=device) kwargs = {'adapter': self, 'device-id': device.id} self.devices_handlers[device.id] = AdtranOltHandler(**kwargs) d = defer.Deferred() reactor.callLater(0, self.devices_handlers[device.id].activate, d, True) return d