[node-patches] Change in ovirt-node[master]: [DRAFT] boot: Persist NIC order at boot time

fabiand at fedoraproject.org fabiand at fedoraproject.org
Thu Oct 11 11:18:13 UTC 2012


Fabian Deutsch has uploaded a new change for review.

Change subject: [DRAFT] boot: Persist NIC order at boot time
......................................................................

[DRAFT] boot: Persist NIC order at boot time

Previously the NIC order was only persisted when a NIC got configured.
Now the order of the NICs is persisted at boot time.

Change-Id: I8a5d830c0664264fc67ce7270c284ddc5551c3c8
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/ovirt-functions.in
M scripts/ovirt-init-functions.sh
M scripts/ovirtnode/network.py
3 files changed, 39 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/97/8497/1

diff --git a/scripts/ovirt-functions.in b/scripts/ovirt-functions.in
index 712af3e..dc3b499 100644
--- a/scripts/ovirt-functions.in
+++ b/scripts/ovirt-functions.in
@@ -1227,6 +1227,14 @@
 EOP
 }
 
+persist_nic_order ()
+{
+    python <<EOP
+import ovirtnode.network
+ovirtnode.network.persist_nic_order()
+EOP
+}
+
 # execute a function if called as a script, e.g.
 #   ovirt-functions ovirt_store_config /etc/hosts
 
diff --git a/scripts/ovirt-init-functions.sh b/scripts/ovirt-init-functions.sh
index 72825aa..44ed61c 100644
--- a/scripts/ovirt-init-functions.sh
+++ b/scripts/ovirt-init-functions.sh
@@ -826,6 +826,8 @@
         fi
     fi
 
+    persist_nic_order
+    # Now that the order is (eventually) persisted, apply it.
     [[ -f "/etc/udev/rules.d/71-persistent-node-net.rules" ]] && {
         # Rename the interfaces after bind-mounting the udev rules, rhbz#831658
         rm -f /etc/udev/rules.d/70-persistent-net.rules
diff --git a/scripts/ovirtnode/network.py b/scripts/ovirtnode/network.py
index b4b5667..ecd813a 100644
--- a/scripts/ovirtnode/network.py
+++ b/scripts/ovirtnode/network.py
@@ -372,22 +372,6 @@
         _functions.ovirt_store_config("/etc/sysconfig/network")
         _functions.ovirt_store_config("/etc/hosts")
 
-        # Copy the initial net rules to a file that get's not
-        # overwritten at each boot, rhbz#773495
-        rulesfile = "/etc/udev/rules.d/70-persistent-net.rules"
-        newrulesfile = "/etc/udev/rules.d/71-persistent-node-net.rules"
-        if os.path.exists(rulesfile):
-            _functions.system_closefds("cp %s %s >> /var/log/ovirt.log" % (
-                                                                rulesfile,
-                                                                newrulesfile))
-            _functions.ovirt_store_config(newrulesfile)
-
-            # Eventully it makes sense to rename the NICs
-            #system_closefds("sed -ic 's/NAME=\"eth/NAME=\"eth00/' " +
-            #                 "/etc/udev/rules.d/71-persistent-node-net.rules")
-
-
-
         logger.info("Network configured successfully")
         if net_configured == 1:
             logger.info("Stopping Network services")
@@ -573,6 +557,35 @@
     return True
 
 
+def persist_nic_order():
+        # Copy the initial net rules to a file that get's not
+        # overwritten at each boot, rhbz#773495
+        rulesfile = "/etc/udev/rules.d/70-persistent-net.rules"
+        newrulesfile = "/etc/udev/rules.d/71-persistent-node-net.rules"
+
+        if os.path.exists(newrulesfile):
+            logger.debug("NIC order already persisted in '%s'" % (
+                                                                newrulesfile))
+            _functions.system_closefds("dmesg | grep udev " +
+                                       " >> /var/log/ovirt.log")
+            return
+
+        if os.path.exists(rulesfile):
+            _functions.system_closefds("cp %s %s >> /var/log/ovirt.log" % (
+                                                                rulesfile,
+                                                                newrulesfile))
+            _functions.ovirt_store_config(newrulesfile)
+
+            # Eventully it makes sense to rename the NICs
+            #system_closefds("sed -ic 's/NAME=\"eth/NAME=\"eth00/' " +
+            #                 "/etc/udev/rules.d/71-persistent-node-net.rules")
+            logger.debug("NIC order successfully persisted in '%s'" % (
+                                                                newrulesfile))
+        else:
+            logger.debug("Not persisting NIC order, '%s' not present" % (
+                                                                rulesfile))
+
+
 def network_auto():
     try:
         network = Network()


--
To view, visit http://gerrit.ovirt.org/8497
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a5d830c0664264fc67ce7270c284ddc5551c3c8
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list