From c54674942388dc85f1fc0c4bce1cd4e09929b618 Mon Sep 17 00:00:00 2001 From: Raphael Glon Date: Fri, 9 Aug 2019 14:59:53 +0200 Subject: Fixes get_holder disks with nvme drives Change-Id: I195ffdeeb3c13bdec5fc1735b82efa53c8d9d3de --- ironic_python_agent/utils.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ironic_python_agent/utils.py') diff --git a/ironic_python_agent/utils.py b/ironic_python_agent/utils.py index 2c71827a..0257cfb1 100644 --- a/ironic_python_agent/utils.py +++ b/ironic_python_agent/utils.py @@ -17,6 +17,7 @@ import errno import glob import io import os +import re import shutil import subprocess import tarfile @@ -60,6 +61,9 @@ COLLECT_LOGS_COMMANDS = { } +DEVICE_EXTRACTOR = re.compile(r'^(?:(.*\d)p|(.*\D))(?:\d+)$') + + def execute(*cmd, **kwargs): """Convenience wrapper around ironic_lib's execute() method. @@ -436,3 +440,16 @@ def get_ssl_client_options(conf): else: cert = None return verify, cert + + +def extract_device(part): + """Extract the device from a partition name or path. + + :param part: the partition + :return: a device if success, None otherwise + """ + + m = DEVICE_EXTRACTOR.match(part) + if not m: + return None + return (m.group(1) or m.group(2)) -- cgit v1.2.1