yanger: handle all frr uptime formats

FRR prints uptime different based on how long it is. Prior to this
commit yanger expected uptime to be on the format HH:MM:SS which it is
as long as it's shorter than a day. If it's longer the format changes,
this commit handles this.

The commit also adds unit test data triggering the different formats
(<day, <week, >week).

Side note:
cli-pretty could be made to represent the data on "FRR format" again,
which is perhaps more human friendly.

Signed-off-by: Richard Alpe <richard@bit42.se>
This commit is contained in:
Richard Alpe
2024-10-08 10:06:32 +02:00
parent 3e8e8a2e99
commit 950e868eb3
3 changed files with 36 additions and 8 deletions
@@ -6,6 +6,6 @@
10.0.13.0/30 110/2000 e5 ospfv2 0h0m0s
>* 10.0.13.0/30 0/0 e5 direct 0h0m0s
10.0.23.0/30 110/1 e6 ospfv2 0h0m0s
>* 10.0.23.0/30 0/0 e6 direct 0h0m0s
192.168.3.0/24 110/1 e2 ospfv2 0h0m0s
>* 192.168.3.0/24 0/0 e2 direct 0h0m0s
>* 10.0.23.0/30 0/0 e6 direct 20h10m5s
192.168.3.0/24 110/1 e2 ospfv2 133h5m0s
>* 192.168.3.0/24 0/0 e2 direct 205h0m0s
@@ -228,7 +228,7 @@
"internalNextHopActiveNum":1,
"nexthopGroupId":23,
"installedNexthopGroupId":23,
"uptime":"00:00:00",
"uptime":"20:10:05",
"nexthops":[
{
"flags":3,
@@ -256,7 +256,7 @@
"internalNextHopNum":1,
"internalNextHopActiveNum":1,
"nexthopGroupId":33,
"uptime":"00:00:00",
"uptime":"5d13h05m",
"nexthops":[
{
"flags":1,
@@ -286,7 +286,7 @@
"internalNextHopActiveNum":1,
"nexthopGroupId":17,
"installedNexthopGroupId":17,
"uptime":"00:00:00",
"uptime":"01w1d13h",
"nexthops":[
{
"flags":3,