sysinv-agent: Do not report partitions from the iSCSI local devices
to conductor Although disks are not reported anymore we are still reporting partitions which can cause lots of logging in sysinv. Change-Id: I86c2d45f86b317666e1cb9d7fe2fc5716f9ffbc0
This commit is contained in:
parent
19a756882b
commit
177209d994
|
@ -40,8 +40,6 @@ from sysinv.openstack.common import context
|
|||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
VENDOR_ID_LIO = 'LIO-ORG'
|
||||
|
||||
|
||||
class DiskOperator(object):
|
||||
'''Class to encapsulate Disk operations for System Inventory'''
|
||||
|
@ -128,7 +126,7 @@ class DiskOperator(object):
|
|||
# Check that partition table format is GPT.
|
||||
# Return 0 if not.
|
||||
if not utils.disk_is_gpt(device_node=device_node):
|
||||
LOG.warn("Format of disk node %s is not GPT." % device_node)
|
||||
LOG.debug("Format of disk node %s is not GPT." % device_node)
|
||||
return 0
|
||||
|
||||
pvs_command = '{} {}'.format('pvs | grep -w ', device_node)
|
||||
|
@ -268,53 +266,11 @@ class DiskOperator(object):
|
|||
idisk = []
|
||||
context = pyudev.Context()
|
||||
|
||||
# Valid major numbers for disks:
|
||||
# https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
|
||||
#
|
||||
# 3 block First MFM, RLL and IDE hard disk/CD-ROM interface
|
||||
# 8 block SCSI disk devices (0-15)
|
||||
# 65 block SCSI disk devices (16-31)
|
||||
# 66 block SCSI disk devices (32-47)
|
||||
# 67 block SCSI disk devices (48-63)
|
||||
# 68 block SCSI disk devices (64-79)
|
||||
# 69 block SCSI disk devices (80-95)
|
||||
# 70 block SCSI disk devices (96-111)
|
||||
# 71 block SCSI disk devices (112-127)
|
||||
# 128 block SCSI disk devices (128-143)
|
||||
# 129 block SCSI disk devices (144-159)
|
||||
# 130 block SCSI disk devices (160-175)
|
||||
# 131 block SCSI disk devices (176-191)
|
||||
# 132 block SCSI disk devices (192-207)
|
||||
# 133 block SCSI disk devices (208-223)
|
||||
# 134 block SCSI disk devices (224-239)
|
||||
# 135 block SCSI disk devices (240-255)
|
||||
# 240-254 block LOCAL/EXPERIMENTAL USE (253 == /dev/vdX)
|
||||
# 259 block Block Extended Major (NVMe - /dev/nvmeXn1)
|
||||
valid_major_list = ['3','8', '65', '66', '67', '68', '69', '70', '71',
|
||||
'128', '129', '130', '131', '132', '133', '134',
|
||||
'135', '253', '259']
|
||||
|
||||
for device in context.list_devices(DEVTYPE='disk'):
|
||||
if device.get("ID_BUS") == "usb":
|
||||
# Skip USB devices
|
||||
if not utils.is_system_usable_block_device(device):
|
||||
continue
|
||||
if device.get("DM_VG_NAME") or device.get("DM_LV_NAME"):
|
||||
# Skip LVM devices
|
||||
continue
|
||||
id_path = device.get("ID_PATH", "")
|
||||
if "iqn." in id_path or "eui." in id_path:
|
||||
# Skip all iSCSI devices, they are links for volume storage.
|
||||
# As per https://www.ietf.org/rfc/rfc3721.txt, "iqn." or "edu."
|
||||
# have to be present when constructing iSCSI names.
|
||||
continue
|
||||
if device.get("ID_VENDOR") == VENDOR_ID_LIO:
|
||||
# LIO devices are iSCSI, should be skipped above!
|
||||
LOG.error("Invalid id_path. Device %s (%s) is iSCSI!" %
|
||||
(id_path, device.get('DEVNAME')))
|
||||
continue
|
||||
major = device['MAJOR']
|
||||
if major in valid_major_list:
|
||||
|
||||
if device['MAJOR'] in constants.VALID_MAJOR_LIST:
|
||||
if 'ID_PATH' in device:
|
||||
device_path = "/dev/disk/by-path/" + device['ID_PATH']
|
||||
LOG.debug("[DiskEnum] device_path: %s ", device_path)
|
||||
|
|
|
@ -18,6 +18,7 @@ import pyudev
|
|||
import subprocess
|
||||
import sys
|
||||
from sysinv.common import utils as utils
|
||||
from sysinv.common import constants
|
||||
from sysinv.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -76,7 +77,7 @@ class PartitionOperator(object):
|
|||
:returns: list of partitions"""
|
||||
# Check that partition table format is GPT. Return 0 if not.
|
||||
if not utils.disk_is_gpt(device_node=device_node):
|
||||
LOG.warn("Format of disk node %s is not GPT." % device_node)
|
||||
LOG.debug("Format of disk node %s is not GPT." % device_node)
|
||||
return None
|
||||
|
||||
try:
|
||||
|
@ -151,19 +152,10 @@ class PartitionOperator(object):
|
|||
# Get all disk devices.
|
||||
context = pyudev.Context()
|
||||
for device in context.list_devices(DEVTYPE='disk'):
|
||||
if device.get("ID_BUS") == "usb":
|
||||
# Skip USB devices
|
||||
if not utils.is_system_usable_block_device(device):
|
||||
continue
|
||||
if device.get("ID_VENDOR") == VENDOR_ID_LIO:
|
||||
# Skip iSCSI devices, they are links for volume storage
|
||||
continue
|
||||
if device.get("DM_VG_NAME") or device.get("DM_LV_NAME"):
|
||||
# Skip LVM devices
|
||||
continue
|
||||
major = device['MAJOR']
|
||||
|
||||
if (major == '8' or major == '3' or major == '253' or
|
||||
major == '259'):
|
||||
if device['MAJOR'] in constants.VALID_MAJOR_LIST:
|
||||
device_path = "/dev/disk/by-path/" + device['ID_PATH']
|
||||
device_node = device.device_node
|
||||
|
||||
|
|
|
@ -272,6 +272,33 @@ REGION_ONE_NAME = 'RegionOne'
|
|||
# DC Region Must match VIRTUAL_MASTER_CLOUD in dcorch
|
||||
SYSTEM_CONTROLLER_REGION = 'SystemController'
|
||||
|
||||
# Valid major numbers for disks:
|
||||
# https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
|
||||
#
|
||||
# 3 block First MFM, RLL and IDE hard disk/CD-ROM interface
|
||||
# 8 block SCSI disk devices (0-15)
|
||||
# 65 block SCSI disk devices (16-31)
|
||||
# 66 block SCSI disk devices (32-47)
|
||||
# 67 block SCSI disk devices (48-63)
|
||||
# 68 block SCSI disk devices (64-79)
|
||||
# 69 block SCSI disk devices (80-95)
|
||||
# 70 block SCSI disk devices (96-111)
|
||||
# 71 block SCSI disk devices (112-127)
|
||||
# 128 block SCSI disk devices (128-143)
|
||||
# 129 block SCSI disk devices (144-159)
|
||||
# 130 block SCSI disk devices (160-175)
|
||||
# 131 block SCSI disk devices (176-191)
|
||||
# 132 block SCSI disk devices (192-207)
|
||||
# 133 block SCSI disk devices (208-223)
|
||||
# 134 block SCSI disk devices (224-239)
|
||||
# 135 block SCSI disk devices (240-255)
|
||||
# 240-254 block LOCAL/EXPERIMENTAL USE (253 == /dev/vdX)
|
||||
# 259 block Block Extended Major (NVMe - /dev/nvmeXn1)
|
||||
VALID_MAJOR_LIST = ['3', '8', '65', '66', '67', '68', '69', '70', '71',
|
||||
'128', '129', '130', '131', '132', '133', '134',
|
||||
'135', '253', '259']
|
||||
VENDOR_ID_LIO = 'LIO-ORG'
|
||||
|
||||
# Storage backends supported
|
||||
SB_TYPE_FILE = 'file'
|
||||
SB_TYPE_LVM = 'lvm'
|
||||
|
|
|
@ -482,6 +482,35 @@ def is_valid_pci_class_id(id):
|
|||
return True
|
||||
|
||||
|
||||
def is_system_usable_block_device(pydev_device):
|
||||
""" Check if a block device is local and can be used for partitioning
|
||||
|
||||
Example devices:
|
||||
o local block devices: local HDDs, SSDs, RAID arrays
|
||||
o remote devices: iscsi mounted, LIO, EMC
|
||||
o non permanent devices: USB stick
|
||||
:return bool: True if device can be used else False
|
||||
"""
|
||||
if pydev_device.get("ID_BUS") == "usb":
|
||||
# Skip USB devices
|
||||
return False
|
||||
if pydev_device.get("DM_VG_NAME") or pydev_device.get("DM_LV_NAME"):
|
||||
# Skip LVM devices
|
||||
return False
|
||||
id_path = pydev_device.get("ID_PATH", "")
|
||||
if "iqn." in id_path or "eui." in id_path:
|
||||
# Skip all iSCSI devices, they are links for volume storage.
|
||||
# As per https://www.ietf.org/rfc/rfc3721.txt, "iqn." or "edu."
|
||||
# have to be present when constructing iSCSI names.
|
||||
return False
|
||||
if pydev_device.get("ID_VENDOR") == constants.VENDOR_ID_LIO:
|
||||
# LIO devices are iSCSI, should be skipped above!
|
||||
LOG.error("Invalid id_path. Device %s (%s) is iSCSI!" %
|
||||
(id_path, pydev_device.get('DEVNAME')))
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def get_ip_version(network):
|
||||
"""Returns the IP version of a network (IPv4 or IPv6).
|
||||
|
||||
|
|
|
@ -3444,16 +3444,24 @@ class ConductorManager(service.PeriodicService):
|
|||
# Check that the DB partitions are in sync with the DB disks and PVs.
|
||||
for db_part in db_parts:
|
||||
if not db_part.device_path:
|
||||
LOG.warning("Disk partition %s is missing its device path." %
|
||||
db_part.uuid)
|
||||
# Should not happen unless pyudev gives us wrong data
|
||||
# or we have a programming error.
|
||||
LOG.error("PART ipartition_update_by_ihost: "
|
||||
"Disk partition %s is missing its "
|
||||
"device path, ignoring!" % db_part.uuid)
|
||||
continue
|
||||
|
||||
# Obtain the disk the partition is on.
|
||||
part_disk = next((d for d in db_disks
|
||||
if d.device_path in db_part.device_path), None)
|
||||
|
||||
if not part_disk:
|
||||
LOG.debug("PART conductor - partition disk is not "
|
||||
"present.")
|
||||
# Should not happen as we only store partitions associated
|
||||
# with a disk.
|
||||
LOG.error("PART ipartition_update_by_ihost: "
|
||||
"Disk for partition %s is not "
|
||||
"present in database, ignoring!" % db_part.uuid)
|
||||
continue
|
||||
|
||||
partition_dict = {'forihostid': forihostid}
|
||||
partition_update_needed = False
|
||||
|
@ -3519,20 +3527,29 @@ class ConductorManager(service.PeriodicService):
|
|||
LOG.debug("PART conductor - disk - part_dict: %s " %
|
||||
str(part_dict))
|
||||
|
||||
new_part = None
|
||||
try:
|
||||
new_part = self.dbapi.partition_create(
|
||||
forihostid, part_dict)
|
||||
except:
|
||||
LOG.exception("Partition creation failed.")
|
||||
new_part = None
|
||||
try:
|
||||
LOG.info("Partition create on host: %s. Details: %s" % (forihostid, part_dict))
|
||||
new_part = self.dbapi.partition_create(
|
||||
forihostid, part_dict)
|
||||
except Exception as e:
|
||||
LOG.exception("Partition creation failed on host: %s. "
|
||||
"Details: %s" % (forihostid, str(e)))
|
||||
|
||||
# If the partition has been successfully created, update its status.
|
||||
if new_part:
|
||||
if new_part.type_guid != constants.USER_PARTITION_PHYSICAL_VOLUME:
|
||||
partition_status = {'status': constants.PARTITION_IN_USE_STATUS}
|
||||
else:
|
||||
partition_status = {'status': constants.PARTITION_READY_STATUS}
|
||||
self.dbapi.partition_update(new_part.uuid, partition_status)
|
||||
# If the partition has been successfully created, update its status.
|
||||
if new_part:
|
||||
if new_part.type_guid != constants.USER_PARTITION_PHYSICAL_VOLUME:
|
||||
status = {'status': constants.PARTITION_IN_USE_STATUS}
|
||||
else:
|
||||
status = {'status': constants.PARTITION_READY_STATUS}
|
||||
self.dbapi.partition_update(new_part.uuid, status)
|
||||
break
|
||||
else:
|
||||
# This shouldn't happen as disks are reported before partitions
|
||||
LOG.warning("Found partition not associated with any disks, "
|
||||
"underlying disk should be created on next inventory "
|
||||
"reporting, ignoring for now. Details: ihost_uuid: %s "
|
||||
"ipart_dict_array: %s" % (ihost_uuid, part_dict))
|
||||
|
||||
# Check to see if partitions have been removed.
|
||||
for db_part in db_parts:
|
||||
|
|
|
@ -28,7 +28,7 @@ class Partition(base.SysinvObject):
|
|||
'device_node': utils.str_or_none,
|
||||
'type_guid': utils.str_or_none,
|
||||
'type_name': utils.str_or_none,
|
||||
'idisk_id': int,
|
||||
'idisk_id': utils.int_or_none,
|
||||
'foripvid': utils.int_or_none,
|
||||
'forihostid': utils.int_or_none,
|
||||
'status': int,
|
||||
|
|
Loading…
Reference in New Issue