diff options
| author | Raphael Glon <raphael.glon@corp.ovh.com> | 2019-08-09 14:59:53 +0200 |
|---|---|---|
| committer | Raphael Glon <raphael.glon@corp.ovh.com> | 2019-08-13 10:37:18 +0200 |
| commit | c54674942388dc85f1fc0c4bce1cd4e09929b618 (patch) | |
| tree | 64f1dbc8e0509c36428a7cf9fb901be44aa679be /ironic_python_agent/utils.py | |
| parent | 47ed5a2f9f8a9d295cc8aa88446a3065f7ad547f (diff) | |
| download | ironic-python-agent-c54674942388dc85f1fc0c4bce1cd4e09929b618.tar.gz | |
Fixes get_holder disks with nvme drives
Change-Id: I195ffdeeb3c13bdec5fc1735b82efa53c8d9d3de
Diffstat (limited to 'ironic_python_agent/utils.py')
| -rw-r--r-- | ironic_python_agent/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
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)) |
