Ejemplo n.º 1
0
    def sendNotification(self, authData, transportTarget, notifyType,
                         notificationType, *varBinds, **kwargs):
        if 'lookupNames' not in kwargs:
            kwargs['lookupNames'] = False
        if 'lookupValues' not in kwargs:
            kwargs['lookupValues'] = False
        if not isinstance(notificationType,
                          (ObjectIdentity, ObjectType, NotificationType)):
            if isinstance(notificationType[0], tuple):
                # legacy
                notificationType = ObjectIdentity(notificationType[0][0], notificationType[0][1], *notificationType[1:])
            else:
                notificationType = ObjectIdentity(notificationType)

        if not isinstance(notificationType, NotificationType):
            notificationType = NotificationType(notificationType)

        for (errorIndication,
             errorStatus,
             errorIndex,
             rspVarBinds) in sync.sendNotification(self.snmpEngine, authData,
                                                   transportTarget,
                                                   ContextData(kwargs.get('contextEngineId'),
                                                               kwargs.get('contextName', null)),
                                                   notifyType,
                                                   notificationType.addVarBinds(*varBinds),
                                                   **kwargs):
            if notifyType == 'inform':
                return errorIndication, errorStatus, errorIndex, rspVarBinds
            else:
                break
Ejemplo n.º 2
0
    def sendNotification(self, authData, transportTarget, notifyType,
                         notificationType, *varBinds, **kwargs):
        if 'lookupNames' not in kwargs:
            kwargs['lookupNames'] = False
        if 'lookupValues' not in kwargs:
            kwargs['lookupValues'] = False
        if not isinstance(notificationType,
                          (ObjectIdentity, ObjectType, NotificationType)):
            if isinstance(notificationType[0], tuple):
                # legacy
                notificationType = ObjectIdentity(notificationType[0][0], notificationType[0][1], *notificationType[1:])
            else:
                notificationType = ObjectIdentity(notificationType)

        if not isinstance(notificationType, NotificationType):
            notificationType = NotificationType(notificationType)
        errorIndication, errorStatus, errorIndex, rspVarBinds = None, 0, 0, []
        for errorIndication, \
            errorStatus, errorIndex, \
            rspVarBinds \
            in sync.sendNotification(self.snmpEngine, authData,
                                     transportTarget,
                                     ContextData(
                                         kwargs.get('contextEngineId'),
                                         kwargs.get('contextName', null)
                                     ),
                                     notifyType,
                                     notificationType.addVarBinds(*varBinds),
                                     **kwargs):
            if notifyType == 'inform':
                return errorIndication, errorStatus, errorIndex, rspVarBinds
            else:
                break