mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 00:27:47 +00:00
[cli] add lease info to srp server host and srp server service (#12589)
This commit adds lease and remaining lease information to the output of `srp server host` and `srp server service` CLI commands. The information includes: - `lease`: The total lease time in seconds. - `key-lease`: The total key lease time in seconds. - `remaining lease`: The remaining lease time in seconds (with millisecond precision). - `remaining key-lease`: The remaining key lease time in seconds (with millisecond precision). A new utility method `OutputMsecDurationInSec()` is added to `Utils` class to format durations in milliseconds as seconds with a fractional part. The SRP server host and service output parsers in `tests/scripts/thread-cert/node.py`, `tests/toranj/cli/cli.py`, and `tools/otci/otci/otci.py` are updated to correctly handle the new fields for both active and deleted entries.
This commit is contained in:
@@ -1157,7 +1157,11 @@ class NodeImpl:
|
||||
'fullname': 'my-host.default.service.arpa.',
|
||||
'name': 'my-host',
|
||||
'deleted': 'false',
|
||||
'addresses': ['2001::1', '2001::2']
|
||||
'addresses': ['2001::1', '2001::2'],
|
||||
'lease': '7200',
|
||||
'key-lease': '1209600',
|
||||
'remaining lease': '6345.459',
|
||||
'remaining key-lease': '1208734.459'
|
||||
}]
|
||||
"""
|
||||
|
||||
@@ -1173,6 +1177,10 @@ class NodeImpl:
|
||||
|
||||
host['deleted'] = lines.pop(0).strip().split(':')[1].strip()
|
||||
if host['deleted'] == 'true':
|
||||
for _ in range(2):
|
||||
# `key-lease` and `remaining key-lease`
|
||||
key_value = lines.pop(0).strip().split(':')
|
||||
host[key_value[0].strip()] = key_value[1].strip()
|
||||
host_list.append(host)
|
||||
continue
|
||||
|
||||
@@ -1180,6 +1188,11 @@ class NodeImpl:
|
||||
map(str.strip, addresses)
|
||||
host['addresses'] = [addr.strip() for addr in addresses if addr]
|
||||
|
||||
for _ in range(4):
|
||||
# `lease`, `key-lease`, `remaining lease` and `remaining key-lease`
|
||||
key_value = lines.pop(0).strip().split(':')
|
||||
host[key_value[0].strip()] = key_value[1].strip()
|
||||
|
||||
host_list.append(host)
|
||||
|
||||
return host_list
|
||||
@@ -1210,7 +1223,9 @@ class NodeImpl:
|
||||
'weight': '0',
|
||||
'ttl': '7200',
|
||||
'lease': '7200',
|
||||
'key-lease': '7200',
|
||||
'key-lease': '1209600',
|
||||
'remaining lease': '6345.459',
|
||||
'remaining key-lease': '1208734.459',
|
||||
'TXT': ['abc=010203'],
|
||||
'host_fullname': 'my-host.default.service.arpa.',
|
||||
'host': 'my-host',
|
||||
@@ -1235,11 +1250,15 @@ class NodeImpl:
|
||||
|
||||
service['deleted'] = lines.pop(0).strip().split(':')[1].strip()
|
||||
if service['deleted'] == 'true':
|
||||
for _ in range(2):
|
||||
key_value = lines.pop(0).strip().split(':')
|
||||
service[key_value[0].strip()] = key_value[1].strip()
|
||||
service_list.append(service)
|
||||
continue
|
||||
|
||||
# 'subtypes', port', 'priority', 'weight', 'ttl', 'lease', and 'key-lease'
|
||||
for i in range(0, 7):
|
||||
# 'subtypes', port', 'priority', 'weight', 'ttl', 'lease', 'key-lease',
|
||||
# 'remaining lease', and `remaining key-lease`
|
||||
for i in range(0, 9):
|
||||
key_value = lines.pop(0).strip().split(':')
|
||||
service[key_value[0].strip()] = key_value[1].strip()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user