VOL-838 Openolt device reconciliation
Change in the core on how to distinguish onu and olt by adapter name.
implementation of reconcile in openolt adapter and special case at creation of openolt handler.
Change-Id: I6c9d241d1b577532020b65b31e5875cb71fee6b1
diff --git a/voltha/adapters/openolt/openolt.py b/voltha/adapters/openolt/openolt.py
index a5cb3bb..612ba60 100644
--- a/voltha/adapters/openolt/openolt.py
+++ b/voltha/adapters/openolt/openolt.py
@@ -101,7 +101,26 @@
def reconcile_device(self, device):
log.info('reconcile-device', device=device)
- raise NotImplementedError()
+ kwargs = {
+ 'adapter_agent': self.adapter_agent,
+ 'device': device,
+ 'device_num': self.num_devices + 1,
+ 'reconciliation': True
+ }
+ try:
+ reconciled_device = OpenoltDevice(**kwargs)
+ log.debug('reconciled-device-recreated', device_id=reconciled_device.device_id)
+ self.devices[device.id] = reconciled_device
+ except Exception as e:
+ log.error('Failed to reconcile OpenOLT device', error=e, exception_type=type(e).__name__)
+ del self.devices[device.id]
+ raise
+ else:
+ self.num_devices += 1
+ # Invoke the children reconciliation which would setup the
+ # basic children data structures
+ self.adapter_agent.reconcile_child_devices(device.id)
+ return device
def abandon_device(self, device):
log.info('abandon-device', device=device)
diff --git a/voltha/adapters/openolt/openolt_device.py b/voltha/adapters/openolt/openolt_device.py
index efbe641..e92d5df 100644
--- a/voltha/adapters/openolt/openolt_device.py
+++ b/voltha/adapters/openolt/openolt_device.py
@@ -64,18 +64,22 @@
self.adapter_agent = kwargs['adapter_agent']
self.device_num = kwargs['device_num']
device = kwargs['device']
+ is_reconciliation = kwargs.get('reconciliation', False)
self.device_id = device.id
self.host_and_port = device.host_and_port
self.log = structlog.get_logger(id=self.device_id, ip=self.host_and_port)
self.nni_oper_state = dict() #intf_id -> oper_state
self.proxy = registry('core').get_proxy('/')
- # Update device
- device.root = True
- device.serial_number = self.host_and_port # FIXME
- device.connect_status = ConnectStatus.REACHABLE
- device.oper_status = OperStatus.ACTIVATING
- self.adapter_agent.update_device(device)
+ # Device already set in the event of reconciliation
+ if not is_reconciliation:
+ # It is a new device
+ # Update device
+ device.root = True
+ device.serial_number = self.host_and_port # FIXME
+ device.connect_status = ConnectStatus.REACHABLE
+ device.oper_status = OperStatus.ACTIVATING
+ self.adapter_agent.update_device(device)
# Initialize the OLT state machine
self.machine = Machine(model=self, states=OpenoltDevice.states,
@@ -103,6 +107,9 @@
self.heartbeat_signature = None
self.heartbeat_thread.start()
+ self.log.debug('openolt-device-created', device_id=self.device_id)
+
+
def process_indications(self):
self.log.debug('starting-indications-thread')
diff --git a/voltha/core/core.py b/voltha/core/core.py
index c7dccea..8978034 100644
--- a/voltha/core/core.py
+++ b/voltha/core/core.py
@@ -133,13 +133,13 @@
# handling the ONU should be present before the ONU reconciliation
# occurs
for device in devices:
- if device.type.endswith("_onu"):
+ if device.type.endswith("onu"):
yield self._handle_reconcile_existing_device(
device=device, reconcile=False)
# Then reconcile the OLT devices
for device in devices:
- if device.type.endswith("_olt"):
+ if device.type.endswith("olt"):
yield self._handle_reconcile_existing_device(
device=device, reconcile=True)
diff --git a/voltha/core/device_agent.py b/voltha/core/device_agent.py
index 7ad358f..a5f11bb 100644
--- a/voltha/core/device_agent.py
+++ b/voltha/core/device_agent.py
@@ -305,6 +305,7 @@
@inlineCallbacks
def update_device(self, device):
+ self.log.debug('updating-device', device=device.id)
self.last_data = device # so that we don't propagate back
self.proxy.update('/', device)
if device.admin_state == AdminState.ENABLED and \