Showing posts with label NetworkManager. Show all posts
Showing posts with label NetworkManager. Show all posts

Oct 15, 2009

resolv.conf empty, resolv.conf.netconfig ate the data

Problem: After a reboot, /etc/resolv.conf says just # Generated by NetworkManager and the real data went to /etc/resolv.conf.netconfig. I have both eth0 and wlan0 activated by NM. My setup does not involve dial-up like Seife's.

Work-around:
rcnetwork stop
rm /etc/resolv.conf.netconfig
: > /etc/resolv.conf
rcnetwork start
I wonder if this is a bug. Anyway, hopefully this will help someone. openSUSE 11.2 RC1.

Aug 11, 2009

cnetworkmanager 0.21

As I advertised in a previous post, cnetworkmanager got a complete rewrite, and here is a summary of the changes:

v0.21, User visible changes
  • Added screenshots.html.
  • Output in a tabular form (like Tambet's nmcli); --terse/-t to disable.
  • Added --wireless-enabled/--we.
  • Added --con-info.
  • For unimplemented device types, return "unknown", crash not (Kevin Fenzi).
  • Ignore AlreadyAsleepOrAwake error (-o).
  • Flags with zero value now output its name (NONE) instead of nothing.
v0.20
  • Major rewrite:
  • Created a library wrapping the NM DBus API.
  • Created a generic library wrapping python-dbus.
    (both libraries are still quite messy)
  • Dropped support for NM 0.6.
    (the last trace is in the 'breakup' branch)
  • Connection setting:
    --activate-connection for system settings or another applet
    --connect for exporting a transient connection
  • knetworkmanager (KDE3) config reading dropped
  • Added a (basic) testsuite.
  • Switched to distutils.
BTW, I also pushed the git repo to Github so that you can enjoy the fork graphs. (repo.or.cz stays)

Jul 21, 2009

HackWeek: NetworkManager Python library

It is Hack Week again, a time when we venture into unexplored territories. So why am I returning to cnetworkmanager?

It is because I am doing a complete rewrite, based on an easy-to-use library that hides some rough edges in dbus-python. If you ever thought NM needed some programmatic prodding but were put off by the tedious details, the library might be just the thing for you. For me, it is also an opportunity to learn more Python.

Compare how you get the interface names.
Before:
#! /usr/bin/python
import dbus
bus = dbus.SystemBus()
NM = 'org.freedesktop.NetworkManager'
nm = bus.get_object(NM, '/org/freedesktop/NetworkManager')
for dev_opath in nm.GetDevices(dbus_interface = NM):
dev = bus.get_object(NM, dev_opath)
print dev.Get(NM + '.Device', 'Interface',
dbus_interface='org.freedesktop.DBus.Properties')
After:
#! /usr/bin/python
from networkmanager.networkmanager import NetworkManager
nm = NetworkManager()
for d in nm.GetDevices():
print d["Interface"]
It is in the librarize branch of the git repo. Beware, the code is still messy. Getting it:
git clone git://repo.or.cz/cnetworkmanager.git cnetworkmanager.librarize
cd cnetworkmanager.librarize
git checkout -b librarize origin/librarize
./cnetworkmanager -h

Jul 14, 2008

cnetworkmanager 0.7.1

Cnetworkmanager is a command-line client for NetworkManager, intended to supplement and replace the GUI applets. So far it is a single python script. What is new in version 0.7.1:
  • it does not need a configuration file anymore:
    cnetworkmanager -C publicnet
    cnetworkmanager -C myessid --wep-hex 112234445566778899aabbccdd
    cnetworkmanager -C another --wpa-psk-hex \
     112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00
  • it works with NM 0.6 (tested on Ubuntu 8.04 Hardy and a pre-release OLPC) in addition to the older support for NM 0.7pre (tested on openSUSE 11.0)
What is still left to do:
  • sooner:
    • specifying the key as a non-hex passphrase
    • reading the configuration stored by the GNOME nm-applet
    • possibility to quit after a connection is established
  • later:
    • more encryption schemes (WPA2?)
    • more connection types (dial-up, VPN)

Jun 10, 2008

cnetworkmanager 0.4

I pulled together 0.4 yesterday:
  • New: changed license to GPLv2 or later, to match other parts of NM
  • New: distinguish WEP, WPA, WPA2 for -n.
  • New: -o, -w control online and WiFi status.
  • New: basic device info for NM 0.6
  • Fix: recognize Notification Messages in knetwormanagerrc.
  • Fix: -u: better error message when applet not running.
  • Fix: standardized option parsing, both -Cfoo and -C foo work.
The software is now hosted in a Git repository.

May 30, 2008

try cnetworkmanager 0.3

cnetworkmanager is a command line interface for Network Manager. It is still lacking many features but I decided to announce it now, when it can:

  1. connect to WiFi networks
  2. read the configuration file of KNetworkManager

It is working for me on RC1 of openSUSE-11.0, which has NetworkManager-0.7.0.r3685-3. It is my first project in Python, so the code is somewhat cumbersome. Thanks to Mišo for getting me started (idea.o.o, abclinuxu.cz), and Bille for the API docs.

Regarding related projects, I have seen network-manager-cli, but it is for 0.6 only and the developers were only active last August, so I decided that I should first write some working code for 0.7.

I am interested in comments, bugs, feature requests, patches, any feedback.

Here are some screenshots ;-)

$ cnetworkmanager -h
cnetworkmanager 0.3 - Command Line Interface for NetworkManager
Options:
-d, --dev list devices
-c, --actcon list active connections
-s, --syscon list system connection settings
-u, --usrcon list user connection settings (can CRASH nm-applet)
-a, --ap list found access points
-n, --nets list found wireless networks
-C<net>, --connect=<net> connect to a wireless network (using knetworkmanagerrc)
-m, --monitor loop to show dbus signals

Listing the networks:

$ cnetworkmanager -n
cnetworkmanager 0.3 - Command Line Interface for NetworkManager
Wifi Networks:
49: onenet (54Mb, protected)
46: IT (54Mb, protected)
48: TiborBrunclik (11Mb, protected)
46: linksys (54Mb)
46: IT (54Mb, protected)
46: 23 (54Mb)

May 5, 2008

cnetworkmanager 0.1

Thanks to Mišo for getting me started on this...
$ cnetworkmanager -d -c
cnetworkmanager 0.1 - Command Line Interface for NetworkManager
state: CONNECTED
wifi: 1
wifi hw: 1
/org/freedesktop/Hal/devices/net_00_02_3f_0d_7d_93
Udi: /org/freedesktop/Hal/devices/net_00_02_3f_0d_7d_93
Interface: eth0
Driver: 8139too
Ip4Address: 268702730
Capabilities: NM_SUPPORTED,CARRIER_DETECT
Dev State: FAILED
Dev Type: 802_3_ETHERNET
HwAddress: 00:02:3F:0D:7D:93
Speed: 100
Carrier: 1
/org/freedesktop/Hal/devices/net_00_11_d8_70_00_2f
Udi: /org/freedesktop/Hal/devices/net_00_11_d8_70_00_2f
Interface: wlan0
Driver: rt2500pci
Ip4Address: 1476989962
Capabilities: NM_SUPPORTED
Dev State: FAILED
Dev Type: 802_11_WIRELESS
Dev Mode: INFRA
Wifi Capabilities: RSN,CIPHER_WEP40,CIPHER_WEP104,CIPHER_TKIP,CIPHER_CCMP,WPA
HwAddress: 00:11:D8:70:00:2F
Bitrate: 1000
ActiveAccessPoint: /org/freedesktop/NetworkManager/AccessPoint/4
Active Connections
/org/freedesktop/NetworkManager/ActiveConnection/8
ServiceName: org.freedesktop.NetworkManagerSystemSettings
Connection: /org/freedesktop/NetworkManagerSettings/0
SpecificObject: /
SharedServiceName:
SharedConnection: /
Devices: dbus.Array([dbus.ObjectPath('/org/freedesktop/Hal/devices/net_00_02_3f_0d_7d_93')], signature=dbus.Signature('o'), variant_level=1)
/org/freedesktop/NetworkManager/ActiveConnection/9
ServiceName: org.freedesktop.NetworkManagerUserSettings
Connection: /org/freedesktop/NetworkManagerSettings/Connection/0
SpecificObject: /org/freedesktop/NetworkManager/AccessPoint/4
SharedServiceName:
SharedConnection: /
Devices: dbus.Array([dbus.ObjectPath('/org/freedesktop/Hal/devices/net_00_11_d8_70_00_2f')], signature=dbus.Signature('o'), variant_level=1)

Apr 30, 2008

D-Bus Sightseeing

I figured it was time to learn more about D-Bus. Today, let me share some useful calls that I found so far. Hopefully they will inspire you to experimenting too and together we will have a chance of learning more.
$ dbus-send --print-reply \
--dest=org.kde.klipper \
/klipper \
org.kde.klipper.klipper.getClipboardContents
method return sender=:1.37 -> dest=:1.73 reply_serial=2
string "Hello D-Bus"

Your result will be probably different. In fact, I spent several minutes wondering why the method does not return anything and just repeats its name ;-)
The meaning of the parameters: --dest is the destination connection; apparently D-Bus cannot find it out from the following parameter: /klipper: the destination object. org.kde.klipper.klipper is the interface. Most objects have their own interface plus the introspection interface org.freedesktop.DBus.Introspectable. getClipboardContents is of course the method name.

For further exploration, the GUI tool qdbusviewer is very useful. Try it for calling getClipboardContents now.
$ dbus-send --type=method_call --dest=org.kde.kwin \
/KWin org.kde.KWin.nextDesktop
$ dbus-send --type=method_call --dest=org.kde.kwin \
/KWin org.kde.KWin.previousDesktop
$ dbus-send --type=method_call --dest=org.kde.plasma \
/App org.kde.plasma.App.toggleDashboard
The type option is necessary because dbus-call defaults to type=signal which would not work. (BTW does anyone have a nice example for demonstrating a signal?) With print-reply in the first example, type=method_call is implied.

Let's pass some arguments:
$ dbus-send --type=method_call --dest=org.kde.klipper \
/klipper org.kde.klipper.klipper.setClipboardContents \
string:'Test Beta2!'
$ dbus-send --type=method_call --dest=org.kde.krunner \
/Interface org.kde.krunner.Interface.display \
string:'system'
So far we have been using the session bus. The system-wide bus offers even more fun:
$ dbus-send --system --print-reply \
--dest=org.freedesktop.NetworkManagerSystemSettings \
/org/freedesktop/NetworkManagerSettings \
org.freedesktop.NetworkManagerSettings.ListConnections

array [
object path "/org/freedesktop/NetworkManagerSettings/0"
object path "/org/freedesktop/NetworkManagerSettings/1"
object path "/org/freedesktop/NetworkManagerSettings/2"
]

$ dbus-send --system --print-reply \
--dest=org.freedesktop.NetworkManagerSystemSettings \
/org/freedesktop/NetworkManagerSettings/1 \
org.freedesktop.NetworkManagerSettings.Connection.GetSettings

array [
dict entry(
string "802-11-wireless"
array [
dict entry(
string "ssid"
variant array [
byte 102
byte 114
byte 111
byte 103
byte 115
]
)
dict entry(
string "security"
variant string "802-11-wireless-security"
)
]
)
/* more data. BTW you can't see any of this in qdbusviewer. */
]
(Interesting, every even call to NMS fails with a timeout)

Finally, a long list to scroll up while the music plays:
$ dbus-send --system --print-reply \
--dest=org.freedesktop.Hal \
/org/freedesktop/Hal/Manager \
org.freedesktop.Hal.Manager.GetAllDevices