[node-patches] Change in ovirt-node[master]: move storage selection enumeration to blivet modules
jboggs at redhat.com
jboggs at redhat.com
Sun Dec 15 20:55:13 UTC 2013
Joey Boggs has uploaded a new change for review.
Change subject: move storage selection enumeration to blivet modules
......................................................................
move storage selection enumeration to blivet modules
Signed-off-by: Joey Boggs <jboggs at redhat.com>
Change-Id: I5ad7eef4c5dace5e70ede7d5a5a8ef079d2cf9f8
---
M recipe/fedora-pkgs.ks
M recipe/image-minimizer.ks.in
M src/ovirt/node/utils/storage.py
3 files changed, 94 insertions(+), 25 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/98/22398/1
diff --git a/recipe/fedora-pkgs.ks b/recipe/fedora-pkgs.ks
index 6ffd7cb..ae73076 100644
--- a/recipe/fedora-pkgs.ks
+++ b/recipe/fedora-pkgs.ks
@@ -32,3 +32,4 @@
#async reboot
python-daemon
+python-blivet
diff --git a/recipe/image-minimizer.ks.in b/recipe/image-minimizer.ks.in
index 956bc20..a155713 100644
--- a/recipe/image-minimizer.ks.in
+++ b/recipe/image-minimizer.ks.in
@@ -4,8 +4,24 @@
%end
%post
+
+# save blivet disklabel python source before removal
+if [ -e /usr/lib/python2.6 ]; then
+ PYTHONPATH="/usr/lib/python2.6/site-packages/blivet"
+elif [ -e /usr/lib/python2.7 ]; then
+ PYTHONPATH="/usr/lib/python2.7/site-packages/blivet"
+fi
+
+if [ -n $PYTHONPATH ]; then
+ cp -a $PYTHONPATH/formats/disklabel.py /tmp
+fi
+
echo "Removing python source files"
find /usr -name '*.py' -exec rm -f {} \;
find /usr -name '*.pyo' -exec rm -f {} \;
+# move blivet disklabel source back inplace
+if [ -n /tmp/disklabel.py ]; then
+ cp -a /tmp/disklabel.py $PYTHONPATH/formats/
+fi
%end
diff --git a/src/ovirt/node/utils/storage.py b/src/ovirt/node/utils/storage.py
index 8958b70..93f1c71 100644
--- a/src/ovirt/node/utils/storage.py
+++ b/src/ovirt/node/utils/storage.py
@@ -23,7 +23,7 @@
from ovirt.node.utils import process
from ovirt.node.utils.fs import File
import os
-
+import blivet
class iSCSI(base.Base):
"""A class to deal with some external iSCSI related functionality
@@ -108,31 +108,83 @@
"""
if self._fake_devices:
return self._fake_devices
- from ovirtnode.ovirtfunctions import translate_multipath_device
- dev_names, disk_dict = self._storage.get_udev_devices()
+ valid_devs = {}
+ blacklisted_devs = []
+ self.logger.debug("Adding live disk to blacklist")
+ blacklisted_devs.append(self.live_disk_name())
+ devicetree = blivet.Blivet()
+ devicetree.reset()
+ devices = devicetree.devices
+ disks = [d for d in devices if d.isDisk and
+ d.size > 0 and
+ not d.format.hidden and
+ not (d.protected and
+ d.removable)]
+ for disk in disks:
+ parent_dev_path = ""
+ self.logger.debug("Disk: %s" % disk.path)
+ self.logger.debug("Parents: %s" % disk.path)
+ parent_dev = [b.path for b in disk.parents]
+ has_parent = False
+ if len(parent_dev) > 0:
+ has_parent = True
+
+ self.logger.debug("Device has parent: %s" % has_parent)
+ if has_parent:
+ parent_dev_path = parent_dev[0]
+ blacklisted_devs.append(parent_dev_path)
+ self.logger.debug("Blacklisting: %s" % parent_dev_path)
+ bus = disk.bus.lower()
+ if not bus or len(bus) == 0:
+ bus = "ata"
+ busmap = { \
+ "usb": "USB Device ", \
+ "ata": "Local / FibreChannel", \
+ "scsi": "Local / FibreChannel", \
+ "cciss": "CCISS " \
+ }
+ if bus in busmap:
+ bus = busmap[bus]
+ elif "/dev/vd" in disk.path:
+ bus = "Local (Virtio) "
+ vendor = "Virtio Device"
+ self.logger.debug("Disk bus: %s" % bus)
+
+ size = int(disk.size / 1024)
+ vendor = disk.vendor
+ if not vendor:
+ vendor = "Not Available"
+
+ valid_devs[disk.path] = "%s,%s|%s,%s,%s,%s,%s" % (bus,
+ disk.path,
+ parent_dev_path,
+ size,
+ vendor,
+ disk.serial,
+ disk.model
+ )
+
+ self.logger.debug(valid_devs)
+ self.logger.debug(blacklisted_devs)
+
devices = {}
- for _dev in dev_names:
- dev = translate_multipath_device(_dev)
- self.logger.debug("Checking device %s (%s)" % (dev, _dev))
- if dev in devices:
- self.logger.warning("Device is already in dict: %s" % dev)
- continue
- if dev not in disk_dict:
- self.logger.warning("Device in names but not in dict: " +
- "%s" % dev)
- continue
- if dev == self.live_disk_name():
- self.logger.info("Ignoring device " +
- "%s it's the live media" % dev)
- continue
- infos = disk_dict[dev].split(",", 5)
- device = Device(dev, *infos)
- device.name = os.path.basename(device.name).replace(" ", "")
- device.name = translate_multipath_device(device.name)
- if device.name in devices:
- self.logger.debug("Device with same name already " +
- "exists: %s" % device.name)
- devices[device.path] = device
+ for dev in valid_devs:
+ if not dev in blacklisted_devs:
+ # blivet is not passing on serial from parent
+ infos = valid_devs[dev].split(",", 5)
+ self.logger.debug(infos)
+ paths = infos[1]
+ disk, parent = paths.split("|")
+ infos[1] = disk
+ self.logger.debug(paths)
+ if parent:
+ parent_info = valid_devs[dev].split(",", 5)
+ self.logger.debug("Parent Info: " + parent_info)
+ infos[4] = valid_devs[parent].split(",",5)[4]
+ self.logger.debug("Disk Info: " + infos)
+ device = Device(dev, *infos)
+ device.name = device.name.replace(" ", "")
+ devices[device.path] = device
return devices
--
To view, visit http://gerrit.ovirt.org/22398
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ad7eef4c5dace5e70ede7d5a5a8ef079d2cf9f8
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Joey Boggs <jboggs at redhat.com>
More information about the node-patches
mailing list