[node-patches] Change in ovirt-node[master]: Fix the installer for EL7 and general logic changes

rbarry at redhat.com rbarry at redhat.com
Fri Aug 15 18:41:26 UTC 2014


Ryan Barry has uploaded a new change for review.

Change subject: Fix the installer for EL7 and general logic changes
......................................................................

Fix the installer for EL7 and general logic changes

Pass yes to lvcreate so it overwrites LVs with signatures (which
shouldn't matter during the install anyway), and force wiping the
filesystem now that it's required.

Additionally, be smarter about whether to mount /liveos. Don't
try to mount any local filesystems at /liveos if we're booted
from a CD

Change-Id: I327fb0026d739361ad5c932a12cf3b536057be9a
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1095081
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M scripts/ovirt-functions.in
M src/ovirtnode/ovirtfunctions.py
M src/ovirtnode/storage.py
3 files changed, 28 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/44/31544/1

diff --git a/scripts/ovirt-functions.in b/scripts/ovirt-functions.in
index 435678e..2bbdc2f 100644
--- a/scripts/ovirt-functions.in
+++ b/scripts/ovirt-functions.in
@@ -356,7 +356,9 @@
         return 0
     fi
     mkdir -p /liveos
-    mount LABEL=Root /liveos || mount -r LABEL=Root /liveos
+    if grep -vq "CDLABEL" /proc/cmdline; then
+        mount LABEL=Root /liveos || mount -r LABEL=Root /liveos
+    fi
 }
 
 mount_iscsi_liveos() {
diff --git a/src/ovirtnode/ovirtfunctions.py b/src/ovirtnode/ovirtfunctions.py
index 1d53297..329cc75 100644
--- a/src/ovirtnode/ovirtfunctions.py
+++ b/src/ovirtnode/ovirtfunctions.py
@@ -522,21 +522,22 @@
         if is_iscsi_install():
             connect_iscsi_root()
         system_closefds("mkdir -p /liveos")
-        if not system("mount LABEL=Root /liveos &>/dev/null"):
-            # just in case /dev/disk/by-label is not using devmapper and fails
-            for dev in os.listdir("/dev/mapper"):
-                if system("e2label \"/dev/mapper/" + dev + "\" 2>/dev/null|grep Root|grep -v Backup"):
-                    system("rm -rf /dev/disk/by-label/Root")
-                    system("ln -s \"/dev/mapper/" + dev + "\" /dev/disk/by-label/Root")
-                    if system("mount LABEL=Root /liveos"):
-                        return True
-                    else:
-                        if os.path.ismount("/dev/.initramfs/live"):
-                            system_closefds("mount -o bind /dev/.initramfs/live /liveos")
-                        elif os.path.ismount("/run/initramfs/live"):
-                            system_closefds("mount -o bind /run/initramfs/live /liveos")
-                        else:
-                            return False
+        if not "CDLABEL" in open("/proc/cmdline").read()
+            if not system("mount LABEL=Root /liveos &>/dev/null"):
+                # just in case /dev/disk/by-label is not using devmapper and fails
+                for dev in os.listdir("/dev/mapper"):
+                    if system("e2label \"/dev/mapper/" + dev + "\" 2>/dev/null|grep Root|grep -v Backup"):
+                        system("rm -rf /dev/disk/by-label/Root")
+                        system("ln -s \"/dev/mapper/" + dev + "\" /dev/disk/by-label/Root")
+                        if system("mount LABEL=Root /liveos"):
+                            return True
+        elif "CDLABEL" in open("/proc/cmdline").read():
+            if os.path.ismount("/dev/.initramfs/live"):
+                system_closefds("mount -o bind /dev/.initramfs/live /liveos")
+            elif os.path.ismount("/run/initramfs/live"):
+                system_closefds("mount -o bind /run/initramfs/live /liveos")
+            else:
+                return False
         else:
             return True
 
@@ -1365,7 +1366,7 @@
     logger.info("Wiping old boot sector")
 #    system_closefds("dd if=/dev/zero of=\""+ drive +"\" bs=1024K count=1 &>>" + OVIRT_TMP_LOGFILE)
     system_closefds("parted -s \""+ drive +"\" mklabel loop &>>" + OVIRT_TMP_LOGFILE)
-    system_closefds("wipefs -a \""+ drive +"\" &>>" + OVIRT_TMP_LOGFILE)
+    system_closefds("wipefs -af \""+ drive +"\" &>>" + OVIRT_TMP_LOGFILE)
     ## zero out the GPT secondary header
     #logger.info("Wiping secondary gpt header")
     #disk_kb = subprocess_closefds("sfdisk -s \""+ drive +"\" 2>/dev/null", shell=True, stdout=PIPE, stderr=STDOUT)
diff --git a/src/ovirtnode/storage.py b/src/ovirtnode/storage.py
index dceb539..d18ba8e 100644
--- a/src/ovirtnode/storage.py
+++ b/src/ovirtnode/storage.py
@@ -511,7 +511,7 @@
             drv_count = drv_count + 1
         if self.SWAP_SIZE > 0:
             logger.info("Creating swap partition")
-            _functions.system("lvcreate --name Swap --size " + \
+            _functions.system("yes | lvcreate --name Swap --size " + \
                               str(self.SWAP_SIZE) + "M /dev/HostVG")
             _functions.system("mkswap -L \"SWAP\" /dev/HostVG/Swap")
             _functions.system_closefds("echo \"/dev/HostVG/Swap swap swap " +
@@ -523,14 +523,14 @@
                                 "\" >> /etc/ovirt-crypttab")
         if self.CONFIG_SIZE > 0:
             logger.info("Creating config partition")
-            _functions.system("lvcreate --name Config --size " +
+            _functions.system("yes | lvcreate --name Config --size " +
                     str(self.CONFIG_SIZE) + "M /dev/HostVG")
             _functions.system("mke2fs -j -t ext4 /dev/HostVG/Config " + \
                               "-L \"CONFIG\"")
             _functions.system("tune2fs -c 0 -i 0 /dev/HostVG/Config")
         if self.LOGGING_SIZE > 0:
             logger.info("Creating log partition")
-            _functions.system("lvcreate --name Logging --size " +
+            _functions.system("yes | lvcreate --name Logging --size " +
                     str(self.LOGGING_SIZE) + "M /dev/HostVG")
             _functions.system("mke2fs -j -t ext4 /dev/HostVG/Logging " + \
                               "-L \"LOGGING\"")
@@ -541,11 +541,11 @@
         use_data = 1
         if self.DATA_SIZE == -1:
             logger.info("Creating data partition with remaining free space")
-            _functions.system("lvcreate --name Data -l 100%FREE /dev/HostVG")
+            _functions.system("yes | lvcreate --name Data -l 100%FREE /dev/HostVG")
             use_data = 0
         elif self.DATA_SIZE > 0:
             logger.info("Creating data partition")
-            _functions.system("lvcreate --name Data --size " + \
+            _functions.system("yes | lvcreate --name Data --size " + \
                               str(self.DATA_SIZE) + "M /dev/HostVG")
             use_data = 0
         if use_data == 0:
@@ -676,7 +676,7 @@
 
         if self.SWAP2_SIZE > 0:
             logger.info("Creating swap2 partition")
-            lv_cmd = ("lvcreate --name Swap2 --size \"" +
+            lv_cmd = ("yes | lvcreate --name Swap2 --size \"" +
                       str(self.SWAP2_SIZE) + "M\" /dev/AppVG")
             logger.debug(lv_cmd)
             _functions.system(lv_cmd)
@@ -693,11 +693,11 @@
         use_data = "1"
         if self.DATA2_SIZE == -1:
             logger.info("Creating data2 partition with remaining free space")
-            _functions.system("lvcreate --name Data2 -l 100%FREE /dev/AppVG")
+            _functions.system("yes | lvcreate --name Data2 -l 100%FREE /dev/AppVG")
             use_data = 0
         elif self.DATA2_SIZE > 0:
             logger.info("Creating data2 partition")
-            _functions.system("lvcreate --name Data2 --size " + \
+            _functions.system("yes | lvcreate --name Data2 --size " + \
                               str(self.DATA2_SIZE) +
                    "M /dev/AppVG")
             use_data = 0


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I327fb0026d739361ad5c932a12cf3b536057be9a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list