[PATCH master 6/7] networking: use ksdata.network.hostname instead of actual installer hostname

Radek Vykydal rvykydal at redhat.com
Fri Aug 24 09:36:16 UTC 2012


ksdata.network.hostname which is new property (there is a related kickstart
patch) obtaining the hostname from network commands (ksdata.network.network
list of NetworkData objects). The goal is to use this data instead
of getting actual hostname of installer (getHostname function)

notes:

- ksdata.network.hostname value will be initalized in networkInitialize
  (following patch)

- getHostname (actual hostname of system) is still used in dracutSetupArgs,
  we need to get ksdata passed somehow from bootloader.py:set_boot_args()

- Hostname of installer environment is still set in kickstart. We used to
  do it because of mdadm member naming (640743) but this is not needed
  anymore - mdadm actually doesn't use it. If it starts to again, or
  does it in some special conditions, we can pass ksdata.network.hostname
  (as we do for default vg names) using --homehost option.
  We might need to set the hostname for some installed package though,
  so I am keeping it.

- We should think about where to set hostname in GUI. This should happen
  before writing storage (needed for vg, mdmember names), or we can drop
  default naming based on hostname.
---
 anaconda.spec.in               |    2 +-
 pyanaconda/network.py          |    6 +-----
 pyanaconda/storage/__init__.py |   14 ++++----------
 3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/anaconda.spec.in b/anaconda.spec.in
index f5d8bd9..93e0115 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -26,7 +26,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 %define intltoolver 0.31.2-3
 %define libnlver 1.0
 %define libselinuxver 1.6
-%define pykickstartver 1.99.16
+%define pykickstartver 1.99.17
 %define rpmpythonver 4.2-0.61
 %define slangver 2.0.6-2
 %define yumver 3.4.3-32
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 1118357..e5c4a88 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -773,11 +773,7 @@ def write_sysconfig_network(rootpath, ksdata, overwrite=False):
     f.write("NETWORKING=yes\n")
     f.write("HOSTNAME=")
 
-    hostname = getHostname()
-    if hostname:
-        f.write(hostname + "\n")
-    else:
-        f.write("localhost.localdomain\n")
+    f.write("HOSTNAME=%s\n" % ksdata.network.hostname)
 
     gateway = ipv6_defaultgw = None
     for iface in reversed(getDevices()):
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index 8794055..e71c65e 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -1114,11 +1114,8 @@ class Storage(object):
             name = kwargs.pop("name")
         else:
             hostname = ""
-            if self.data:
-                for nd in self.data.network.dataList():
-                    if nd.hostname:
-                        hostname = nd.hostname
-                        break
+            if self.data and self.data.network.hostname is not None:
+                hostname = self.data.network.hostname
 
             name = self.suggestContainerName(hostname=hostname)
 
@@ -1186,11 +1183,8 @@ class Storage(object):
             # set up the volume label, using hostname if necessary
             if not name:
                 hostname = ""
-                if self.data:
-                    for nd in self.data.network.dataList():
-                        if nd.hostname:
-                            hostname = nd.hostname
-                            break
+                if self.data and self.data.network.hostname is not None:
+                    hostname = self.data.network.hostname
 
                 name = self.suggestContainerName(hostname=hostname)
             if "label" not in fmt_args:
-- 
1.7.4



More information about the anaconda-patches mailing list