Comment # 3 on bug 931912 from
(In reply to Frederic Crozat from comment #2)
> if networks are configured by user in NM and not set system-wide (this is
> the default behaviour), /etc/sysconfig/network/* won't be written (the
> configuration will be stored in user home directory).
> 
> I guess this information could be queried through D-Bus NM API.

The right thing would be to query dbus, not relying on the output of a tool
provided by NM (there is nmcli devices, that would give output, but parsing
this is just wrong).

You can get a list of known devices by means of:

gdbus call --system --dest org.freedesktop.NetworkManager --object-path
/org/freedesktop/NetworkManager --method
org.freedesktop.NetworkManager.GetDevices

which returns an array of known devices
([objectpath '/org/freedesktop/NetworkManager/Devices/0',
'/org/freedesktop/NetworkManager/Devices/1',
'/org/freedesktop/NetworkManager/Devices/2',
'/org/freedesktop/NetworkManager/Devices/4'],)

Then iterating over them, you can get the status information of each of them
(example on device 0)

> gdbus introspect --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/Devices/0
node /org/freedesktop/NetworkManager/Devices/0 {
  interface org.freedesktop.DBus.Introspectable {
    methods:
      Introspect(out s data);
    signals:
    properties:
  };
  interface org.freedesktop.DBus.Properties {
    methods:
      Get(in  s interface,
          in  s propname,
          out v value);
      Set(in  s interface,
          in  s propname,
          in  v value);
      GetAll(in  s interface,
             out a{sv} props);
    signals:
    properties:
  };
  interface org.freedesktop.NetworkManager.Device {
    methods:
      Delete();
      Disconnect();
    signals:
      StateChanged(u arg_0,
                   u arg_1,
                   u arg_2);
    properties:
      readonly u Mtu = 65536;
      readonly s PhysicalPortId = '';
      readonly ao AvailableConnections = [];
      readonly u DeviceType = 14;
      readonly b FirmwareMissing = false;
      readwrite b Autoconnect = false;
      readonly b Managed = false;
      readonly o Dhcp6Config = '/';
      readonly o Ip6Config = '/org/freedesktop/NetworkManager/IP6Config/2';
      readonly o Dhcp4Config = '/';
      readonly o Ip4Config = '/org/freedesktop/NetworkManager/IP4Config/2';
      readonly o ActiveConnection = '/';
      readonly (uu) StateReason = (10, 0);
      readonly u State = 10;
      readonly u Ip4Address = 16777343;
      readonly u Capabilities = 7;
      readonly s FirmwareVersion = '';
      readonly s DriverVersion = '';
      readonly s Driver = 'unknown';
      readonly s IpInterface = 'lo';
      readonly s Interface = 'lo';
      readonly s Udi = '/sys/devices/virtual/net/lo';
  };
  interface org.freedesktop.NetworkManager.Device.Generic {
    methods:
    signals:
      PropertiesChanged(a{sv} arg_0);
    properties:
      readonly s TypeDescription = 'loopback';
      readonly s HwAddress = '00:00:00:00:00:00';
  };
};

The fields Managed and Interface are likely the most interesting ones


You are receiving this mail because: