diff options
author | David Cantrell <dcantrel@dado.honolulu.burdell.org> | 2008-09-17 16:38:49 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2008-09-18 09:14:42 -1000 |
commit | 37216e27911e044abdede9f842f4528ca5d1ee24 (patch) | |
tree | 2a1f28fc14a0ae2fbce5be8c9fcca74e7f5b19cf /network.py | |
parent | 56512e7f78fe08a6087a1dc623e0f52175e11252 (diff) | |
download | anaconda-37216e27911e044abdede9f842f4528ca5d1ee24.tar.gz anaconda-37216e27911e044abdede9f842f4528ca5d1ee24.tar.xz anaconda-37216e27911e044abdede9f842f4528ca5d1ee24.zip |
Add getDefaultHostname() to network.py
getDefaultHostname() returns a string to the caller (either the
iw or textw interface that contains the default hostname to
populate the UI with.
Diffstat (limited to 'network.py')
-rw-r--r-- | network.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/network.py b/network.py index c903a255b..e7e5962d6 100644 --- a/network.py +++ b/network.py @@ -67,6 +67,18 @@ def sanityCheckHostname(hostname): return None +# Try to determine what the hostname should be for this system +def getDefaultHostname(anaconda): + hn = anaconda.id.network.hostname + + if hn is None or hn == '': + hn = socket.gethostname() + + if hn is None or hn == '': + hn = 'localhost.localdomain' + + return hn + # return if the device is of a type that requires a ptpaddr to be specified def isPtpDev(devname): if (devname.startswith("ctc") or devname.startswith("iucv")): @@ -208,6 +220,7 @@ class Network: self.netdevices[dev].set(('BOOTPROTO', 'dhcp')) else: self.netdevices[dev].unset('BOOTPROTO') + bus = dbus.SystemBus() config_path = props.Get(isys.NM_MANAGER_IFACE, 'Ip4Config') config = bus.get_object(isys.NM_SERVICE, config_path) config_props = dbus.Interface(config, isys.DBUS_PROPS_IFACE) |