Merge "Refactor inventory items for multipath support"
This commit is contained in:
commit
2400ae204e
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017-2018 Wind River Systems, Inc.
|
# Copyright (c) 2017-2023 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
@ -170,15 +170,9 @@ def _get_disk_device_path(part_device_path):
|
||||||
:returns the device path of the disk on which the partition resides
|
:returns the device path of the disk on which the partition resides
|
||||||
"""
|
"""
|
||||||
disk_device_path = ""
|
disk_device_path = ""
|
||||||
if 'by-path' in part_device_path:
|
if 'by-path' in part_device_path or 'by-id' in part_device_path:
|
||||||
disk_device_path = re.match('(/dev/disk/by-path/(.+))-part([0-9]+)',
|
disk_device_path = re.match('(/dev/disk/by-(path|id)/(.+))-part([0-9]+)',
|
||||||
part_device_path).group(1)
|
part_device_path).group(1)
|
||||||
if constants.DEVICE_NAME_MPATH in part_device_path:
|
|
||||||
match_path = re.match('(/dev/disk/by-id/.+)-part([0-9]+)(-mpath.*)',
|
|
||||||
part_device_path)
|
|
||||||
if match_path:
|
|
||||||
disk_device_path = match_path.group(1) + match_path.group(3)
|
|
||||||
|
|
||||||
return disk_device_path
|
return disk_device_path
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017 Wind River Systems, Inc.
|
# Copyright (c) 2017-2023 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
@ -47,7 +47,7 @@ device_nodes=( `echo "$sfdisk_part_info" | awk '$1 == "Device" {i=1; next}; i {p
|
||||||
sector_size=$(blockdev --getss $device_path)
|
sector_size=$(blockdev --getss $device_path)
|
||||||
|
|
||||||
for device in "${device_nodes[@]}"; do
|
for device in "${device_nodes[@]}"; do
|
||||||
part_number=$(udevadm info $device | grep -oP 'E: PARTN=\K.*')
|
part_number=$(udevadm info $device | grep -oP -m1 'E: PARTN=\K.*|E: DM_PART=\K.*')
|
||||||
# Parse the output and put it in the right return format.
|
# Parse the output and put it in the right return format.
|
||||||
part_type_guid=$(sfdisk --part-type $device_path $part_number)
|
part_type_guid=$(sfdisk --part-type $device_path $part_number)
|
||||||
part_type_name=$(echo "$sfdisk_part_info" | grep -w $device | awk '{print substr($0, index($0, $6))}' | tr ' ' '.')
|
part_type_name=$(echo "$sfdisk_part_info" | grep -w $device | awk '{print substr($0, index($0, $6))}' | tr ' ' '.')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2018 Wind River Systems, Inc.
|
# Copyright (c) 2013-2023 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
@ -247,8 +247,8 @@ class DiskOperator(object):
|
||||||
device_path = "/dev/disk/by-path/" + device['ID_PATH']
|
device_path = "/dev/disk/by-path/" + device['ID_PATH']
|
||||||
LOG.debug("[DiskEnum] device_path: %s ", device_path)
|
LOG.debug("[DiskEnum] device_path: %s ", device_path)
|
||||||
elif (constants.DEVICE_NAME_MPATH in device.get("DM_NAME", "")
|
elif (constants.DEVICE_NAME_MPATH in device.get("DM_NAME", "")
|
||||||
and 'DM_UUID' in device):
|
and 'DM_WWN' in device):
|
||||||
device_path = "/dev/disk/by-id/dm-uuid-" + device['DM_UUID']
|
device_path = "/dev/disk/by-id/wwn-" + device['DM_WWN']
|
||||||
LOG.debug("[DiskEnum] device_path: %s ", device_path)
|
LOG.debug("[DiskEnum] device_path: %s ", device_path)
|
||||||
device_node = utils.get_mpath_from_dm(device.device_node)
|
device_node = utils.get_mpath_from_dm(device.device_node)
|
||||||
LOG.debug("[DiskEnum] device_node: %s ", device_node)
|
LOG.debug("[DiskEnum] device_node: %s ", device_node)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017 Wind River Systems, Inc.
|
# Copyright (c) 2017-2023 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
@ -88,9 +88,12 @@ class PartitionOperator(object):
|
||||||
for partition in sfdisk_partitions:
|
for partition in sfdisk_partitions:
|
||||||
partition_number = partition.get('part_number')
|
partition_number = partition.get('part_number')
|
||||||
size_mib = partition.get('size_mib')
|
size_mib = partition.get('size_mib')
|
||||||
if 'nvme' in device_node:
|
if constants.DEVICE_NAME_NVME in device_node:
|
||||||
part_device_node = '{}p{}'.format(device_node,
|
part_device_node = '{}p{}'.format(device_node,
|
||||||
partition_number)
|
partition_number)
|
||||||
|
elif constants.DEVICE_NAME_MPATH in device_node:
|
||||||
|
part_device_node = '{}-part{}'.format(device_node,
|
||||||
|
partition_number)
|
||||||
else:
|
else:
|
||||||
part_device_node = '{}{}'.format(device_node, partition_number)
|
part_device_node = '{}{}'.format(device_node, partition_number)
|
||||||
|
|
||||||
|
@ -137,8 +140,8 @@ class PartitionOperator(object):
|
||||||
device_path = "/dev/disk/by-path/" + device['ID_PATH']
|
device_path = "/dev/disk/by-path/" + device['ID_PATH']
|
||||||
device_node = device.device_node
|
device_node = device.device_node
|
||||||
elif (constants.DEVICE_NAME_MPATH in device.get("DM_NAME", "")
|
elif (constants.DEVICE_NAME_MPATH in device.get("DM_NAME", "")
|
||||||
and 'DM_UUID' in device):
|
and 'DM_WWN' in device):
|
||||||
device_path = "/dev/disk/by-id/dm-uuid-" + device['DM_UUID']
|
device_path = "/dev/disk/by-id/wwn-" + device['DM_WWN']
|
||||||
device_node = utils.get_mpath_from_dm(device.device_node)
|
device_node = utils.get_mpath_from_dm(device.device_node)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017-2022 Wind River Systems, Inc.
|
# Copyright (c) 2017-2023 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
@ -204,7 +204,8 @@ class PartitionController(rest.RestController):
|
||||||
# Only return user created partitions.
|
# Only return user created partitions.
|
||||||
partitions = [
|
partitions = [
|
||||||
p for p in partitions
|
p for p in partitions
|
||||||
if p.type_guid == constants.USER_PARTITION_PHYSICAL_VOLUME]
|
if (p.type_guid == constants.USER_PARTITION_PHYSICAL_VOLUME or
|
||||||
|
p.type_name == "Linux LVM")]
|
||||||
|
|
||||||
return PartitionCollection.convert_with_links(partitions, limit,
|
return PartitionCollection.convert_with_links(partitions, limit,
|
||||||
url=resource_url,
|
url=resource_url,
|
||||||
|
@ -409,6 +410,9 @@ def _build_device_node_path(partition):
|
||||||
if constants.DEVICE_NAME_NVME in idisk.device_node:
|
if constants.DEVICE_NAME_NVME in idisk.device_node:
|
||||||
device_node = "%sp%s" %\
|
device_node = "%sp%s" %\
|
||||||
(idisk.device_node, len(partitions) + 1)
|
(idisk.device_node, len(partitions) + 1)
|
||||||
|
elif constants.DEVICE_NAME_MPATH in idisk.device_node:
|
||||||
|
device_node = "%s-part%s" %\
|
||||||
|
(idisk.device_node, len(partitions) + 1)
|
||||||
else:
|
else:
|
||||||
device_node = "%s%s" % (idisk.device_node, len(partitions) + 1)
|
device_node = "%s%s" % (idisk.device_node, len(partitions) + 1)
|
||||||
device_path = cutils.get_part_device_path(idisk.device_path,
|
device_path = cutils.get_part_device_path(idisk.device_path,
|
||||||
|
@ -416,6 +420,8 @@ def _build_device_node_path(partition):
|
||||||
else:
|
else:
|
||||||
if constants.DEVICE_NAME_NVME in idisk.device_node:
|
if constants.DEVICE_NAME_NVME in idisk.device_node:
|
||||||
device_node = idisk.device_node + "p1"
|
device_node = idisk.device_node + "p1"
|
||||||
|
elif constants.DEVICE_NAME_MPATH in idisk.device_node:
|
||||||
|
device_node = idisk.device_node + "-part1"
|
||||||
else:
|
else:
|
||||||
device_node = idisk.device_node + '1'
|
device_node = idisk.device_node + '1'
|
||||||
device_path = cutils.get_part_device_path(idisk.device_path, "1")
|
device_path = cutils.get_part_device_path(idisk.device_path, "1")
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
# Copyright (c) 2013-2023 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
|
|
||||||
from eventlet.green import subprocess
|
from eventlet.green import subprocess
|
||||||
|
@ -169,6 +169,10 @@ class Storage(base.APIBase):
|
||||||
constants.DEVICE_NAME_NVME in d.device_node):
|
constants.DEVICE_NAME_NVME in d.device_node):
|
||||||
stor.journal_node = "{}p{}".format(d.device_node,
|
stor.journal_node = "{}p{}".format(d.device_node,
|
||||||
part_number)
|
part_number)
|
||||||
|
elif (d.device_node is not None and
|
||||||
|
constants.DEVICE_NAME_MPATH in d.device_node):
|
||||||
|
stor.journal_node = "{}-part{}".format(d.device_node,
|
||||||
|
part_number)
|
||||||
else:
|
else:
|
||||||
stor.journal_node = "{}{}".format(d.device_node,
|
stor.journal_node = "{}{}".format(d.device_node,
|
||||||
part_number)
|
part_number)
|
||||||
|
|
|
@ -568,8 +568,7 @@ def is_system_usable_block_device(pydev_device):
|
||||||
if pydev_device.get("DM_VG_NAME") or pydev_device.get("DM_LV_NAME"):
|
if pydev_device.get("DM_VG_NAME") or pydev_device.get("DM_LV_NAME"):
|
||||||
# Skip LVM devices
|
# Skip LVM devices
|
||||||
return False
|
return False
|
||||||
if (constants.DEVICE_NAME_MPATH in pydev_device.get("DM_NAME", "")
|
if constants.DEVICE_NAME_MPATH in pydev_device.get("DM_NAME", "") and pydev_device.get("DM_PART", ""):
|
||||||
and "part" in pydev_device.get("DM_UUID", "").split("-")[0]):
|
|
||||||
# Skip mpath partition devices
|
# Skip mpath partition devices
|
||||||
return False
|
return False
|
||||||
if pydev_device.get("ID_FS_TYPE") == constants.DEVICE_FS_TYPE_MPATH:
|
if pydev_device.get("ID_FS_TYPE") == constants.DEVICE_FS_TYPE_MPATH:
|
||||||
|
@ -3713,13 +3712,15 @@ def get_mpath_from_dm(dm_device):
|
||||||
|
|
||||||
context = pyudev.Context()
|
context = pyudev.Context()
|
||||||
|
|
||||||
pydev_device = pyudev.Device.from_device_file(context, dm_device)
|
pydev_device = pyudev.Devices.from_device_file(context, dm_device)
|
||||||
|
|
||||||
if constants.DEVICE_NAME_MPATH in pydev_device.get("DM_NAME", ""):
|
device_mapper_name = pydev_device.get("DM_NAME", "")
|
||||||
re_line = re.compile(r'^(\D*)')
|
if constants.DEVICE_NAME_MPATH in device_mapper_name:
|
||||||
match = re_line.search(pydev_device.get("DM_NAME"))
|
device_mapper_mpath = pydev_device.get("DM_MPATH", None)
|
||||||
if match:
|
if device_mapper_mpath:
|
||||||
mpath_device = os.path.join("/dev/mapper", match.group(1))
|
mpath_device = os.path.join("/dev/mapper", device_mapper_mpath)
|
||||||
|
else:
|
||||||
|
mpath_device = os.path.join("/dev/mapper", device_mapper_name)
|
||||||
|
|
||||||
return mpath_device
|
return mpath_device
|
||||||
|
|
||||||
|
@ -3731,15 +3732,7 @@ def get_part_device_path(disk_device_path, part_number):
|
||||||
:param part_number: the partition number
|
:param part_number: the partition number
|
||||||
:returns the partition device path
|
:returns the partition device path
|
||||||
"""
|
"""
|
||||||
if constants.DEVICE_NAME_MPATH in disk_device_path:
|
part_device_path = '{}-part{}'.format(disk_device_path, part_number)
|
||||||
path_split = disk_device_path.split(constants.DEVICE_NAME_MPATH)
|
|
||||||
part_device_path = '{}part{}-{}{}'.format(path_split[0],
|
|
||||||
part_number,
|
|
||||||
constants.DEVICE_NAME_MPATH,
|
|
||||||
path_split[1])
|
|
||||||
else:
|
|
||||||
part_device_path = '{}-part{}'.format(disk_device_path, part_number)
|
|
||||||
|
|
||||||
return part_device_path
|
return part_device_path
|
||||||
|
|
||||||
|
|
||||||
|
@ -3749,15 +3742,8 @@ def get_part_number(part_device_path):
|
||||||
:returns the partition's number
|
:returns the partition's number
|
||||||
"""
|
"""
|
||||||
part_num = ""
|
part_num = ""
|
||||||
if 'by-path' in part_device_path:
|
if 'by-path' in part_device_path or 'by-id' in part_device_path:
|
||||||
part_num = re.match('.*?([0-9]+)$', part_device_path).group(1)
|
part_num = re.match('.*?([0-9]+)$', part_device_path).group(1)
|
||||||
|
|
||||||
if constants.DEVICE_NAME_MPATH in part_device_path:
|
|
||||||
match_path = re.match('(/dev/disk/by-id/.+)-part([0-9]+)(-mpath.*)',
|
|
||||||
part_device_path)
|
|
||||||
if match_path:
|
|
||||||
part_num = match_path.group(2)
|
|
||||||
|
|
||||||
return part_num
|
return part_num
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue