You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env ruby
require "dbus"
bus = DBus::SystemBus.instance
@nm_service = bus.service("org.freedesktop.NetworkManager")
@nm_settings = @nm_service.object("/org/freedesktop/NetworkManager/Settings")
@nm_settings_iface = DBus::ProxyObjectInterface.new(@nm_settings, "org.freedesktop.NetworkManager.Settings")
@nm_settings_iface.define_method("AddConnection", "in connection:a{sa{sv}}, out path:o");
new_c = { "connection" => {"id" => "LAN", "type"=>"802-3-ethernet"},
"ipv4" => {"method"=>"manual", "address-data" => [{"address" => "192.168.2.1", "prefix" => 24}] } }
p "Creating new LAN connection"
p new_c
clan_path = @nm_settings_iface.AddConnection(new_c)
gives the following error:
$ ./new_con.rb
"Creating new LAN connection"
{"connection"=>{"id"=>"LAN", "type"=>"802-3-ethernet"}, "ipv4"=>{"method"=>"manual", "address-data"=>[{"address"=>"192.168.2.1", "prefix"=>24}]}}
/var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/connection.rb:95:in `block in send_sync_or_async': ipv4.address-data: can't set property of type 'aa{sv}' from value of type 'av'; caused by 3 sender=:1.10 -> dest=:1.8432 serial=495323 reply_serial=3 path=; interface=; member= error_name=org.freedesktop.NetworkManager.Settings.Connection.InvalidProperty (DBus::Error)
from /var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/connection.rb:284:in `process'
from /var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/connection.rb:228:in `send_sync'
from /var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/connection.rb:94:in `send_sync_or_async'
from /var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/proxy_object_interface.rb:70:in `block (2 levels) in define_method_from_descriptor'
from ./new_con.rb:16:in `<main>'
/var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/connection.rb:95:in `block in send_sync_or_async': ipv4.address-data: can't set property of type 'aa{sv}' from value of type 'av' (DBus::Error)
from /var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/connection.rb:284:in `process'
from /var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/connection.rb:228:in `send_sync'
from /var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/connection.rb:94:in `send_sync_or_async'
from /var/lib/gems/3.1.0/gems/ruby-dbus-0.23.1/lib/dbus/proxy_object_interface.rb:70:in `block (2 levels) in define_method_from_descriptor'
from ./new_con.rb:16:in `<main>'
The expected behaviour is that the address-data array: [{"address" => "192.168.2.1", "prefix" => 24}] is indeed sent via DBus as 'aa{sv}' and not as 'av'
The text was updated successfully, but these errors were encountered:
The problem is that ruby-dbus has no way of knowing what type the NetworkManager API is actually expecting.
This is a known problem, please see #124 for a slightly more general description, also using the org.freedesktop.NetworkManager.Settings interface
You need to explicitly set the data type, like this:
The following code
gives the following error:
The expected behaviour is that the address-data array: [{"address" => "192.168.2.1", "prefix" => 24}] is indeed sent via DBus as 'aa{sv}' and not as 'av'
The text was updated successfully, but these errors were encountered: