Re: Managing a connection using D-Bus API
- From: Ozan Çağlayan <ozan pardus org tr>
- To: Giovanni Campagna <scampa giovanni gmail com>
- Cc: networkmanager-list gnome org
- Subject: Re: Managing a connection using D-Bus API
- Date: Fri, 2 Jul 2010 10:19:07 +0300
Perşembe 01 Temmuz 2010 günü (saat 18:01:04) Giovanni Campagna şunları
yazmıştı:
> On Thu, Jul 1, 2010 at 2:56 PM, Ozan Çağlayan <ozan pardus org tr> wrote:
> > Hi,
> >
> > I'm writing a Python script which uses python-networkmanager for
> > communicating with NetworkManager's D-Bus facilities.
> >
> > I want to disconnect an active connection. Using the nm-applet, we are
> > not forced to write a MAC address for a connection.
> >
> > Say that I want to disconnect the device eth0 AA:BB:CC:DD:EE:FF which is
> > currently connected to the connection with the ID "WiredConnection1".
> >
> > Since the connection doesn't have an hwaddress set, I can't match the
>
> > connection with the device. What I want to do is sth like that:
> You need the ActiveConnection object.
> That is, obtain ActiveConnections property from
> /org/freedesktop/NetworkManager. Obtain the Connection object with the ID
> you want
> Find the ActiveConnection whose Connection property is the Connection
> object you found
> For each device in the Devices property, invoke Deactivate.
Oops the problem was during the activation of a given connection not
deactivation. For deactivation, we're doing exactly what you suggested.
This is the code snippet I'm talking about. It'll give an error when
mac_address is None.
def set_profile_state_up(nm_handle, profile):
for conn in nm_handle.connections:
if conn.settings.id == profile:
for device in nm_handle.devices:
if device.hwaddress == conn.settings.mac_address:
nm_handle.activate_connection(conn, device)
We've also looked at nm-applet. Apparently it lists all the available
connections for a specific type under all the specific device so I don't
expect a solution to be available but you may have some good suggestions.
Thanks.
---
Ozan Çağlayan
TUBITAK/UEKAE - Pardus Linux
http://www.pardus.org.tr/eng
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]