Skip to content

Commit 6365754

Browse files
authored
Merge pull request ceph#60031 from guits/cv-quick-fix
ceph-volume: docstring and typing corrections
2 parents 2d93ad5 + b4c62fe commit 6365754

File tree

1 file changed

+16
-7
lines changed
  • src/ceph-volume/ceph_volume/util

1 file changed

+16
-7
lines changed

src/ceph-volume/ceph_volume/util/disk.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,20 @@ def holder_inner_loop() -> bool:
771771
result.append([name, kname, "part", partitions[partition]])
772772
return sorted(result, key=lambda x: x[0])
773773

774-
def get_partitions(_sys_dev_block_path ='/sys/dev/block') -> List[str]:
774+
def get_partitions(_sys_dev_block_path: str ='/sys/dev/block') -> Dict[str, str]:
775+
"""
776+
Retrieves a dictionary mapping partition system names to their parent device names.
777+
778+
Args:
779+
_sys_dev_block_path (str, optional): The path to the system's block device directory.
780+
Defaults to '/sys/dev/block'.
781+
782+
Returns:
783+
Dict[str, str]: A dictionary where the keys are partition system names, and the values are
784+
the corresponding parent device names.
785+
"""
775786
devices: List[str] = os.listdir(_sys_dev_block_path)
776-
result: Dict[str, str] = dict()
787+
result: Dict[str, str] = {}
777788
for device in devices:
778789
device_path: str = os.path.join(_sys_dev_block_path, device)
779790
is_partition: bool = int(get_file_contents(os.path.join(device_path, 'partition'), '0')) > 0
@@ -1120,10 +1131,8 @@ def get_parent_device_from_mapper(mapper: str, abspath: bool = True) -> str:
11201131
pass
11211132
return result
11221133

1123-
11241134
def get_lvm_mapper_path_from_dm(path: str, sys_block: str = '/sys/block') -> str:
1125-
"""_summary_
1126-
Retrieve the logical volume path for a given device.
1135+
"""Retrieve the logical volume path for a given device.
11271136
11281137
This function takes the path of a device and returns the corresponding
11291138
logical volume path by reading the 'dm/name' file within the sysfs
@@ -1134,7 +1143,7 @@ def get_lvm_mapper_path_from_dm(path: str, sys_block: str = '/sys/block') -> str
11341143
sys_block (str, optional): The base sysfs block directory. Defaults to '/sys/block'.
11351144
11361145
Returns:
1137-
str: The device mapper path in the form of '/dev/dm-X'.
1146+
str: The device mapper path in the 'dashed form' of '/dev/mapper/vg-lv'.
11381147
"""
11391148
result: str = ''
11401149
dev: str = os.path.basename(path)
@@ -1252,4 +1261,4 @@ def active_mappers(self) -> Dict[str, Any]:
12521261
result[holder]['dmcrypt_mapping'] = content_split[3]
12531262
if mapper_type == 'LVM':
12541263
result[holder]['uuid'] = content_split[1]
1255-
return result
1264+
return result

0 commit comments

Comments
 (0)