summaryrefslogtreecommitdiffstats
path: root/network.py
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2008-08-27 22:24:19 -1000
committerDavid Cantrell <dcantrell@redhat.com>2008-08-27 22:24:19 -1000
commit1ea81b1f85d2ba3f21c4bb03fa0e2f1ed2901e85 (patch)
treed6a0738f19eeb072d57014de513e2eab0fe13447 /network.py
parent56476cc484579a578cd1f0cc76c9873640b12108 (diff)
downloadanaconda-1ea81b1f85d2ba3f21c4bb03fa0e2f1ed2901e85.tar.gz
anaconda-1ea81b1f85d2ba3f21c4bb03fa0e2f1ed2901e85.tar.xz
anaconda-1ea81b1f85d2ba3f21c4bb03fa0e2f1ed2901e85.zip
Do not call has_key() on NetworkDevice, use isys.NM_*
The NetworkDevice class does not have has_key(), just call get() and check to see if it's empty. The NM_ and DBUS_ constants are currently in isys, so reference them there. Ideally NetworkManager would be offering a Python module that provides this sort of info.
Diffstat (limited to 'network.py')
-rw-r--r--network.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/network.py b/network.py
index 24c9182dd..7c8ea318b 100644
--- a/network.py
+++ b/network.py
@@ -83,20 +83,20 @@ def _anyUsing(method):
methods = (method)
bus = dbus.SystemBus()
- nm = bus.get_object(NM_SERVICE, NM_MANAGER_PATH)
- nm_props_iface = dbus.Interface(nm, DBUS_PROPS_IFACE)
+ nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH)
+ nm_props_iface = dbus.Interface(nm, isys.DBUS_PROPS_IFACE)
- active_connections = nm_props_iface.Get(NM_MANAGER_IFACE, "ActiveConnections")
+ active_connections = nm_props_iface.Get(isys.NM_MANAGER_IFACE, "ActiveConnections")
for path in active_connections:
- active = bus.get_object(NM_SERVICE, path)
- active_props_iface = dbus.Interface(active, DBUS_PROPS_IFACE)
+ active = bus.get_object(isys.NM_SERVICE, path)
+ active_props_iface = dbus.Interface(active, isys.DBUS_PROPS_IFACE)
- active_service_name = active_props_iface.Get(NM_ACTIVE_CONNECTION_IFACE, "ServiceName")
- active_path = active_props_iface.Get(NM_ACTIVE_CONNECTION_IFACE, "Connection")
+ active_service_name = active_props_iface.Get(isys.NM_ACTIVE_CONNECTION_IFACE, "ServiceName")
+ active_path = active_props_iface.Get(isys.NM_ACTIVE_CONNECTION_IFACE, "Connection")
connection = bus.get_object(active_service_name, active_path)
- connection_iface = dbus.Interface(connection, NM_CONNECTION_IFACE)
+ connection_iface = dbus.Interface(connection, isys.NM_CONNECTION_IFACE)
settings = connection_iface.GetSettings()
# XXX: add support for Ip6Config when it appears
@@ -289,19 +289,19 @@ class Network:
self.domains.append(ifcfg_contents[key])
elif key == 'HOSTNAME':
self.hostname = ifcfg_contents[key]
- elif not self.netdevices[dev].has_key(key):
+ elif self.netdevices[dev].get(key) == '':
self.netdevices[dev].set((key, ifcfg_contents[key]))
self.netdevices[dev].set(('useIPv4', flags.useIPv4))
self.netdevices[dev].set(('useIPv6', flags.useIPv6))
# XXX: fix this block
- if not self.netdevices[dev].has_key('BOOTPROTO'):
- if not self.netdevices[dev].has_key('IPADDR'):
+ if self.netdevices[dev].get('BOOTPROTO') == '':
+ if self.netdevices[dev].get('IPADDR') == '':
self.netdevices[dev].set(('useIPv4', False))
- if not (self.netdevices[dev].has_key('IPV6ADDR') and \
- self.netdevices[dev].has_key('IPV6_AUTOCONF') and \
- self.netdevices[dev].has_key('DHCPV6C')):
+ if (self.netdevices[dev].get('IPV6ADDR') == '' and \
+ self.netdevices[dev].get('IPV6_AUTOCONF') == '' and \
+ self.netdevices[dev].get('DHCPV6C') == ''):
self.netdevices[dev].set(('useIPv6', False))
# XXX: this code needs to be improved too
@@ -346,6 +346,7 @@ class Network:
return self.firstnetdevice
def available(self):
+ # XXX: this should use NetworkManager
for device in minihal.get_devices_by_type("net"):
if device.has_key('net.arp_proto_hw_id'):
if device['net.arp_proto_hw_id'] == 1:
@@ -361,7 +362,7 @@ class Network:
if flags.cmdline.has_key("ksdevice"):
ksdevice = flags.cmdline["ksdevice"]
- if ksdevice and self.netdevices.has_key(ksdevice):
+ if ksdevice and self.netdevices.get(ksdevice) != '':
self.firstnetdevice = ksdevice
return self.netdevices