deal with nvme

This commit is contained in:
beast 2023-03-31 18:12:22 +08:00
parent 00b28377f6
commit 185e6fedca

View File

@ -225,12 +225,15 @@ def get_all_lvmdrives(disk_layouts: Dict[str,Any] = None) -> List[Dict[str,Any]]
# 分区有 # 分区有
for index,partition in enumerate(partitions): for index,partition in enumerate(partitions):
if (device := partition.get('device',None)) is not None and device.get('as_lvm',False): if (device := partition.get('device',None)) is not None and device.get('as_lvm',False):
disk_partition_name = disk + str(index + 1)
if disk.lower().find("nvme".lower()) >= 0:
disk_partition_name = disk + "p" + str(index + 1)
if lvm_drives_obj.get(device['vg_name'],None) is not None: if lvm_drives_obj.get(device['vg_name'],None) is not None:
lvm_drives_obj[device['vg_name']].vg_size += device['vg_size'] lvm_drives_obj[device['vg_name']].vg_size += device['vg_size']
lvm_drives_obj[device['vg_name']].pvs.append(disk + str(index + 1)) lvm_drives_obj[device['vg_name']].pvs.append(disk_partition_name)
lvm_drives_obj[device['vg_name']].partitions.extend(device.get('partitions',[])) lvm_drives_obj[device['vg_name']].partitions.extend(device.get('partitions',[]))
else: else:
lvm_drives_obj[device['vg_name']] = VgPartition(device['vg_name'],device['vg_size'],[disk + str(index + 1)],device.get('partitions',[])) lvm_drives_obj[device['vg_name']] = VgPartition(device['vg_name'],device['vg_size'],[disk_partition_name],device.get('partitions',[]))
# if (device := partition.get('device',None)) is not None and len(lvs := device.get('partitions',[])) > 0: # if (device := partition.get('device',None)) is not None and len(lvs := device.get('partitions',[])) > 0:
# print("lvm_drives_obj=====>>>>>>",lvm_drives_obj) # print("lvm_drives_obj=====>>>>>>",lvm_drives_obj)
# lvm_drives_obj[device['vg_name']].partitions.extend(lvs) # lvm_drives_obj[device['vg_name']].partitions.extend(lvs)