reorg of table format

This commit is contained in:
Wolfgang Hottgenroth 2025-02-21 10:36:36 +01:00
parent 9e8b4b097f
commit 0645e660b6

View File

@ -14,9 +14,12 @@ import ipaddress
BASE_OID_ENTERPRISE = '1.3.6.1.4.1'
BASE_OID_HOTTIS = BASE_OID_ENTERPRISE + '.9676'
BASE_OID_HOTTIS_NTPSEC = BASE_OID_HOTTIS + '.123'
BASE_OID_ENTERPRISE = '1.3.6.1.4.1'
BASE_OID_HOTTIS = BASE_OID_ENTERPRISE + '.9676'
BASE_OID_HOTTIS_NTPSEC = BASE_OID_HOTTIS + '.123'
LOCAL_PREFIX = '1'
PEERS_PREFIX = '2'
def int_scale1k(x):
return int (x * 1000)
@ -159,33 +162,28 @@ class NtpsecDataUpdater(pyagentx3.Updater):
with self.data_store as ds:
if ds.data:
try:
for index, data_spec in enumerate(LOCAL_SERVER_KEYS):
for index, data_spec in enumerate(LOCAL_SERVER_KEYS, start=1):
logger.debug(f"local: {index=} {data_spec=}")
CURRENT_NAME_OID_BASE = f"0.0.{index}"
CURRENT_VALUE_OID_BASE = f"0.1.{index}"
self._data[CURRENT_NAME_OID_BASE] = {
'name': CURRENT_NAME_OID_BASE,
'type': pyagentx3.TYPE_OCTETSTRING,
'value': data_spec[0]
}
self._data[CURRENT_VALUE_OID_BASE] = {
'name': CURRENT_VALUE_OID_BASE,
oid_prefix = f"{LOCAL_PREFIX}.{index}"
self._data[oid_prefix] = {
'name': oid_prefix,
'type': data_spec[1],
'value': data_spec[2](ds.data['local'][data_spec[0]])
}
for associd, peer in ds.data['peers'].items():
for peer_index, (associd, peer) in enumerate(ds.data['peers'].items(), start=1):
logger.debug(f"peer: {peer}")
for index, data_spec in enumerate(PEER_KEYS):
logger.debug(f"peer: {associd=} {index=} {data_spec=}")
CURRENT_NAME_OID_BASE = str(associd) + '.' + str(index) + '.0'
CURRENT_VALUE_OID_BASE = str(associd) + '.' + str(index) + '.1'
self._data[CURRENT_NAME_OID_BASE] = {
'name': CURRENT_NAME_OID_BASE,
'type': pyagentx3.TYPE_OCTETSTRING,
'value': data_spec[0]
}
self._data[CURRENT_VALUE_OID_BASE] = {
'name': CURRENT_VALUE_OID_BASE,
index_oid_prefix = f"{PEERS_PREFIX}.1.{peer_index}"
self._data[index_oid_prefix] = {
'name': index_oid_prefix,
'type': pyagentx3.TYPE_INTEGER,
'value': associd
}
for key_index, data_spec in enumerate(PEER_KEYS, start=2):
logger.debug(f"peer: {associd=} {key_index=} {data_spec=}")
oid_prefix = f"{PEERS_PREFIX}.{key_index}.{peer_index}"
self._data[oid_prefix] = {
'name': oid_prefix,
'type': data_spec[1],
'value': data_spec[2](peer[data_spec[0]])
}