(cls, instance)
Generate a Security Parameters object based on the instance's
        configuration.
Generate a Security Parameters object based on the instance's
        configuration.
Generate a Security Parameters object based on the instance s configuration .
def get_auth_data(cls, instance):
        # type: (Dict[str, Any]) -> Any
        """
        Generate a Security Parameters object based on the instance's
        configuration.
        """
        if 'community_string' in instance:
            # SNMP v1 - SNMP v2
            # See http://snmplabs.com/pysnmp/docs/api-reference.html#pysnmp.hlapi.CommunityData
            if int(instance.get('snmp_version', 2)) == 1:
                return CommunityData(instance['community_string'], mpModel=0)
            return CommunityData(instance['community_string'], mpModel=1)

        if 'user' in instance:
            # SNMP v3
            user = instance['user']
            auth_key = None
            priv_key = None
            auth_protocol = None
            priv_protocol = None

            if 'authKey' in instance:
                auth_key = instance['authKey']
                auth_protocol = usmHMACMD5AuthProtocol

            if 'privKey' in instance:
                priv_key = instance['privKey']
                auth_protocol = usmHMACMD5AuthProtocol
                priv_protocol = usmDESPrivProtocol

            if 'authProtocol' in instance:
                protocol_name = instance['authProtocol']
                if protocol_name.lower() in cls.AUTH_PROTOCOL_MAPPING:
                    protocol_name = cls.AUTH_PROTOCOL_MAPPING[protocol_name.lower()]
                auth_protocol = getattr(hlapi, protocol_name)

            if 'privProtocol' in instance:
                protocol_name = instance['privProtocol']
                if protocol_name.lower() in cls.PRIV_PROTOCOL_MAPPING:
                    protocol_name = cls.PRIV_PROTOCOL_MAPPING[protocol_name.lower()]
                priv_protocol = getattr(hlapi, protocol_name)

            return UsmUserData(user, auth_key, priv_key, auth_protocol, priv_protocol)

        raise ConfigurationError('An authentication method needs to be provided')
def get_auth_data ( cls , instance ) : # type: (Dict[str, Any]) -> Any if 'community_string' in instance : # SNMP v1 - SNMP v2 # See http://snmplabs.com/pysnmp/docs/api-reference.html#pysnmp.hlapi.CommunityData if int ( instance . get ( 'snmp_version' , 2 ) ) == 1 : return CommunityData ( instance [ 'community_string' ] , mpModel = 0 ) return CommunityData ( instance [ 'community_string' ] , mpModel = 1 ) if 'user' in instance : # SNMP v3 user = instance [ 'user' ] auth_key = None priv_key = None auth_protocol = None priv_protocol = None if 'authKey' in instance : auth_key = instance [ 'authKey' ] auth_protocol = usmHMACMD5AuthProtocol if 'privKey' in instance : priv_key = instance [ 'privKey' ] auth_protocol = usmHMACMD5AuthProtocol priv_protocol = usmDESPrivProtocol if 'authProtocol' in instance : protocol_name = instance [ 'authProtocol' ] if protocol_name . lower ( ) in cls . AUTH_PROTOCOL_MAPPING : protocol_name = cls . AUTH_PROTOCOL_MAPPING [ protocol_name . lower ( ) ] auth_protocol = getattr ( hlapi , protocol_name ) if 'privProtocol' in instance : protocol_name = instance [ 'privProtocol' ] if protocol_name . lower ( ) in cls . PRIV_PROTOCOL_MAPPING : protocol_name = cls . PRIV_PROTOCOL_MAPPING [ protocol_name . lower ( ) ] priv_protocol = getattr ( hlapi , protocol_name ) return UsmUserData ( user , auth_key , priv_key , auth_protocol , priv_protocol ) raise ConfigurationError ( 'An authentication method needs to be provided' )