Use labels for virtual media dev in Ironic ramdisk
This commit changes Ironic deploy ramdisk to find out the virtual media device by using labels instead of looking at the model of block device. This helps in finding out the device irrespective of the hardware. Corresponding Ironic change is If5b78d9af7048f2631d050ee5ce01ab7a67e2354. Closes-Bug: #1429340 Change-Id: I5e8a706989bad13051eb47db0b1e762e6c672318
This commit is contained in:
parent
226eaa3e3f
commit
1540e753dc
@ -17,27 +17,39 @@ function configure_vmedia_dir() {
|
||||
VMEDIA_MOUNT_POINT="/vfloppy_mnt"
|
||||
VMEDIA_DIR="/vfloppy"
|
||||
VMEDIA_CONFIG_FILE="parameters.txt"
|
||||
|
||||
SYSFS_DEVICE_MODELS="/sys/class/block/*/device/model"
|
||||
SYSFS_VMEDIA_DEVICE_MODEL="virtual media"
|
||||
VMEDIA_DEVICE_BY_LABEL="/dev/disk/by-label/ir-vfd-dev"
|
||||
|
||||
# Wait for some seconds for kernel to finish initializing the
|
||||
# virtual media devices.
|
||||
wait_for 5 1 "grep -q -i \"$SYSFS_VMEDIA_DEVICE_MODEL\" $SYSFS_DEVICE_MODELS"
|
||||
wait_for 5 1 "ls $VMEDIA_DEVICE_BY_LABEL"
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Error finding the virtual floppy device on the node."
|
||||
troubleshoot
|
||||
fi
|
||||
|
||||
# Find the virtual media device from the kernel sysfs file system.
|
||||
VMEDIA_DEVICE=$(grep -l -i "$SYSFS_VMEDIA_DEVICE_MODEL" $SYSFS_DEVICE_MODELS | awk -F'/' '{print $5}')
|
||||
if [[ -z $VMEDIA_DEVICE ]]; then
|
||||
echo "Error finding the virtual floppy device on the node."
|
||||
troubleshoot
|
||||
# TODO(rameshg87): This block of code is there only for backward
|
||||
# compatibility to older versions of Ironic. Remove this after 2
|
||||
# releases. Ironic will now assign labels to Virtual Media devices.
|
||||
SYSFS_DEVICE_MODELS="/sys/class/block/*/device/model"
|
||||
SYSFS_VMEDIA_DEVICE_MODEL="virtual media"
|
||||
|
||||
# Wait for some seconds for kernel to finish initializing the
|
||||
# virtual media devices.
|
||||
wait_for 5 1 "grep -q -i \"$SYSFS_VMEDIA_DEVICE_MODEL\" $SYSFS_DEVICE_MODELS"
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Error finding the virtual floppy device on the node."
|
||||
troubleshoot
|
||||
fi
|
||||
|
||||
# Find the virtual media device from the kernel sysfs file system.
|
||||
VMEDIA_DEVICE=$(grep -l -i "$SYSFS_VMEDIA_DEVICE_MODEL" $SYSFS_DEVICE_MODELS | awk -F'/' '{print $5}')
|
||||
if [[ -z $VMEDIA_DEVICE ]]; then
|
||||
echo "Error finding the virtual floppy device on the node."
|
||||
troubleshoot
|
||||
fi
|
||||
VMEDIA_DEVICE_FILE="/dev/$VMEDIA_DEVICE"
|
||||
else
|
||||
VMEDIA_DEVICE_FILE="$VMEDIA_DEVICE_BY_LABEL"
|
||||
fi
|
||||
|
||||
# Mount the virtual media device
|
||||
VMEDIA_DEVICE_FILE="/dev/$VMEDIA_DEVICE"
|
||||
mkdir -p $VMEDIA_MOUNT_POINT
|
||||
mount $VMEDIA_DEVICE_FILE $VMEDIA_MOUNT_POINT
|
||||
if [[ $? != 0 ]]; then
|
||||
|
89
elements/ramdisk-base/udev.d/60-persistent-storage.rules
Normal file
89
elements/ramdisk-base/udev.d/60-persistent-storage.rules
Normal file
@ -0,0 +1,89 @@
|
||||
# do not edit this file, it will be overwritten on update
|
||||
|
||||
# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path}
|
||||
# scheme based on "Linux persistent device names", 2004, Hannes Reinecke <hare@suse.de>
|
||||
|
||||
# forward scsi device event to corresponding block device
|
||||
ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST=="block", ATTR{block/*/uevent}="change"
|
||||
|
||||
ACTION=="remove", GOTO="persistent_storage_end"
|
||||
|
||||
# enable in-kernel media-presence polling
|
||||
ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", ATTR{parameters/events_dfl_poll_msecs}=="0", ATTR{parameters/events_dfl_poll_msecs}="2000"
|
||||
ACTION=="add", ATTR{removable}=="1", ATTR{events_poll_msecs}=="-1", ATTR{events_poll_msecs}="2000"
|
||||
|
||||
SUBSYSTEM!="block", GOTO="persistent_storage_end"
|
||||
|
||||
# skip rules for inappropriate block devices
|
||||
KERNEL=="fd*|mtd*|nbd*|gnbd*|btibm*|dm-*|md*", GOTO="persistent_storage_end"
|
||||
|
||||
# ignore partitions that span the entire disk
|
||||
TEST=="whole_disk", GOTO="persistent_storage_end"
|
||||
|
||||
# for partitions import parent information
|
||||
ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"
|
||||
|
||||
# virtio-blk
|
||||
KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}"
|
||||
KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n"
|
||||
|
||||
# ATA devices using the "scsi" subsystem
|
||||
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode"
|
||||
# ATA/ATAPI devices (SPC-3 or later) using the "scsi" subsystem
|
||||
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode"
|
||||
|
||||
# Run ata_id on non-removable USB Mass Storage (SATA/PATA disks in enclosures)
|
||||
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $devnode"
|
||||
# Otherwise fall back to using usb_id for USB devices
|
||||
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"
|
||||
|
||||
# scsi devices
|
||||
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="scsi"
|
||||
KERNEL=="cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="cciss"
|
||||
KERNEL=="sd*|sr*|cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
|
||||
KERNEL=="sd*|cciss*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"
|
||||
|
||||
# firewire
|
||||
KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}"
|
||||
KERNEL=="sd*[0-9]", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}-part%n"
|
||||
|
||||
KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
|
||||
KERNEL=="mmcblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n"
|
||||
KERNEL=="mmcblk[0-9]p[0-9]", ENV{PARTNAME}=="?*", SYMLINK+="disk/by-partlabel/$env{PARTNAME}"
|
||||
KERNEL=="mspblk[0-9]", SUBSYSTEMS=="memstick", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}"
|
||||
KERNEL=="mspblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}-part%n"
|
||||
|
||||
# by-path (parent device path)
|
||||
ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id"
|
||||
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
|
||||
ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
|
||||
|
||||
# skip unpartitioned removable media devices from drivers which do not send "change" events
|
||||
ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end"
|
||||
|
||||
# probe filesystem metadata of optical drives which have a media inserted
|
||||
KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \
|
||||
IMPORT{builtin}="blkid --offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}"
|
||||
# single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET
|
||||
KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", \
|
||||
IMPORT{builtin}="blkid --noraid"
|
||||
|
||||
# probe filesystem metadata of disks
|
||||
KERNEL!="sr*", IMPORT{builtin}="blkid"
|
||||
|
||||
# watch metadata changes by tools closing the device after writing
|
||||
KERNEL!="sr*", OPTIONS+="watch"
|
||||
|
||||
# by-label/by-uuid links (filesystem metadata)
|
||||
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
|
||||
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
|
||||
|
||||
# by-id (World Wide Name)
|
||||
ENV{DEVTYPE}=="disk", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}"
|
||||
ENV{DEVTYPE}=="partition", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}-part%n"
|
||||
|
||||
# by-partlabel/by-partuuid links (partition metadata)
|
||||
ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}"
|
||||
ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
|
||||
|
||||
LABEL="persistent_storage_end"
|
Loading…
Reference in New Issue
Block a user