Re: Documentation
- From: Bluesky_greenleaf <trojanwei gmail com>
- To: jklimes redhat com
- Cc: networkmanager-list gnome org
- Subject: Re: Documentation
- Date: Thu, 25 Mar 2010 14:37:34 -0700
Thanks, But don't find the some examples in source tree of NM in examples directory.
Also I still have the confuse for the connection
I have the object path /org/freedesktop/NetworkManager/Devices/0 for
WIFI under the bus name org.freedesktop.NetworkManager, and
/org/freedesktop/NetworkManager/AccessPoint/15 for this connection
$SERVICE="org.freedesktop.NetworkManager"
$CONNECTION="/org/freedesktop/NetworkManager/AccessPoint/15"
$DEVICE="/org/freedesktop/NetworkManager/Devices/0"
$ dbus-send --system --print-reply --type=method_call
--dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager
org.freedesktop.NetworkManager.ActivateConnection string:"$SERVICE"
objpath:"$CONNECTION" objpath:"$DEVICE" objpath:"/"
Error org.freedesktop.NetworkManager.InvalidService: Invalid settings service name
If I try the following, it also have the errors:
SERVICE="org.freedesktop.NetworkManagerSystemSettings"
CONNECTION="/org/freedesktop/NetworkManager/AccessPoint/15"
DEVICE="/org/freedesktop/NetworkManager/Devices/0"
dbus-send --system --print-reply --type=method_call
--dest='org.freedesktop.NetworkManager'
'/org/freedesktop/NetworkManager'
org.freedesktop.NetworkManager.ActivateConnection string:"$SERVICE"
objpath:"$CONNECTION" objpath:"$DEVICE" objpath:"/"
Error org.freedesktop.NetworkManager.UnknownConnection: Connection was not provided by any settings service
How can I solve this problem? Thanks
On Thu, Mar 25, 2010 at 1:52 AM, Jirka Klimes
<jklimes redhat com> wrote:
On Thursday 25 of March 2010 02:46:35 Bluesky_greenleaf wrote:
> Dear Dan,
>
> I would like to write an application based on the NM D-BUS. I have taken a
> look at the document of NM, the link is shown as follows:
>
>
http://projects.gnome.org/NetworkManager/developers/spec-08.html
> and
>
http://projects.gnome.org/NetworkManager/developers/spec.html
>
> I know how to disconnect the network connection for example Ethernet, Wifi
> wlan0 using the D-BUS, but How to start a connection for Eth0 or WLAN0
> based on the D-BUS. I don't find which method can do this function. I have
> /org/freedesktop/NetworkManager
> /org/freedesktop/NetworkManager/Device/0
> /org/freedesktop/NetworkManager/Device/1
>
> Are there other documentations or sample scripts?
>
> Thanks
>
> William
You are looking for ActivateConnection method of
org.freedesktop.NetworkManager interface:
http://projects.gnome.org/NetworkManager/developers/spec-08.html#org.freedesktop.NetworkManager
When connecting, NM uses a concept of connections, which are configured profiles
that can be activated on a device.
For more info see http://live.gnome.org/NetworkManagerConfiguration
Here are two simple examples, how to activate a connection. You have to adjust
the paths of course.
1) Python
#!/usr/bin/python
import dbus
SERVICE = "org.freedesktop.NetworkManagerSystemSettings"
OPATH = "/org/freedesktop/NetworkManager"
IFACE = "org.freedesktop.NetworkManager"
CONNECTION = "/org/freedesktop/NetworkManagerSettings/1"
DEVICE = "/org/freedesktop/NetworkManager/Devices/0"
bus = dbus.SystemBus()
nm_iface = dbus.Interface(bus.get_object(SERVICE, OPATH), IFACE)
# Ask NM to activate the connection
active_path = nm_iface.ActivateConnection(SERVICE, CONNECTION, DEVICE, "/")
if not active_path:
print "Couldn't activate connection"
sys.exit(1)
2) Bash
#!/bin/bash
SERVICE="org.freedesktop.NetworkManagerSystemSettings"
CONNECTION="/org/freedesktop/NetworkManagerSettings/1"
DEVICE="/org/freedesktop/NetworkManager/Devices/0"
dbus-send --system --print-reply --type=method_call --
dest='org.freedesktop.NetworkManager' \
'/org/freedesktop/NetworkManager'
org.freedesktop.NetworkManager.ActivateConnection \
string:"$SERVICE" objpath:"$CONNECTION" objpath:"$DEVICE" objpath:"/"
You can also find some examples in source tree of NM in examples directory.
We should probably create a section on wiki with some examples to have them in
one place and easy to find.
Jirka
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]