On Thu, 2017-09-07 at 09:31 +0100, Colin Helliwell wrote: > > On 06 September 2017 at 17:18 Dan Williams <d...@redhat.com> wrote: > > > > On Wed, 2017-09-06 at 12:51 +0100, Colin Helliwell wrote: > > > > > > On 06 September 2017 at 11:14 Thomas Haller <thal...@redhat.com > > > > > > > > > wrote: > > > > > > > > On Wed, 2017-09-06 at 10:20 +0100, colin.helliwell@ln-systems.c > > > > om > > > > wrote: > > > > > > > > > I'm python-scripting to get a connection's gsm properties, > > > > > and > > > > > want > > > > > to get > > > > > the password - which "c.for_each_setting_value(print_values, > > > > > None)" > > > > > seems to > > > > > not report (just "None"). > > > > > What would be the technique to get it? > > > > > Thanks > > > > > > > > Hi, > > > > > > > > on D-Bus, secrets are exposed separately from regular > > > > properties of > > > > the > > > > connection. > > > > > > > > GetSettings() vs GetSecrets() in > > > > https://developer.gnome.org/NetworkManager/stable/gdbus-org.fre > > > > edes > > > > ktop.NetworkManager.Settings.Connection.html > > > > > > > > Anyway, from libnm (and python gi) you would call > > > > > > > > secrets = remote_connection.get_secrets('ethernet') > > > > > > Great, got that. Now, don't suppose you could help me get to > > > grips > > > with parsing the Glib.Variant....? ;) > > > > You can get around the need for touching GVariant by passing what > > you > > get from get_secrets() to NMConnection's replace_settings() call > > too. > > Then you get a nice NMConnection object, with only the secrets > > filled > > in. For example, pass a connection UUID as the argument to this: > > > > #!/usr/bin/env python > > import gi > > gi.require_version('NM', '1.0') > > from > > gi.repository import GLib, NM > > import sys > > > > client = NM.Client.new(None) > > c = client.get_connection_by_uuid(sys.argv[1]) > > wifi_secrets = > > c.get_secrets(NM.SETTING_WIRELESS_SECURITY_SETTING_NAME) > > wifi_secrets_con = NM.SimpleConnection.new() > > wifi_secrets_con.replace_settings(wifi_secrets) > > wsec = wifi_secrets_con.get_setting_wireless_security() > > print "%s" % wsec.get_psk() > > > > Thanks Dan, that gets it. > Now I'm struggling to *modify* the password.... :S I see that I can > do a > settings.set_property(NM.SETTING_GSM_PASSWORD, "NewPw") > but unsure how to complete the updating. I found > NM.Connection.replace_settings(), and update_secrets(), but both of > those put me back into GVariant territory. > What would be the route to get the new password fed back through > (presumably prior to finishing with a > NM.RemoteConnection.save()/commit()?)
You're correct. Here's what I'd do: client = NM.Client.new(None) c = client.get_connection_by_uuid(sys.argv[1]) secrets = c.get_secrets(NM.SETTING_WIRELESS_SECURITY_SETTING_NAME) # this merges the secrets into the existing connection c.update_secrets(NM.SETTING_WIR ELESS_SECURITY_SETTING_NAME, secrets) <change the secret here with set_property()> # write the full connection back to NM c.save() Dan _______________________________________________ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list