* Get disk lun info on FreeBSD

* Changed the regex filter to accept more situations. In Testing

* Removed the CD part of the filter
This commit is contained in:
r-dailey 2024-11-13 20:09:28 -08:00 коммит произвёл GitHub
Родитель 4ec8c8dfe5
Коммит a8affe467d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 37 добавлений и 9 удалений

Просмотреть файл

@ -1638,6 +1638,20 @@ class Disk(AzureFeatureMixin, features.Disk):
# /dev/nvme0n1p15 -> /dev/nvme0
NVME_CONTROLLER_PATTERN = re.compile(r"/dev/nvme[0-9]+", re.M)
# <Msft Virtual Disk 1.0> at scbus0 target 0 lun 0 (pass0,da0)
# <Msft Virtual Disk 1.0> at scbus0 target 0 lun 1 (pass1,da1)
# <Msft Virtual DVD-ROM 1.0> at scbus0 target 0 lun 2 (pass2,cd0)
# <Msft Virtual Disk 1.0> at scbus1 target 0 lun 0 (da6,pass7)
# <Msft Virtual Disk 1.0> at scbus1 target 0 lun 1 (da9,pass10)
# <Msft Virtual Disk 1.0> at scbus1 target 0 lun 2 (da7,pass8)
# <Msft Virtual Disk 1.0> at scbus1 target 0 lun 3 (da8,pass9)
# <Msft Virtual Disk 1.0> at scbus1 target 0 lun 4 (da5,pass6)
# <Msft Virtual Disk 1.0> at scbus1 target 0 lun 6 (da4,pass5)
# <Msft Virtual Disk 1.0> at scbus1 target 0 lun 7 (da3,pass4)
LUN_PATTERN_BSD = re.compile(
r"at\s+scbus\d+\s+target\s+\d+\s+lun\s+(\d+)\s+\(.*(da\d+)", re.M
)
@classmethod
def settings_type(cls) -> Type[schema.FeatureSettings]:
return AzureDiskOptionSettings
@ -1707,6 +1721,20 @@ class Disk(AzureFeatureMixin, features.Disk):
def get_luns(self) -> Dict[str, int]:
# disk_controller_type == SCSI
# get azure scsi attached disks
device_luns = {}
if isinstance(self._node.os, BSD):
cmd_result = self._node.execute(
"camcontrol devlist",
shell=True,
sudo=True,
)
for line in cmd_result.stdout.splitlines():
match = self.LUN_PATTERN_BSD.search(line)
if match:
lun_number = int(match.group(1))
device_name = match.group(2)
device_luns.update({device_name: lun_number})
else:
azure_scsi_disks = self._get_scsi_data_disks()
device_luns = {}
lun_number_pattern = re.compile(r"[0-9]+$", re.M)