summaryrefslogtreecommitdiffstats
path: root/src/ceph-volume/ceph_volume
diff options
context:
space:
mode:
Diffstat (limited to 'src/ceph-volume/ceph_volume')
-rw-r--r--src/ceph-volume/ceph_volume/devices/lvm/zap.py3
-rw-r--r--src/ceph-volume/ceph_volume/main.py10
-rw-r--r--src/ceph-volume/ceph_volume/tests/devices/lvm/data_zap.py2
-rw-r--r--src/ceph-volume/ceph_volume/util/disk.py19
-rw-r--r--src/ceph-volume/ceph_volume/util/prepare.py3
5 files changed, 27 insertions, 10 deletions
diff --git a/src/ceph-volume/ceph_volume/devices/lvm/zap.py b/src/ceph-volume/ceph_volume/devices/lvm/zap.py
index c278de43eb0..a6d82c7f0fa 100644
--- a/src/ceph-volume/ceph_volume/devices/lvm/zap.py
+++ b/src/ceph-volume/ceph_volume/devices/lvm/zap.py
@@ -119,13 +119,12 @@ class Zap:
osd_uuid = details.get('osd_uuid')
break
- for osd_uuid, details in raw_report.items():
+ for _, details in raw_report.items():
device: str = details.get('device')
if details.get('osd_uuid') == osd_uuid:
raw_devices.add(device)
return list(raw_devices)
-
def find_associated_devices(self) -> List[api.Volume]:
"""From an ``osd_id`` and/or an ``osd_fsid``, filter out all the Logical Volumes (LVs) in the
diff --git a/src/ceph-volume/ceph_volume/main.py b/src/ceph-volume/ceph_volume/main.py
index f8eca65ec49..4f27f429e89 100644
--- a/src/ceph-volume/ceph_volume/main.py
+++ b/src/ceph-volume/ceph_volume/main.py
@@ -11,8 +11,16 @@ try:
from importlib.metadata import entry_points
def get_entry_points(group: str): # type: ignore
- return entry_points().get(group, []) # type: ignore
+ eps = entry_points()
+ if hasattr(eps, 'select'):
+ # New importlib.metadata uses .select()
+ return eps.select(group=group)
+ else:
+ # Fallback to older EntryPoints that returns dicts
+ return eps.get(group, []) # type: ignore
+
except ImportError:
+ # Fallback to `pkg_resources` for older versions
from pkg_resources import iter_entry_points as entry_points # type: ignore
def get_entry_points(group: str): # type: ignore
diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/data_zap.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/data_zap.py
index cca64e83ab0..c971b7776ef 100644
--- a/src/ceph-volume/ceph_volume/tests/devices/lvm/data_zap.py
+++ b/src/ceph-volume/ceph_volume/tests/devices/lvm/data_zap.py
@@ -22,7 +22,7 @@ ceph_bluestore_tool_output = '''
"whoami": "0"
},
"/dev/vdx": {
- "osd_uuid": "d5a496bc-dcb9-4ad0-a12c-393d3200d2b6",
+ "osd_uuid": "d5a496bc-dcb9-4ad0-a12c-393d3200d2b7",
"size": 214748364800,
"btime": "2024-10-16T10:51:05.955279+0000",
"description": "main",
diff --git a/src/ceph-volume/ceph_volume/util/disk.py b/src/ceph-volume/ceph_volume/util/disk.py
index 77b55314f66..921e61a4534 100644
--- a/src/ceph-volume/ceph_volume/util/disk.py
+++ b/src/ceph-volume/ceph_volume/util/disk.py
@@ -347,12 +347,21 @@ def lsblk_all(device: str = '',
return result
-def is_device(dev):
+def is_device(dev: str) -> bool:
"""
- Boolean to determine if a given device is a block device (**not**
- a partition!)
+ Determines whether the given path corresponds to a block device (not a partition).
- For example: /dev/sda would return True, but not /dev/sdc1
+ This function checks whether the provided device path represents a valid block device,
+ such as a physical disk (/dev/sda) or an allowed loop device, but excludes partitions
+ (/dev/sdc1). It performs several validation steps, including file existence, path format,
+ device type, and additional checks for loop devices if allowed.
+
+ Args:
+ dev (str): The path to the device (e.g., "/dev/sda").
+
+ Returns:
+ bool: True if the path corresponds to a valid block device (not a partition),
+ otherwise False.
"""
if not os.path.exists(dev):
return False
@@ -364,7 +373,7 @@ def is_device(dev):
TYPE = lsblk(dev).get('TYPE')
if TYPE:
- return TYPE in ['disk', 'mpath']
+ return TYPE in ['disk', 'mpath', 'loop']
# fallback to stat
return _stat_is_device(os.lstat(dev).st_mode) and not is_partition(dev)
diff --git a/src/ceph-volume/ceph_volume/util/prepare.py b/src/ceph-volume/ceph_volume/util/prepare.py
index 9c863b83d93..ff7fc023fc4 100644
--- a/src/ceph-volume/ceph_volume/util/prepare.py
+++ b/src/ceph-volume/ceph_volume/util/prepare.py
@@ -9,6 +9,7 @@ import logging
import json
from ceph_volume import process, conf, terminal
from ceph_volume.util import system, constants, str_to_int, disk
+from typing import Optional
logger = logging.getLogger(__name__)
mlogger = terminal.MultiLogger(__name__)
@@ -121,7 +122,7 @@ def get_block_wal_size(lv_format=True):
return wal_size
-def create_id(fsid, json_secrets, osd_id=None):
+def create_id(fsid: str, json_secrets: str, osd_id: Optional[str]=None) -> str:
"""
:param fsid: The osd fsid to create, always required
:param json_secrets: a json-ready object with whatever secrets are wanted