[Git][NTPsec/ntpsec][master] 3 commits: Added ntpsnmpd-man.txt.
Ian Bruene
gitlab at mg.gitlab.com
Sun Feb 18 16:48:14 UTC 2018
Ian Bruene pushed to branch master at NTPsec / ntpsec
Commits:
cd05b39b by Ian Bruene at 2018-02-18T10:47:53-06:00
Added ntpsnmpd-man.txt.
- - - - -
0c45e067 by Ian Bruene at 2018-02-18T10:47:53-06:00
Removed and updated obsolete comments.
- - - - -
9098486a by Ian Bruene at 2018-02-18T10:47:53-06:00
Removed redundant "static" key in MIB trees.
The "static" key was used by the tree walker to determine wether a node
had static or dynamic children. This same information is now gleaned
directly by checking if the "subids" field is an instance of dict.
- - - - -
4 changed files:
- + ntpclients/ntpsnmpd-man.txt
- ntpclients/ntpsnmpd.py
- pylib/agentx.py
- tests/pylib/test_agentx.py
Changes:
=====================================
ntpclients/ntpsnmpd-man.txt
=====================================
--- /dev/null
+++ b/ntpclients/ntpsnmpd-man.txt
@@ -0,0 +1,21 @@
+= ntpsnmpd(1) =
+:doctype: manpage
+:man source: NTPsec
+:man version: @NTPSEC_VERSION@
+:man manual: NTPsec
+
+== NAME ==
+ntpsnmpd - NTP Simple Network Management Protcol sub-sgent
+
+include::../docs/includes/ntpsnmpd-body.txt[]
+
+== EXIT STATUS ==
+
+One of the following exit values will be returned:
+
+0 (EXIT_SUCCESS)::
+ Successful program execution.
+1 (EXIT_FAILURE)::
+ The operation failed or the command syntax was not valid.
+
+// end
=====================================
ntpclients/ntpsnmpd.py
=====================================
--- a/ntpclients/ntpsnmpd.py
+++ b/ntpclients/ntpsnmpd.py
@@ -37,7 +37,7 @@ ntpRootOID = (1, 3, 6, 1, 2, 1, 197) # mib-2 . 197, aka: NTPv4-MIB
snmpTrapOID = (1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0)
snmpSysUptime = (1, 3, 6, 1, 2, 1, 1, 3, 0)
-DEFHOST = "localhost" # For now only know how to talk to the local ntp
+DEFHOST = "localhost"
class DataSource: # This will be broken up in future to be less NTP-specific
@@ -49,206 +49,206 @@ class DataSource: # This will be broken up in future to be less NTP-specific
self.oidTree = {
# ntpEntNotifications
0:
- node(None, None, True,
+ node(None, None,
# ntpEntNotifModeChange
- {1: node(None, None, True, None),
+ {1: node(None, None, None),
# ntpEntNotifStratumChange
- 2: node(None, None, True, None),
+ 2: node(None, None, None),
# ntpEntNotifSyspeerChange
- 3: node(None, None, True, None),
+ 3: node(None, None, None),
# ntpEntNotifAddAssociation
- 4: node(None, None, True, None),
+ 4: node(None, None, None),
# ntpEntNotifRemoveAsociation
- 5: node(None, None, True, None),
+ 5: node(None, None, None),
# ntpEntNotifConfigChanged
- 6: node(None, None, True, None),
+ 6: node(None, None, None),
# ntpEntNotifLeapSecondAnnounced
- 7: node(None, None, True, None),
+ 7: node(None, None, None),
# ntpEntNotifHeartbeat
- 8: node(None, None, True, None)}),
+ 8: node(None, None, None)}),
# ntpSnmpMIBObjects
1:
- node(None, None, True,
+ node(None, None,
# ntpEntInfo
{1:
- node(None, None, True,
+ node(None, None,
# ntpNetSoftwareName utf8str
{1: node((lambda oid:
self.cbr_systemInfo(oid, "name")),
- None, True, None),
+ None, None),
# ntpEntSoftwareVersion utf8str
2: node((lambda oid:
self.cbr_systemInfo(oid, "version")),
- None, True, None),
+ None, None),
# ntpEntSoftwareVendor utf8str
3: node((lambda oid:
self.cbr_systemInfo(oid, "vendor")),
- None, True, None),
+ None, None),
# ntpEntSystemType utf8str
4: node((lambda oid:
self.cbr_systemInfo(oid, "system")),
- None, True, None),
+ None, None),
# ntpEntTimeResolution uint32
- 5: node(self.cbr_timeResolution, None, True, None),
+ 5: node(self.cbr_timeResolution, None, None),
# ntpEntTimePrecision int32
- 6: node(self.cbr_timePrecision, None, True, None),
+ 6: node(self.cbr_timePrecision, None, None),
# ntpEntTimeDistance DisplayString
- 7: node(self.cbr_timeDistance, None, True, None)}),
+ 7: node(self.cbr_timeDistance, None, None)}),
# ntpEntStatus
2:
- node(None, None, True,
+ node(None, None,
# ntpEntStatusCurrentMode INTEGER {...}
- {1: node(self.cbr_statusCurrentMode, None, True, None),
+ {1: node(self.cbr_statusCurrentMode, None, None),
# ntpEntStatusStratum NtpStratum
- 2: node(self.cbr_statusStratum, None, True, None),
+ 2: node(self.cbr_statusStratum, None, None),
# ntpEntStatusActiveRefSourceId
# uint32 (0..99999)
3: node(self.cbr_statusActiveRefSourceID,
- None, True, None),
+ None, None),
# ntpEntStatusActiveRefSourceName utf8str
4: node(self.cbr_statusActiveRefSourceName,
- None, True, None),
+ None, None),
# ntpEntStatusActiveOffset DisplayString
- 5: node(self.cbr_statusActiveOffset, None, True, None),
+ 5: node(self.cbr_statusActiveOffset, None, None),
# ntpEntStatusNumberOfRefSources
# unit32 (0..99)
6: node(self.cbr_statusNumRefSources,
- None, True, None),
+ None, None),
# ntpEntStatusDispersion DisplayString
- 7: node(self.cbr_statusDispersion, None, True, None),
+ 7: node(self.cbr_statusDispersion, None, None),
# ntpEntStatusEntityUptime TimeTicks
- 8: node(self.cbr_statusEntityUptime, None, True, None),
+ 8: node(self.cbr_statusEntityUptime, None, None),
# ntpEntStatusDateTime NtpDateTime
- 9: node(self.cbr_statusDateTime, None, True, None),
+ 9: node(self.cbr_statusDateTime, None, None),
# ntpEntStatusLeapSecond NtpDateTime
- 10: node(self.cbr_statusLeapSecond, None, True, None),
+ 10: node(self.cbr_statusLeapSecond, None, None),
# ntpEntStatusLeapSecondDirection
# int32 (-1..1)
11: node(self.cbr_statusLeapSecDirection,
- None, True, None),
+ None, None),
# ntpEntStatusInPkts Counter32
- 12: node(self.cbr_statusInPkts, None, True, None),
+ 12: node(self.cbr_statusInPkts, None, None),
# ntpEntStatusOutPkts Counter32
- 13: node(self.cbr_statusOutPkts, None, True, None),
+ 13: node(self.cbr_statusOutPkts, None, None),
# ntpEntStatusBadVersion Counter32
- 14: node(self.cbr_statusBadVersion, None, True, None),
+ 14: node(self.cbr_statusBadVersion, None, None),
# ntpEntStatusProtocolError Counter32
15: node(self.cbr_statusProtocolError,
- None, True, None),
+ None, None),
# ntpEntStatusNotifications Counter32
16: node(self.cbr_statusNotifications,
- None, True, None),
+ None, None),
# ntpEntStatPktModeTable
# SEQUENCE of NtpEntStatPktModeEntry
17:
- node(None, None, True,
+ node(None, None,
# ntpEntStatPktModeEntry SEQUENCE {...}
{1:
- node(None, None, True,
+ node(None, None,
# ntpEntStatPktMode INTEGER {...}
- {1: node(None, None, True, None),
+ {1: node(None, None, None),
# ntpEntStatPktSent Counter32
- 2: node(None, None, True, None),
+ 2: node(None, None, None),
# ntpEntStatPktRecived Counter32
- 3: node(None, None, True, None)})})}),
+ 3: node(None, None, None)})})}),
# ntpAssociation
3:
- node(None, None, True,
+ node(None, None,
# ntpAssociationTable
# SEQUENCE of NtpAssociationEntry
{1:
- node(None, None, True,
+ node(None, None,
# ntpAssociationEntry SEQUENCE {...}
{1:
- node(None, None, True,
+ node(None, None,
# ntpAssocId uint32 (1..99999)
- {1: node(None, None, False,
+ {1: node(None, None,
self.sub_assocID),
# ntpAssocName utf8str
- 2: node(None, None, False,
+ 2: node(None, None,
self.sub_assocName),
# ntpAssocRefId DisplayString
- 3: node(None, None, False,
+ 3: node(None, None,
self.sub_assocRefID),
# ntpAssocAddressType
# InetAddressType
- 4: node(None, None, False,
+ 4: node(None, None,
self.sub_assocAddrType),
# ntpAssocAddress
# InetAddress SIZE (4|8|16|20)
- 5: node(None, None, False,
+ 5: node(None, None,
self.sub_assocAddr),
# ntpAssocOffset DisplayString
- 6: node(None, None, False,
+ 6: node(None, None,
self.sub_assocOffset),
# ntpAssocStratum NtpStratum
- 7: node(None, None, False,
+ 7: node(None, None,
self.sub_assocStratum),
# ntpAssocStatusJitter
# DisplayString
- 8: node(None, None, False,
+ 8: node(None, None,
self.sub_assocJitter),
# ntpAssocStatusDelay
# DisplayString
- 9: node(None, None, False,
+ 9: node(None, None,
self.sub_assocDelay),
# ntpAssocStatusDispersion
# DisplayString
- 10: node(None, None, False,
+ 10: node(None, None,
self.sub_assocDispersion)})}),
# ntpAssociationStatisticsTable
# SEQUENCE of ntpAssociationStatisticsEntry
2:
- node(None, None, True,
+ node(None, None,
# ntpAssociationStatisticsEntry
# SEQUENCE {...}
{1:
- node(None, None, True,
+ node(None, None,
# ntpAssocStatInPkts Counter32
- {1: node(None, None, False,
+ {1: node(None, None,
self.sub_assocStatInPkts),
# ntpAssocStatOutPkts Counter32
- 2: node(None, None, False,
+ 2: node(None, None,
self.sub_assocStatOutPkts),
# ntpAssocStatProtocolError
# Counter32
- 3: node(None, None, False,
+ 3: node(None, None,
self.sub_assocStatProtoErr)})})}),
# ntpEntControl
4:
- node(None, None, True,
+ node(None, None,
# ntpEntHeartbeatInterval unit32
{1: node(self.cbr_entHeartbeatInterval,
self.cbw_entHeartbeatInterval,
- True, None),
+ None),
# ntpEntNotifBits BITS {...}
2: node(self.cbr_entNotifBits, self.cbw_entNotifBits,
- True, None)}),
+ None)}),
# ntpEntNotifObjects
5:
- node(None, None, True,
+ node(None, None,
# ntpEntNotifMessage utf8str
{1: node(self.cbr_entNotifMessage,
- None, True, None)})}),
+ None, None)})}),
# ntpEntConformance
2:
- node(None, None, True,
+ node(None, None,
# ntpEntCompliances
{1:
- node(None, None, True,
+ node(None, None,
# ntpEntNTPCompliance
- {1: node(None, None, True, None),
+ {1: node(None, None, None),
# ntpEntSNTPCompliance
- 2: node(None, None, True, None)}),
+ 2: node(None, None, None)}),
# ntpEntGroups
2:
- node(None, None, True,
+ node(None, None,
# ntpEntObjectsGroup1 OBJECTS {...}
- {1: node(None, None, True, None),
+ {1: node(None, None, None),
# ntpEntObjectsGroup2 OBJECTS {...}
- 2: node(None, None, True, None),
+ 2: node(None, None, None),
# ntpEntNotifGroup NOTIFICATIONS {...}
- 3: node(None, None, True, None)})})}
+ 3: node(None, None, None)})})}
self.session = ntp.packet.ControlSession()
self.hostname = hostname if hostname else DEFHOST
self.session.openhost(self.hostname)
@@ -571,9 +571,8 @@ class DataSource: # This will be broken up in future to be less NTP-specific
##########################
- def cbr_entNotifMessage(self, oid): # DUMMY
+ def cbr_entNotifMessage(self, oid):
# utf8str
- # Should probably either return null, or remove this handler.
return ax.Varbind(ax.VALUE_OCTET_STR, oid, "no event")
#########################
@@ -1104,7 +1103,7 @@ class DataSource: # This will be broken up in future to be less NTP-specific
subs = {}
associds = self.misc_getPeerIDs() # need the peer count
for i in range(len(associds)):
- subs[i+1] = ax.mibnode(readCallback, None, None, None)
+ subs[i+1] = ax.mibnode(readCallback, None, None)
return subs
def readCallbackSkeletonSimple(self, oid, varname, dataType):
@@ -1268,7 +1267,8 @@ class PacketControl:
self.packetLog[index] = packet
def sendNotify(self, varbinds, context=None):
- # DUMMY: packetID
+ # DUMMY packetID, does this need to change? or does the pktID only
+ # count relative to a given transaction ID?
tid = self.highestTransactionID + 5 # +5 to avoid collisions
self.highestTransactionID = tid
pkt = ax.NotifyPDU(True, self.sessionID, tid, 1, varbinds, context)
=====================================
pylib/agentx.py
=====================================
--- a/pylib/agentx.py
+++ b/pylib/agentx.py
@@ -1297,8 +1297,8 @@ def decode_packet(data):
def walkMIBTree(tree, rootpath=()):
# Tree node formats:
- # {"reader": <func>, "writer": <func>, "static": True, "subids": {.blah.}}
- # {"reader": <func>, "writer": <func>, "static": False, "subids": <func>}
+ # {"reader": <func>, "writer": <func>, "subids": {.blah.}}
+ # {"reader": <func>, "writer": <func>, "subids": <func>}
# The "subids" function in dynamic nodes must return an MIB tree
nodeStack = []
oidStack = []
@@ -1323,7 +1323,7 @@ def walkMIBTree(tree, rootpath=()):
# Push current node, move down a level
nodeStack.append((current, currentKeys, keyID, key))
oidStack.append(key)
- if current[key]["static"] is True:
+ if isinstance(current[key]["subids"], dict) is True:
current = current[key]["subids"]
else:
current = current[key]["subids"]() # Tree generator function
@@ -1340,9 +1340,8 @@ def walkMIBTree(tree, rootpath=()):
keyID += 1
-def mibnode(reader, writer, static, subs):
- return {"writer": writer, "reader": reader,
- "static": static, "subids": subs}
+def mibnode(reader, writer, subs):
+ return {"writer": writer, "reader": reader, "subids": subs}
def bits2Bools(bitString, cropLength=None):
=====================================
tests/pylib/test_agentx.py
=====================================
--- a/tests/pylib/test_agentx.py
+++ b/tests/pylib/test_agentx.py
@@ -2630,32 +2630,31 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
self.assertEqual(tuple(f({})), ())
# Test flat, fully static tree
self.assertEqual(tuple(f({0: {"reader": None, "writer": None,
- "static": True, "subids": None},
+ "subids": None},
1: {"reader": None, "writer": None,
- "static": True, "subids": None},
+ "subids": None},
2: {"reader": None, "writer": None,
- "static": True, "subids": None},
+ "subids": None},
5: {"reader": None, "writer": None,
- "static": True, "subids": None}})),
+ "subids": None}})),
((x.OID((0,)), None, None),
(x.OID((1,)), None, None),
(x.OID((2,)), None, None),
(x.OID((5,)), None, None)))
# Test nested, fully static tree
self.assertEqual(tuple(f({0: {"reader": None, "writer": None,
- "static": True, "subids": None},
+ "subids": None},
1: {"reader": None, "writer": None,
- "static": True, "subids":
+ "subids":
{0: {"reader": None, "writer": None,
- "static": True, "subids": None},
+ "subids": None},
1: {"reader": None, "writer": None,
- "static": True, "subids":
+ "subids":
{42: {"reader": None,
"writer": None,
- "static": True,
"subids": None}}}}},
5: {"reader": None, "writer": None,
- "static": True, "subids": None}})),
+ "subids": None}})),
((x.OID((0,)), None, None),
(x.OID((1,)), None, None),
(x.OID((1, 0)), None, None),
@@ -2664,19 +2663,18 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
(x.OID((5,)), None, None)))
# Test nested, fully static tree, with rootpath
self.assertEqual(tuple(f({0: {"reader": None, "writer": None,
- "static": True, "subids": None},
+ "subids": None},
1: {"reader": None, "writer": None,
- "static": True, "subids":
+ "subids":
{0: {"reader": None, "writer": None,
- "static": True, "subids": None},
+ "subids": None},
1: {"reader": None, "writer": None,
- "static": True, "subids":
+ "subids":
{42: {"reader": None,
"writer": None,
- "static": True,
"subids": None}}}}},
5: {"reader": None, "writer": None,
- "static": True, "subids": None}},
+ "subids": None}},
(23,))),
((x.OID((23, 0)), None, None),
(x.OID((23, 1)), None, None),
@@ -2686,20 +2684,20 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
(x.OID((23, 5)), None, None)))
# subid lambda for dynamic tree testing
submaker = (lambda: {0: {"reader": None, "writer": None,
- "static": True, "subids": None},
+ "subids": None},
1: {"reader": None, "writer": None,
- "static": True, "subids":
+ "subids":
{0: {"reader": None, "writer": None,
- "static": True, "subids": None}}},
+ "subids": None}}},
2: {"reader": None, "writer": None,
- "static": True, "subids": None}})
+ "subids": None}})
# Test tree with dynamic nodes
self.assertEqual(tuple(f({0: {"reader": None, "writer": None,
- "static": True, "subids": None},
+ "subids": None},
1: {"reader": None, "writer": None,
- "static": False, "subids": submaker},
+ "subids": submaker},
2: {"reader": None, "writer": None,
- "static": True, "subids": None}})),
+ "subids": None}})),
((x.OID((0,)), None, None),
(x.OID((1,)), None, None),
(x.OID((1, 0)), None, None),
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/9256682f4a13b1d6fb8267c4b0197bd4dc316e28...9098486ad10a7c934937b4c6fbbede126709a7cf
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/9256682f4a13b1d6fb8267c4b0197bd4dc316e28...9098486ad10a7c934937b4c6fbbede126709a7cf
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180218/8c820c10/attachment.html>
More information about the vc
mailing list