Exemplo n.º 1
0
    def base(self, device=None, netbox=None, subid='', varmap=None, alert_type=None):
        """Creates and returns an event base template

        :param device: A nav.models.manage.Device object or primary key.
        :param netbox: A nav.models.manage.Netbox object or primary key.
        :param subid: A subid string, if applicable.
        :param varmap: A dictionary of arbitrary event variables to attach.
        :param alert_type: An option alert type hint for eventEngine; useful
                           for cases where eventEngine has no specific plugin.
        :return:
        """
        event = EventQueue()
        event.source_id = self.source
        event.target_id = self.target
        event.event_type_id = self.event_type

        if isinstance(device, int):
            event.device_id = device
        else:
            event.device = device

        if isinstance(netbox, int):
            event.netbox_id = netbox
        else:
            event.netbox = netbox

        event.subid = str(subid)

        var = dict(varmap or {})
        if alert_type:
            var['alerttype'] = alert_type
        event.varmap = var

        return event
Exemplo n.º 2
0
 def _make_snmpagentstate_event(self):
     event = Event()
     event.source_id = 'ipdevpoll'
     event.target_id = 'eventEngine'
     event.netbox_id = self.netbox.id
     event.event_type_id = 'snmpAgentState'
     return event
Exemplo n.º 3
0
    def _make_linkstate_event(self, start=True):
        django_ifc = self.get_existing_model()
        event = Event()
        event.source_id = 'ipdevpoll'
        event.target_id = 'eventEngine'
        event.netbox_id = self.netbox.id
        event.device = django_ifc.netbox.device
        event.subid = self.id
        event.event_type_id = 'linkState'
        event.state = event.STATE_START if start else event.STATE_END
        event.save()

        EventVar(event_queue=event, variable='alerttype',
                 value='linkDown' if start else 'linkUp').save()
        EventVar(event_queue=event, variable='interface',
                 value=self.ifname).save()
        EventVar(event_queue=event, variable='ifalias',
                 value=django_ifc.ifalias or '').save()
Exemplo n.º 4
0
    def _get_aggregate_link_event(self, start):
        target = self.get_target()
        aggregator = target.get_aggregator()
        event = Event()
        event.source_id = event.target_id = 'eventEngine'
        event.netbox_id = aggregator.netbox_id
        event.subid = aggregator.id
        event.event_type_id = 'aggregateLinkState'
        event.state = event.STATE_START if start else event.STATE_END
        event.save()

        EventVar(event_queue=event,
                 variable='alerttype',
                 value='linkDegraded' if start else 'linkRestored').save()
        EventVar(event_queue=event, variable='aggregate',
                 value=target.id).save()
        EventVar(event_queue=event,
                 variable='aggregate_ifname',
                 value=target.ifname).save()
        EventVar(event_queue=event,
                 variable='aggregate_ifalias',
                 value=target.ifalias or '').save()