[node-patches] Change in ovirt-node[master]: network: if /etc/hostname doesn't exist, create it

dougsland at redhat.com dougsland at redhat.com
Thu Jul 16 21:19:49 UTC 2015


Douglas Schilling Landgraf has uploaded a new change for review.

Change subject: network: if /etc/hostname doesn't exist, create it
......................................................................

network: if /etc/hostname doesn't exist, create it

During autoinstall we must make sure /etc/hostname file
exists in the distro. This patch make sure:

- The installation will create /etc/hostname if it
  doesn't exist via hostnamectl.

- strip values during comparation of variables,
  othewise caracteres '\n' can be catch.

Change-Id: Idebfed15f63111ddc9b36ec09619b0f685b8394b
Signed-off-by: Douglas Schilling Landgraf <dougsland at redhat.com>
---
M src/ovirt/node/config/network.py
1 file changed, 7 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/54/43754/1

diff --git a/src/ovirt/node/config/network.py b/src/ovirt/node/config/network.py
index b5cbc61..1a6840e 100644
--- a/src/ovirt/node/config/network.py
+++ b/src/ovirt/node/config/network.py
@@ -235,8 +235,14 @@
         utils.process.check_call(["hostnamectl", "set-hostname",
                                   new_hostname])
 
+    if not os.path.exists("/etc/hostname") and new_hostname is None:
+        new_hostname = "localhost.localdomain"
+        utils.process.check_call(["hostnamectl", "set-hostname",
+                                  new_hostname])
+        return new_hostname
+
     current_hostname = utils.fs.get_contents(hostnamefile)
-    if new_hostname and current_hostname != new_hostname:
+    if new_hostname and current_hostname.strip() != new_hostname.strip():
         raise RuntimeError(("Runtime hostname '%s' doesn't match" +
                             "configured one: %s") % (current_hostname,
                                                      new_hostname))


-- 
To view, visit https://gerrit.ovirt.org/43754
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idebfed15f63111ddc9b36ec09619b0f685b8394b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>



More information about the node-patches mailing list