def _subscribe_to_events(self):
        self.log.debug('function-entry')

        # OMCI MIB Database sync status
        bus = self._onu_omci_device.event_bus
        topic = OnuDeviceEntry.event_bus_topic(self.device_id,
                                               OnuDeviceEvents.MibDatabaseSyncEvent)
        self._in_sync_subscription = bus.subscribe(topic, self.in_sync_handler)

        # OMCI Capabilities
        bus = self._onu_omci_device.event_bus
        topic = OnuDeviceEntry.event_bus_topic(self.device_id,
                                               OnuDeviceEvents.OmciCapabilitiesEvent)
        self._capabilities_subscription = bus.subscribe(topic, self.capabilties_handler)
Beispiel #2
0
    def on_enter_out_of_sync(self):
        """
        State machine has just started or the MIB database has transitioned
        to an out-of-synchronization state
        """
        self.advertise(OpenOmciEventType.state_change, self.state)
        self._cancel_deferred()
        self._device = self._agent.get_device(self._device_id)

        # Subscribe to events of interest
        try:
            for event, sub in six.iteritems(self._sub_mapping):
                if self._subscriptions[event] is None:
                    self._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('subscription-setup', e=e)

        # Periodically check/poll for in-sync in case subscription was missed or
        # already in sync
        self._deferred = reactor.callLater(0, self.check_in_sync)
Beispiel #3
0
    def _subscribe_to_events(self):
        from pyvoltha.adapters.extensions.omci.onu_device_entry import OnuDeviceEvents, \
            OnuDeviceEntry

        # OMCI MIB Database sync status
        bus = self.openomci.onu_omci_device.event_bus
        topic = OnuDeviceEntry.event_bus_topic(
            self.device_id, OnuDeviceEvents.MibDatabaseSyncEvent)
        self._in_sync_subscription = bus.subscribe(topic, self.in_sync_handler)
Beispiel #4
0
    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 six.iteritems(self._omci_cc_sub_mapping):
                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 six.iteritems(self._onu_dev_sub_mapping):
                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:
            # clear resync failure counter if we "started over"
            self._failed_resync_count = 0
            # Attempt to load a MIB template then start full MIB upload if needed
            self._deferred = reactor.callLater(0, self.load_mib_template)

        else:
            # Examine the MIB Data Sync
            self._deferred = reactor.callLater(0, self.examine_mds)
Beispiel #5
0
    def add_device(self,
                   device_id,
                   core_proxy,
                   adapter_proxy,
                   custom_me_map=None,
                   support_classes=OpenOmciAgentDefaults):
        """
        Add a new ONU to be managed.

        To provide vendor-specific or custom Managed Entities, create your own Entity
        ID to class mapping dictionary.

        Since ONU devices can be added at any time (even during Device Handler
        startup), the ONU device handler is responsible for calling start()/stop()
        for this object.

        :param device_id: (str) Device ID of ONU to add
        :param core_proxy: (CoreProxy) Remote API to VOLTHA core
        :param adapter_proxy: (AdapterProxy) Remote API to other adapters via VOLTHA core
        :param custom_me_map: (dict) Additional/updated ME to add to class map
        :param support_classes: (dict) State machines and tasks for this ONU

        :return: (OnuDeviceEntry) The ONU device
        """
        self.log.debug('OpenOMCIAgent.add-device', device_id=device_id)

        device = self._devices.get(device_id)

        if device is None:
            device = OnuDeviceEntry(self,
                                    device_id,
                                    core_proxy,
                                    adapter_proxy,
                                    custom_me_map,
                                    self._mib_db,
                                    self._alarm_db,
                                    support_classes,
                                    clock=self.reactor)

            self._devices[device_id] = device

        return device