def on_enter_starting(self): """ Determine ONU status and start Alarm Synchronization tasks """ self._device = self._agent.get_device(self._device_id) self.advertise(AlarmOpenOmciEventType.state_change, self.state) # Make sure root of external Alarm Database exists self._seed_database() # Set up Response and Autonomous notification subscriptions try: for event, sub in self._omci_cc_sub_mapping.iteritems(): if self._omci_cc_subscriptions[event] is None: self._omci_cc_subscriptions[event] = \ self._device.omci_cc.event_bus.subscribe( topic=OMCI_CC.event_bus_topic(self._device_id, event), callback=sub) except Exception as e: self.log.exception('omci-cc-subscription-setup', e=e) # Schedule first audit if enabled if self._audit_delay > 0: # Note using the shorter timeout delay here since this is the first # audit after startup self._deferred = reactor.callLater(self._timeout_delay, self.audit_alarm) else: self._deferred = reactor.callLater(0, self.sync_alarm)
def on_enter_starting(self): """ Determine ONU status and start MIB Synchronization tasks """ self._device = self._agent.get_device(self._device_id) self.log.debug('state-transition', new_onu=self.is_new_onu) # Make sure root of external MIB Database exists self._seed_database() # Set up Response and Autonomous notification subscriptions try: for event, sub in self._sub_mapping.iteritems(): if self._subscriptions[event] is None: self._subscriptions[event] = \ self._device.omci_cc.event_bus.subscribe( topic=OMCI_CC.event_bus_topic(self._device_id, event), callback=sub) except Exception as e: self.log.exception('subscription-setup', e=e) # Determine if this ONU has ever synchronized if self.is_new_onu: # Start full MIB upload self._deferred = reactor.callLater(0, self.upload_mib) else: # Examine the MIB Data Sync self._deferred = reactor.callLater(0, self.examine_mds)
def _subscribe_to_events(self): from voltha.extensions.omci.onu_device_entry import OnuDeviceEvents, \ OnuDeviceEntry from voltha.extensions.omci.omci_cc import OMCI_CC, OmciCCRxEvents # OMCI MIB Database sync status bus = self._onu_omci_device.event_bus topic = OnuDeviceEntry.event_bus_topic(self._handler.device_id, OnuDeviceEvents.MibDatabaseSyncEvent) self._in_sync_subscription = bus.subscribe(topic, self.in_sync_handler) # OMCI Capabilities (MEs and Message Types bus = self._onu_omci_device.event_bus topic = OnuDeviceEntry.event_bus_topic(self._handler.device_id, OnuDeviceEvents.OmciCapabilitiesEvent) self._capabilities_subscription = bus.subscribe(topic, self.capabilities_handler) # OMCI-CC Connectivity Events (for reachability/heartbeat) bus = self._onu_omci_device.omci_cc.event_bus topic = OMCI_CC.event_bus_topic(self._handler.device_id, OmciCCRxEvents.Connectivity) self._connectivity_subscription = bus.subscribe(topic, self.onu_is_reachable)
def on_enter_starting(self): """ Determine ONU status and start Alarm Synchronization tasks """ self._device = self._agent.get_device(self._device_id) self.advertise(AlarmOpenOmciEventType.state_change, self.state) # Make sure root of external Alarm Database exists self._seed_database() # Set up Response and Autonomous notification subscriptions try: for event, sub in self._omci_cc_sub_mapping.iteritems(): if self._omci_cc_subscriptions[event] is None: self._omci_cc_subscriptions[event] = \ self._device.omci_cc.event_bus.subscribe( topic=OMCI_CC.event_bus_topic(self._device_id, event), callback=sub) except Exception as e: self.log.exception('omci-cc-subscription-setup', e=e) except Exception as e: self.log.exception('dev-subscription-setup', e=e) # Determine if this ONU has ever synchronized if self.is_updated_alarm: self._deferred = reactor.callLater(0, self.update_alarm) else: self._deferred = reactor.callLater(0, self.sync_alarm)
def on_enter_starting(self): """ Determine ONU status and start/re-start MIB Synchronization tasks """ self._device = self._agent.get_device(self._device_id) self.advertise(OpenOmciEventType.state_change, self.state) # Make sure root of external MIB Database exists self._seed_database() # Set up Response and Autonomous notification subscriptions try: for event, sub in self._omci_cc_sub_mapping.iteritems(): if self._omci_cc_subscriptions[event] is None: self._omci_cc_subscriptions[event] = \ self._device.omci_cc.event_bus.subscribe( topic=OMCI_CC.event_bus_topic(self._device_id, event), callback=sub) except Exception as e: self.log.exception('omci-cc-subscription-setup', e=e) # Set up ONU device subscriptions try: for event, sub in self._onu_dev_sub_mapping.iteritems(): if self._onu_dev_subscriptions[event] is None: self._onu_dev_subscriptions[event] = \ self._device.event_bus.subscribe( topic=OnuDeviceEntry.event_bus_topic(self._device_id, event), callback=sub) except Exception as e: self.log.exception('dev-subscription-setup', e=e) # Clear any previous audit results self._on_olt_only_diffs = None self._on_onu_only_diffs = None self._attr_diffs = None self._audited_olt_db = None self._audited_onu_db = None # Determine if this ONU has ever synchronized if self.is_new_onu: # Start full MIB upload self._deferred = reactor.callLater(0, self.upload_mib) else: # Examine the MIB Data Sync self._deferred = reactor.callLater(0, self.examine_mds)
def _subscribe_to_events(self): from voltha.extensions.omci.onu_device_entry import OnuDeviceEvents, \ OnuDeviceEntry, IN_SYNC_KEY from voltha.extensions.omci.omci_cc import OMCI_CC, OmciCCRxEvents, \ CONNECTED_KEY def in_sync_handler(_topic, msg): if self._in_sync_subscription is not None: try: in_sync = msg[IN_SYNC_KEY] if in_sync: # Only call this once as well (after PON enable) bus = self._onu_omci_device.event_bus bus.unsubscribe(self._in_sync_subscription) self._in_sync_subscription = None # Start up device_info load reactor.callLater(0, self._mib_in_sync) except Exception as e: self.log.exception('in-sync', e=e) def onu_is_reachable(_topic, msg): """ Reach-ability change event :param _topic: (str) subscription topic, not used :param msg: (dict) 'connected' key holds True if reachable """ if self._connectivity_subscription is not None: try: connected = msg[CONNECTED_KEY] # TODO: For now, only care about the first. # Later we could use this for a heartbeat, but may want some hysteresis # Cancel any 'reachable' subscriptions if connected: evt_bus = self._onu_omci_device.omci_cc.event_bus evt_bus.unsubscribe(self._connectivity_subscription) self._connectivity_subscription = None self._connected = True device = self._handler.adapter_agent.get_device(self._handler.device_id) device.oper_status = OperStatus.ACTIVE device.connect_status = ConnectStatus.REACHABLE self._handler.adapter_agent.update_device(device) except Exception as e: self.log.exception('onu-reachable', e=e) # OMCI MIB Database sync status bus = self._onu_omci_device.event_bus topic = OnuDeviceEntry.event_bus_topic(self._handler.device_id, OnuDeviceEvents.MibDatabaseSyncEvent) self._in_sync_subscription = bus.subscribe(topic, in_sync_handler) # OMCI-CC Connectivity Events (for reachbility/heartbeat) bus = self._onu_omci_device.omci_cc.event_bus topic = OMCI_CC.event_bus_topic(self._handler.device_id, OmciCCRxEvents.Connectivity) self._connectivity_subscription = bus.subscribe(topic, onu_is_reachable)
def on_enter_starting(self): """ Add the PON/ANI and UNI PM intervals""" self.advertise(OpenOmciEventType.state_change, self.state) self._device = self._agent.get_device(self._device_id) self._cancel_deferred() # Set up OMCI ME Response subscriptions try: for event, sub in self._omci_cc_sub_mapping.iteritems(): if self._omci_cc_subscriptions[event] is None: self._omci_cc_subscriptions[event] = \ self._device.omci_cc.event_bus.subscribe( topic=OMCI_CC.event_bus_topic(self._device_id, event), callback=sub) except Exception as e: self.log.exception('omci-cc-subscription-setup', e=e) try: # Manually start some ANI/PON and UNI PM interval MEs config = self._device.configuration anis = config.ani_g_entities unis = config.uni_g_entities if anis is not None: for entity_id in anis.iterkeys(): self.add_pm_me( FecPerformanceMonitoringHistoryData.class_id, entity_id) self.add_pm_me( XgPonTcPerformanceMonitoringHistoryData.class_id, entity_id) self.add_pm_me( XgPonDownstreamPerformanceMonitoringHistoryData. class_id, entity_id) self.add_pm_me( XgPonUpstreamPerformanceMonitoringHistoryData.class_id, entity_id) if unis is not None: for entity_id in config.uni_g_entities.iterkeys(): self.add_pm_me(EthernetPMMonitoringHistoryData.class_id, entity_id) # Look for existing instances of dynamically created ME's that have PM # associated with them and add them now for class_id in self._me_watch_list.iterkeys(): instances = { k: v for k, v in self._device.query_mib( class_id=class_id).items() if isinstance(k, int) } for entity_id, data in instances.items(): method = self._me_watch_list[class_id]['create-delete'] cid, eid = method(None, class_id, entity_id, add=True, attributes=data[ATTRIBUTES_KEY]) if cid > 0: # BP entity_id -> (PM class_id, PM entity_id) instances = self._me_watch_list[class_id]['instances'] instances[entity_id] = (cid, eid) except Exception as e: self.log.exception('pm-me-setup', class_id=class_id, e=e) # Got to synchronize_time state self._deferred = reactor.callLater(0, self.tick)