[node-patches] Change in ovirt-node[master]: install: Fix erasure and discovery of disk labels
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Thu Dec 20 15:46:53 UTC 2012
Fabian Deutsch has uploaded a new change for review.
Change subject: install: Fix erasure and discovery of disk labels
......................................................................
install: Fix erasure and discovery of disk labels
This patch addresses two problems: First dd was used to remove the gpt
label, this can lead to problems with the kernel/dm because this changes
the disk layout without telling the kernel.
Another fix is to also translate the ROOTDEVICE name into it's multipath
representative.
rhbz#872502
Change-Id: I147a9aef04633332b3503cfeec0e738b81c824de
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/ovirtnode/install.py
M scripts/ovirtnode/ovirtfunctions.py
M scripts/ovirtnode/storage.py
3 files changed, 34 insertions(+), 21 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/88/10288/1
diff --git a/scripts/ovirtnode/install.py b/scripts/ovirtnode/install.py
index b825ac3..b1e3dbc 100755
--- a/scripts/ovirtnode/install.py
+++ b/scripts/ovirtnode/install.py
@@ -316,13 +316,23 @@
_functions.system("service iscsi restart")
except:
pass
- if _functions.findfs("RootBackup"):
- candidate = "RootBackup"
- elif _functions.findfs("RootUpdate"):
- candidate = "RootUpdate"
- elif _functions.findfs("RootNew"):
- candidate = "RootNew"
- else:
+
+ candidate = None
+ candidate_names = ["RootBackup", "RootUpdate", "RootNew"]
+ for trial in range(1, 3):
+ time.sleep(1)
+ _functions.system("partprobe")
+ for candidate_name in candidate_names:
+ if _functions.findfs(candidate_name):
+ candidate = candidate_name
+ break
+ logger.debug("Trial %s to find candidate (%s)" % (trial,
+ candidate))
+ if candidate:
+ logger.debug("Found candidate: %s" % candidate)
+ break
+
+ if not candidate:
logger.error("Unable to find root partition")
label_debug = ''
for label in os.listdir("/dev/disk/by-label"):
@@ -332,7 +342,6 @@
stderr=subprocess.STDOUT).stdout.read()
logger.debug(label_debug)
return False
- logger.debug("candidate: " + candidate)
if _functions.is_iscsi_install():
_functions.system("mount LABEL=%s /boot" % self.boot_candidate)
diff --git a/scripts/ovirtnode/ovirtfunctions.py b/scripts/ovirtnode/ovirtfunctions.py
index 0274330..0fce24e 100644
--- a/scripts/ovirtnode/ovirtfunctions.py
+++ b/scripts/ovirtnode/ovirtfunctions.py
@@ -1090,7 +1090,9 @@
return False
# Cleans partition tables
-def wipe_partitions(drive):
+def wipe_partitions(_drive):
+ drive = translate_multipath_device(_drive)
+ logger.info("Wiping partitions on: %s->%s" % (_drive, drive))
logger.info("Removing HostVG")
if os.path.exists("/dev/mapper/HostVG-Swap"):
system_closefds("swapoff -a")
@@ -1099,12 +1101,14 @@
if "HostVG" in lv:
system_closefds("dmsetup remove " +lv + " &>>" + OVIRT_TMP_LOGFILE)
logger.info("Wiping old boot sector")
- system_closefds("dd if=/dev/zero of=\""+ drive +"\" bs=1024K count=1 &>>" + 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)
- disk_kb_count = disk_kb.stdout.read()
- system_closefds("dd if=/dev/zero of=\"" +drive +"\" bs=1024 seek=$(("+ disk_kb_count+" - 1)) count=1 &>>" + OVIRT_TMP_LOGFILE)
+# 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)
+ ## 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)
+ #disk_kb_count = disk_kb.stdout.read()
+ #system_closefds("dd if=/dev/zero of=\"" +drive +"\" bs=1024 seek=$(("+ disk_kb_count+" - 1)) count=1 &>>" + OVIRT_TMP_LOGFILE)
system_closefds("sync")
def test_ntp_configuration(self):
diff --git a/scripts/ovirtnode/storage.py b/scripts/ovirtnode/storage.py
index ee4c401..cb7f24a 100644
--- a/scripts/ovirtnode/storage.py
+++ b/scripts/ovirtnode/storage.py
@@ -27,13 +27,11 @@
import subprocess
import shlex
-logger = logging.getLogger(__name__)
-
class Storage:
def __init__(self):
- logger = logging.getLogger(_functions.PRODUCT_SHORT)
- logger.propagate = False
+ #logger = logging.getLogger(PRODUCT_SHORT)
+ #logger.propagate = False
OVIRT_VARS = _functions.parse_defaults()
self.overcommit = 0.5
self.BOOT_SIZE = 50
@@ -63,9 +61,9 @@
for disk in init:
skip = False
if disk_count < 1:
- self.ROOTDRIVE = disk
+ self.ROOTDRIVE = _functions.translate_multipath_device(disk)
if len(init) == 1:
- self.HOSTVGDRIVE = disk
+ self.HOSTVGDRIVE = _functions.translate_multipath_device(disk)
disk_count = disk_count + 1
else:
for hostvg in self.HOSTVGDRIVE.split(","):
@@ -238,6 +236,7 @@
# XXX fails with spaces in device names (TBI)
# ioctl(3, DM_TABLE_LOAD, 0x966980) = -1 EINVAL (Invalid argument)
# create/reload failed on 0QEMU QEMU HARDDISK drive-scsi0-0-0p1
+ _functions.system("kpartx -a '%s'" % drive)
_functions.system("partprobe")
# partprobe fails on cdrom:
# Error: Invalid partition table - recursive partition on /dev/sr0.
@@ -841,6 +840,7 @@
str(self.RootBackup_end) + "M\"")
logger.debug(parted_cmd)
_functions.system(parted_cmd)
+ _functions.system("sync ; udevadm settle ; partprobe")
parted_cmd = ("parted \"" + self.ROOTDRIVE +
"\" -s \"set 2 boot on\"")
logger.debug(parted_cmd)
--
To view, visit http://gerrit.ovirt.org/10288
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I147a9aef04633332b3503cfeec0e738b81c824de
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