summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLadue, David (dl3158) <dl3158@att.com>2018-09-28 08:45:22 -0400
committerLadue, David (dl3158) <dl3158@att.com>2018-09-28 08:45:58 -0400
commitdbc128b6374c7c4ee1dd7634d4b43051093ada82 (patch)
tree4cc1ac7ce4815db4c5c25153c1bc856b0a92f6fb
parentaeae5597c7dcfa4cf432009c4668dd77aa6b84a1 (diff)
fix for V1 varbinds, V3 examples
Change-Id: Ic32dabbb356125384cc5eaa89f90e3c7c5c24128 Issue-ID: DCAEGEN2-842 Signed-off-by: Ladue, David (dl3158) <dl3158@att.com>
-rw-r--r--etc/snmptrapd.json279
-rw-r--r--snmptrap/snmptrapd.py85
-rw-r--r--tests/test_trapd_vb_types.py29
-rw-r--r--tmp/.blank0
4 files changed, 300 insertions, 93 deletions
diff --git a/etc/snmptrapd.json b/etc/snmptrapd.json
index 2061631..12e75c5 100644
--- a/etc/snmptrapd.json
+++ b/etc/snmptrapd.json
@@ -30,7 +30,7 @@
"location": "mtl5",
"client_id": null,
"client_role": null,
- "topic_url": "http://localhost:3904/events/ONAP-COLLECTOR-SNMPTRAP"
+ "topic_url": "http://localhost:3904/events/unauthenticated.ONAP-COLLECTOR-SNMPTRAP"
},
"aaf_username": null
}
@@ -52,56 +52,259 @@
"roll_frequency": "day",
"minimum_severity_to_log": 0
},
- "trap_config": {
- "sw_interval_in_seconds": 60,
- "notify_oids": {
- ".1.3.6.1.4.1.9.0.1": {
- "sw_high_water_in_interval": 102,
- "sw_low_water_in_interval": 7,
- "category": "logonly"
- },
- ".1.3.6.1.4.1.9.0.2": {
- "sw_high_water_in_interval": 101,
- "sw_low_water_in_interval": 7,
- "category": "logonly"
- },
- ".1.3.6.1.4.1.9.0.3": {
- "sw_high_water_in_interval": 102,
- "sw_low_water_in_interval": 7,
- "category": "logonly"
- },
- ".1.3.6.1.4.1.9.0.4": {
- "sw_high_water_in_interval": 10,
- "sw_low_water_in_interval": 3,
- "category": "logonly"
- }
- }
- },
"snmpv3_config": {
"usm_users": [
{
- "user": "usr-sha-aes256",
- "engineId": "8000000001020304",
- "usmHMACSHAAuth": "authkey1",
- "usmAesCfb256": "privkey1"
- },
- {
"user": "user1",
"engineId": "8000000000000001",
- "usmHMACMD5Auth": "authkey1",
- "usmDESPriv": "privkey1"
+ "usmHMACMD5AuthProtocol": "authkey1",
+ "usmDESPrivProtocol": "privkey1"
},
{
"user": "user2",
"engineId": "8000000000000002",
- "usmHMACSHAAuth": "authkey2",
- "usmAesCfb128": "privkey2"
+ "usmHMACMD5AuthProtocol": "authkey2",
+ "usm3DESEDEPrivProtocol": "privkey2"
},
{
"user": "user3",
"engineId": "8000000000000003",
- "usmHMACSHAAuth": "authkey3",
- "usmAesCfb256": "privkey3"
+ "usmHMACMD5AuthProtocol": "authkey3",
+ "usmAesCfb128Protocol": "privkey3"
+ },
+ {
+ "user": "user4",
+ "engineId": "8000000000000004",
+ "usmHMACMD5AuthProtocol": "authkey4",
+ "usmAesBlumenthalCfb192Protocol": "privkey4"
+ },
+ {
+ "user": "user5",
+ "engineId": "8000000000000005",
+ "usmHMACMD5AuthProtocol": "authkey5",
+ "usmAesBlumenthalCfb256Protocol": "privkey5"
+ },
+ {
+ "user": "user6",
+ "engineId": "8000000000000006",
+ "usmHMACMD5AuthProtocol": "authkey6",
+ "usmAesCfb192Protocol": "privkey6"
+ },
+ {
+ "user": "user7",
+ "engineId": "8000000000000007",
+ "usmHMACMD5AuthProtocol": "authkey7",
+ "usmAesCfb256Protocol": "privkey7"
+ },
+ {
+ "user": "user9",
+ "engineId": "8000000000000009",
+ "usmHMACSHAAuthProtocol": "authkey9",
+ "usmDESPrivProtocol": "privkey9"
+ },
+ {
+ "user": "user10",
+ "engineId": "8000000000000010",
+ "usmHMACSHAAuthProtocol": "authkey10",
+ "usm3DESEDEPrivProtocol": "privkey10"
+ },
+ {
+ "user": "user11",
+ "engineId": "8000000000000011",
+ "usmHMACSHAAuthProtocol": "authkey11",
+ "usmAesCfb128Protocol": "privkey11"
+ },
+ {
+ "user": "user12",
+ "engineId": "8000000000000012",
+ "usmHMACSHAAuthProtocol": "authkey12",
+ "usmAesBlumenthalCfb192Protocol": "privkey12"
+ },
+ {
+ "user": "user13",
+ "engineId": "8000000000000013",
+ "usmHMACSHAAuthProtocol": "authkey13",
+ "usmAesBlumenthalCfb256Protocol": "privkey13"
+ },
+ {
+ "user": "user14",
+ "engineId": "8000000000000014",
+ "usmHMACSHAAuthProtocol": "authkey14",
+ "usmAesCfb192Protocol": "privkey14"
+ },
+ {
+ "user": "user15",
+ "engineId": "8000000000000015",
+ "usmHMACSHAAuthProtocol": "authkey15",
+ "usmAesCfb256Protocol": "privkey15"
+ },
+ {
+ "user": "user17",
+ "engineId": "8000000000000017",
+ "usmHMAC128SHA224AuthProtocol": "authkey17",
+ "usmDESPrivProtocol": "privkey17"
+ },
+ {
+ "user": "user18",
+ "engineId": "8000000000000018",
+ "usmHMAC128SHA224AuthProtocol": "authkey18",
+ "usm3DESEDEPrivProtocol": "privkey18"
+ },
+ {
+ "user": "user19",
+ "engineId": "8000000000000019",
+ "usmHMAC128SHA224AuthProtocol": "authkey19",
+ "usmAesCfb128Protocol": "privkey19"
+ },
+ {
+ "user": "user20",
+ "engineId": "8000000000000020",
+ "usmHMAC128SHA224AuthProtocol": "authkey20",
+ "usmAesBlumenthalCfb192Protocol": "privkey20"
+ },
+ {
+ "user": "user21",
+ "engineId": "8000000000000021",
+ "usmHMAC128SHA224AuthProtocol": "authkey21",
+ "usmAesBlumenthalCfb256Protocol": "privkey21"
+ },
+ {
+ "user": "user22",
+ "engineId": "8000000000000022",
+ "usmHMAC128SHA224AuthProtocol": "authkey22",
+ "usmAesCfb192Protocol": "privkey22"
+ },
+ {
+ "user": "user23",
+ "engineId": "8000000000000023",
+ "usmHMAC128SHA224AuthProtocol": "authkey23",
+ "usmAesCfb256Protocol": "privkey23"
+ },
+ {
+ "user": "user25",
+ "engineId": "8000000000000025",
+ "usmHMAC192SHA256AuthProtocol": "authkey25",
+ "usmDESPrivProtocol": "privkey25"
+ },
+ {
+ "user": "user26",
+ "engineId": "8000000000000026",
+ "usmHMAC192SHA256AuthProtocol": "authkey26",
+ "usm3DESEDEPrivProtocol": "privkey26"
+ },
+ {
+ "user": "user27",
+ "engineId": "8000000000000027",
+ "usmHMAC192SHA256AuthProtocol": "authkey27",
+ "usmAesCfb128Protocol": "privkey27"
+ },
+ {
+ "user": "user28",
+ "engineId": "8000000000000028",
+ "usmHMAC192SHA256AuthProtocol": "authkey28",
+ "usmAesBlumenthalCfb192Protocol": "privkey28"
+ },
+ {
+ "user": "user29",
+ "engineId": "8000000000000029",
+ "usmHMAC192SHA256AuthProtocol": "authkey29",
+ "usmAesBlumenthalCfb256Protocol": "privkey29"
+ },
+ {
+ "user": "user30",
+ "engineId": "8000000000000030",
+ "usmHMAC192SHA256AuthProtocol": "authkey30",
+ "usmAesCfb192Protocol": "privkey30"
+ },
+ {
+ "user": "user31",
+ "engineId": "8000000000000031",
+ "usmHMAC192SHA256AuthProtocol": "authkey31",
+ "usmAesCfb256Protocol": "privkey31"
+ },
+ {
+ "user": "user33",
+ "engineId": "8000000000000033",
+ "usmHMAC256SHA384AuthProtocol": "authkey33",
+ "usmDESPrivProtocol": "privkey33"
+ },
+ {
+ "user": "user34",
+ "engineId": "8000000000000034",
+ "usmHMAC256SHA384AuthProtocol": "authkey34",
+ "usm3DESEDEPrivProtocol": "privkey34"
+ },
+ {
+ "user": "user35",
+ "engineId": "8000000000000035",
+ "usmHMAC256SHA384AuthProtocol": "authkey35",
+ "usmAesCfb128Protocol": "privkey35"
+ },
+ {
+ "user": "user36",
+ "engineId": "8000000000000036",
+ "usmHMAC256SHA384AuthProtocol": "authkey36",
+ "usmAesBlumenthalCfb192Protocol": "privkey36"
+ },
+ {
+ "user": "user37",
+ "engineId": "8000000000000037",
+ "usmHMAC256SHA384AuthProtocol": "authkey37",
+ "usmAesBlumenthalCfb256Protocol": "privkey37"
+ },
+ {
+ "user": "user38",
+ "engineId": "8000000000000038",
+ "usmHMAC256SHA384AuthProtocol": "authkey38",
+ "usmAesCfb192Protocol": "privkey38"
+ },
+ {
+ "user": "user39",
+ "engineId": "8000000000000039",
+ "usmHMAC256SHA384AuthProtocol": "authkey39",
+ "usmAesCfb256Protocol": "privkey39"
+ },
+ {
+ "user": "user41",
+ "engineId": "8000000000000041",
+ "usmHMAC384SHA512AuthProtocol": "authkey41",
+ "usmDESPrivProtocol": "privkey41"
+ },
+ {
+ "user": "user42",
+ "engineId": "8000000000000042",
+ "usmHMAC384SHA512AuthProtocol": "authkey42",
+ "usm3DESEDEPrivProtocol": "privkey42"
+ },
+ {
+ "user": "user43",
+ "engineId": "8000000000000043",
+ "usmHMAC384SHA512AuthProtocol": "authkey43",
+ "usmAesCfb128Protocol": "privkey43"
+ },
+ {
+ "user": "user44",
+ "engineId": "8000000000000044",
+ "usmHMAC384SHA512AuthProtocol": "authkey44",
+ "usmAesBlumenthalCfb192Protocol": "privkey44"
+ },
+ {
+ "user": "user45",
+ "engineId": "8000000000000045",
+ "usmHMAC384SHA512AuthProtocol": "authkey45",
+ "usmAesBlumenthalCfb256Protocol": "privkey45"
+ },
+ {
+ "user": "user46",
+ "engineId": "8000000000000046",
+ "usmHMAC384SHA512AuthProtocol": "authkey46",
+ "usmAesCfb192Protocol": "privkey46"
+ },
+ {
+ "user": "user47",
+ "engineId": "8000000000000047",
+ "usmHMAC384SHA512AuthProtocol": "authkey47",
+ "usmAesCfb256Protocol": "privkey47"
}
]
}
diff --git a/snmptrap/snmptrapd.py b/snmptrap/snmptrapd.py
index 325aa55..d2b53f3 100644
--- a/snmptrap/snmptrapd.py
+++ b/snmptrap/snmptrapd.py
@@ -188,7 +188,7 @@ def log_all_arriving_traps():
# going for:
# 1520971776 Tue Mar 13 16:09:36 2018; 1520971776 2018-03-13 16:09:36 DCAE-COLLECTOR-UCSNMP 15209717760049 .1.3.6.1.4.1.2636.4.1.6 gfpmt5pcs10.oss.att.com 135.91.10.139 12.123.1.240 12.123.1.240 2 varbinds: [0] .1.3.6.1.2.1.1.3.0 {10} 1212058366 140 days, 6:49:43.66 [1] .1.3.6.1.6.3.1.1.4.1.0 {6} .1.3.6.1.4.1.2636.4.1.6 [2] .1.3.6.1.4.1.2636.3.1.15.1.1.2.4.0.0 {2} 2 [3] .1.3.6.1.4.1.2636.3.1.15.1.2.2.4.0.0 {2} 4 [4] .1.3.6.1.4.1.2636.3.1.15.1.3.2.4.0.0 {2} 0 [5] .1.3.6.1.4.1.2636.3.1.15.1.4.2.4.0.0 {2} 0 [6] .1.3.6.1.4.1.2636.3.1.15.1.5.2.4.0.0 {4} PEM 3 [7] .1.3.6.1.4.1.2636.3.1.15.1.6.2.4.0.0 {2} 7 [8] .1.3.6.1.4.1.2636.3.1.15.1.7.2.4.0.0 {2} 4 [9] .1.3.6.1.6.3.18.1.3.0 {7} 12.123.1.240
- tds.arriving_traps_fd.write('%s %s; %s %s %s %s %s %s %s %s %s %s %s\n' %
+ tds.arriving_traps_fd.write('%s %s; %s %s %s %s %s %s %s %s %s %s\n' %
(tds.trap_dict["time received"],
time.strftime(
"%a %b %d %H:%M:%S %Y", time.localtime(time.time())),
@@ -201,7 +201,6 @@ def log_all_arriving_traps():
tds.trap_dict["agent address"],
tds.trap_dict["cambria.partition"],
tds.trap_dict["protocol version"],
- tds.trap_dict["sysUptime"],
tds.trap_dict["uuid"],
tds.all_vb_json_str))
@@ -458,27 +457,27 @@ def snmp_engine_observer_cb(snmp_engine, execpoint, variables, cbCtx):
snmp_version = variables['securityModel']
if snmp_version == 1:
tds.trap_dict["protocol version"] = "v1"
- enterprise = variables['pdu']['enterprise'].prettyPrint()
- generic_trap = variables['pdu']['generic-trap']
- specific_trap = variables['pdu']['specific-trap']
- if generic_trap < 6:
- tds.trap_dict["notify OID"] = str(enterprise) + "." + str(specific_trap)
- else:
- tds.trap_dict["notify OID"] = str(enterprise) + ".0." + str(specific_trap)
- tds.trap_dict["notify OID len"] = (tds.trap_dict["notify OID"].count('.') + 1)
- tds.trap_dict["sysUptime"] = variables['pdu']['time-stamp'].prettyPrint()
+ # enterprise = variables['pdu']['enterprise'].prettyPrint()
+ # generic_trap = variables['pdu']['generic-trap']
+ # specific_trap = variables['pdu']['specific-trap']
+ # if generic_trap < 6:
+ # tds.trap_dict["notify OID"] = "." + str(enterprise) + "." + str(specific_trap)
+ # else:
+ # tds.trap_dict["notify OID"] = "." + str(enterprise) + ".0." + str(specific_trap)
+ # tds.trap_dict["notify OID len"] = tds.trap_dict["notify OID"].count('.')
+ # tds.trap_dict["sysUptime"] = variables['pdu']['time-stamp'].prettyPrint()
else:
if snmp_version == 2:
tds.trap_dict["protocol version"] = "v2c"
else:
if snmp_version == 3:
tds.trap_dict["protocol version"] = "v3"
- tds.trap_dict["security level"] = str(variables['securityLevel'])
- tds.trap_dict["context name"] = str(
- variables['contextName'].prettyPrint())
- tds.trap_dict["security name"] = str(variables['securityName'])
- tds.trap_dict["security engine"] = str(
- variables['contextEngineId'].prettyPrint())
+ # tds.trap_dict["security level"] = str(variables['securityLevel'])
+ # tds.trap_dict["context name"] = str(
+ # variables['contextName'].prettyPrint())
+ # tds.trap_dict["security name"] = str(variables['securityName'])
+ # tds.trap_dict["security engine"] = str(
+ # variables['contextEngineId'].prettyPrint())
else:
tds.trap_dict["protocol version"] = "unknown"
@@ -512,18 +511,25 @@ def add_varbind_to_json(vb_idx, vb_oid, vb_type, vb_val):
_individual_vb_dict = {}
- if tds.trap_dict["protocol version"] == "v2c" or tds.trap_dict["protocol version"] == "v3":
- # if v2c and first 2 varbinds, special handling required - e.g. put
- # in trap_dict, not vb_json_str
- if vb_idx == 0:
- tds.trap_dict["sysUptime"] = str(vb_val.prettyPrint())
- return True
- else:
- if vb_idx == 1:
- tds.trap_dict["notify OID"] = str(vb_val.prettyPrint())
- tds.trap_dict["notify OID len"] = (
- tds.trap_dict["notify OID"].count('.') + 1)
- return True
+ # if first varbind (sysUptime), always return immediately as
+ # we don't publish sysUptime
+ if vb_idx == 0:
+ return 0
+
+ # if second varbind, use as notifyOID for all snmp versions
+ if vb_idx == 1:
+ tds.trap_dict["notify OID"] = "." + str(vb_val.prettyPrint())
+ tds.trap_dict["notify OID len"] = tds.trap_dict["notify OID"].count('.')
+ return 0
+
+ # for SNMPv1 traps, skip varbinds 2, 3 and 4:
+ # - .1.3.6.1.6.3.18.1.3.0 agent override
+ # - .1.3.6.1.6.3.18.1.4.0 community string
+ # - .1.3.6.1.6.3.1.1.4.3.0 V1 enterprise in original trap
+ if tds.trap_dict["protocol version"] == "v1":
+ if vb_idx < 5:
+ return 0
+
if tds.first_varbind:
tds.all_vb_json_str = ', \"varbinds\": ['
tds.first_varbind = False
@@ -531,14 +537,14 @@ def add_varbind_to_json(vb_idx, vb_oid, vb_type, vb_val):
tds.all_vb_json_str = tds.all_vb_json_str + " ,"
_individual_vb_dict.clear()
- _individual_vb_dict['varbind_oid'] = vb_oid.prettyPrint()
+ _individual_vb_dict['varbind_oid'] = "." + vb_oid.prettyPrint()
_individual_vb_dict['varbind_type'] = pysnmp_to_netsnmp_varbind_convert(vb_type)
_individual_vb_dict['varbind_value'] = vb_val.prettyPrint()
_individual_vb_json_str = json.dumps(_individual_vb_dict)
tds.all_vb_json_str = tds.all_vb_json_str + _individual_vb_json_str
- return True
+ return 1
# Callback function for receiving notifications
@@ -576,22 +582,22 @@ def notif_receiver_cb(snmp_engine, stateReference, contextEngineId, contextName,
# print(key, val)
# FMDL update reset location when batching publishes
- vb_idx = 0
-
+ pdu_varbinds = 0
+ payload_varbinds = 0
tds.all_vb_json_str = ""
- vb_idx = 0
tds.first_varbind = True
# iterate over varbinds, add to json struct
for vb_oid, vb_val in varBinds:
- add_varbind_to_json(vb_idx, vb_oid, vb_val.__class__.__name__, vb_val)
- vb_idx += 1
+ varbinds_added = add_varbind_to_json(pdu_varbinds, vb_oid, vb_val.__class__.__name__, vb_val)
+ payload_varbinds += varbinds_added
+ pdu_varbinds += 1
curr_trap_json_str = json.dumps(tds.trap_dict)
# now have everything except varbinds in "curr_trap_json_str"
# if varbinds present - which will almost always be the case - add all_vb_json_str to trap_json_message
- if vb_idx != 0:
+ if payload_varbinds != 0:
# close out vb array
tds.all_vb_json_str = tds.all_vb_json_str + ']'
@@ -689,8 +695,9 @@ if __name__ == "__main__":
tds.minimum_severity_to_log = 0
stdout_logger(msg)
# use specific flags or 'all' for full debugging
- help(debug.setLogger)
- debug.setLogger(debug.Debug('dsp', 'msgproc'))
+ # debug.setLogger(debug.Debug('dsp', 'msgproc'))
+ debug.setLogger(debug.Debug('all'))
+
# name and open arriving trap log
tds.arriving_traps_filename = tds.c_config['files']['runtime_base_dir'] + "/" + \
diff --git a/tests/test_trapd_vb_types.py b/tests/test_trapd_vb_types.py
index 4af9235..67c9233 100644
--- a/tests/test_trapd_vb_types.py
+++ b/tests/test_trapd_vb_types.py
@@ -7,7 +7,7 @@ from onap_dcae_cbs_docker_client.client import get_config
from trapd_exit import cleanup_and_exit
from trapd_io import stdout_logger, ecomp_logger
import trapd_settings as tds
-import trapd_snmpv3
+import trapd_vb_types
from pysnmp.entity import engine, config
@@ -16,30 +16,27 @@ class test_trapd_vb_types(unittest.TestCase):
Test snmpv3 module
"""
- def trapd_vb_type_conversions(self):
+ def trapd_vb_type_conversion_valid(self):
"""
Test that pysnmp varbind types convert to netsnmp
"""
- # del os.environ['CBS_SIM_JSON']
- # result = trapd_get_cbs_config.get_cbs_config()
- # print("result: %s" % result)
- # compare = str(result).startswith("{'snmptrap': ")
- # self.assertEqual(compare, False)
tds.c_config = json.loads("{ \"snmptrapd\": { \"version\": \"1.4.0\", \"title\": \"ONAP SNMP Trap Receiver\" }, \"protocols\": { \"transport\": \"udp\", \"ipv4_interface\": \"0.0.0.0\", \"ipv4_port\": 6162, \"ipv6_interface\": \"::1\", \"ipv6_port\": 6162 }, \"cache\": { \"dns_cache_ttl_seconds\": 60 }, \"publisher\": { \"http_timeout_milliseconds\": 1500, \"http_retries\": 3, \"http_milliseconds_between_retries\": 750, \"http_primary_publisher\": \"true\", \"http_peer_publisher\": \"unavailable\", \"max_traps_between_publishes\": 10, \"max_milliseconds_between_publishes\": 10000 }, \"streams_publishes\": { \"sec_fault_unsecure\": { \"type\": \"message_router\", \"aaf_password\": null, \"dmaap_info\": { \"location\": \"mtl5\", \"client_id\": null, \"client_role\": null, \"topic_url\": \"http://localhost:3904/events/ONAP-COLLECTOR-SNMPTRAP\" }, \"aaf_username\": null } }, \"files\": { \"runtime_base_dir\": \"/tmp/opt/app/snmptrap\", \"log_dir\": \"logs\", \"data_dir\": \"data\", \"pid_dir\": \"tmp\", \"arriving_traps_log\": \"snmptrapd_arriving_traps.log\", \"snmptrapd_diag\": \"snmptrapd_prog_diag.log\", \"traps_stats_log\": \"snmptrapd_stats.csv\", \"perm_status_file\": \"snmptrapd_status.log\", \"eelf_base_dir\": \"/tmp/opt/app/snmptrap/logs\", \"eelf_error\": \"error.log\", \"eelf_debug\": \"debug.log\", \"eelf_audit\": \"audit.log\", \"eelf_metrics\": \"metrics.log\", \"roll_frequency\": \"day\", \"minimum_severity_to_log\": 2 }, \"trap_config\": { \"sw_interval_in_seconds\": 60, \"notify_oids\": { \".1.3.6.1.4.1.9.0.1\": { \"sw_high_water_in_interval\": 102, \"sw_low_water_in_interval\": 7, \"category\": \"logonly\" }, \".1.3.6.1.4.1.9.0.2\": { \"sw_high_water_in_interval\": 101, \"sw_low_water_in_interval\": 7, \"category\": \"logonly\" }, \".1.3.6.1.4.1.9.0.3\": { \"sw_high_water_in_interval\": 102, \"sw_low_water_in_interval\": 7, \"category\": \"logonly\" }, \".1.3.6.1.4.1.9.0.4\": { \"sw_high_water_in_interval\": 10, \"sw_low_water_in_interval\": 3, \"category\": \"logonly\" } } } }")
- # del os.environ['CBS_SIM_JSON']
- # result = trapd_get_cbs_config.get_cbs_config()
- # print("result: %s" % result)
- # compare = str(result).startswith("{'snmptrap': ")
- # self.assertEqual(compare, False)
-
good_varbind_types = ["Integer", "Unsigned32", "Counter32", "OctetString", "ObjectIdentifier", "TimeTicks", "IpAddress"]
- result = pysnmp_to_netsnmp_varbind_convert("Integer")
-
- assert pytest_wrapped_sys_exit.type == SystemExit
+ result = trapd_vb_types.pysnmp_to_netsnmp_varbind_convert("Integer")
self.assertEqual(result, "integer")
+ def trapd_vb_type_conversion_invalid(self):
+ """
+ Test that pysnmp varbind types convert to netsnmp
+ """
+
+ tds.c_config = json.loads("{ \"snmptrapd\": { \"version\": \"1.4.0\", \"title\": \"ONAP SNMP Trap Receiver\" }, \"protocols\": { \"transport\": \"udp\", \"ipv4_interface\": \"0.0.0.0\", \"ipv4_port\": 6162, \"ipv6_interface\": \"::1\", \"ipv6_port\": 6162 }, \"cache\": { \"dns_cache_ttl_seconds\": 60 }, \"publisher\": { \"http_timeout_milliseconds\": 1500, \"http_retries\": 3, \"http_milliseconds_between_retries\": 750, \"http_primary_publisher\": \"true\", \"http_peer_publisher\": \"unavailable\", \"max_traps_between_publishes\": 10, \"max_milliseconds_between_publishes\": 10000 }, \"streams_publishes\": { \"sec_fault_unsecure\": { \"type\": \"message_router\", \"aaf_password\": null, \"dmaap_info\": { \"location\": \"mtl5\", \"client_id\": null, \"client_role\": null, \"topic_url\": \"http://localhost:3904/events/ONAP-COLLECTOR-SNMPTRAP\" }, \"aaf_username\": null } }, \"files\": { \"runtime_base_dir\": \"/tmp/opt/app/snmptrap\", \"log_dir\": \"logs\", \"data_dir\": \"data\", \"pid_dir\": \"tmp\", \"arriving_traps_log\": \"snmptrapd_arriving_traps.log\", \"snmptrapd_diag\": \"snmptrapd_prog_diag.log\", \"traps_stats_log\": \"snmptrapd_stats.csv\", \"perm_status_file\": \"snmptrapd_status.log\", \"eelf_base_dir\": \"/tmp/opt/app/snmptrap/logs\", \"eelf_error\": \"error.log\", \"eelf_debug\": \"debug.log\", \"eelf_audit\": \"audit.log\", \"eelf_metrics\": \"metrics.log\", \"roll_frequency\": \"day\", \"minimum_severity_to_log\": 2 }, \"trap_config\": { \"sw_interval_in_seconds\": 60, \"notify_oids\": { \".1.3.6.1.4.1.9.0.1\": { \"sw_high_water_in_interval\": 102, \"sw_low_water_in_interval\": 7, \"category\": \"logonly\" }, \".1.3.6.1.4.1.9.0.2\": { \"sw_high_water_in_interval\": 101, \"sw_low_water_in_interval\": 7, \"category\": \"logonly\" }, \".1.3.6.1.4.1.9.0.3\": { \"sw_high_water_in_interval\": 102, \"sw_low_water_in_interval\": 7, \"category\": \"logonly\" }, \".1.3.6.1.4.1.9.0.4\": { \"sw_high_water_in_interval\": 10, \"sw_low_water_in_interval\": 3, \"category\": \"logonly\" } } } }")
+
+ result = trapd_vb_types.pysnmp_to_netsnmp_varbind_convert("noSuchVarbindType")
+ self.assertEqual(result, "octet")
+
if __name__ == '__main__':
unittest.main()
diff --git a/tmp/.blank b/tmp/.blank
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tmp/.blank