opiproject / sztp

Secure Zero Touch Provisioning (sZTP) in OPI
Apache License 2.0
20 stars 14 forks source link

fetch DHCP leases from ```networkd``` #420

Open bhoopesh369 opened 4 months ago

bhoopesh369 commented 4 months ago

See xPU sZTP provisioning block

today we pass lease file via cmdline arguments like this: --dhcp-lease-file /var/lib/dhclient/dhclient.leases.

for detecting this automatically using Network manger : https://github.com/opiproject/sztp/issues/418 but if detection through Network Manager doesn't work, we can then look through networkd same as the above

can we detect that info automatically from networkd over dbus?

bhoopesh369 commented 2 months ago

It seems we can't get the lease info via dbus for systemd-networkd. Dbus does not expose the info. So the only way to to parse all the lease files present in the /run/systemd/netif/leases folder.

WDYT? @glimchb

bhoopesh369 commented 2 months ago

The maximum info we can get via dbus is:

array [
      dict entry(
         string "OperationalState"
         variant             string "routable"
      )
      dict entry(
         string "CarrierState"
         variant             string "carrier"
      )
      dict entry(
         string "AddressState"
         variant             string "routable"
      )
      dict entry(
         string "IPv4AddressState"
         variant             string "routable"
      )
      dict entry(
         string "IPv6AddressState"
         variant             string "degraded"
      )
      dict entry(
         string "OnlineState"
         variant             string "online"
      )
      dict entry(
         string "AdministrativeState"
         variant             string "configured"
      )
      dict entry(
         string "BitRates"
         variant             struct {
               uint64 18446744073709551615
               uint64 18446744073709551615
            }
      )
   ]
glimchb commented 1 month ago

It seems we can't get the lease info via dbus for systemd-networkd. Dbus does not expose the info. So the only way to to parse all the lease files present in the /run/systemd/netif/leases folder.

WDYT? @glimchb

copy paste please an example of this folder