summaryrefslogtreecommitdiff
path: root/ironic_python_agent/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'ironic_python_agent/utils.py')
-rw-r--r--ironic_python_agent/utils.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/ironic_python_agent/utils.py b/ironic_python_agent/utils.py
index f391b74d..8a804b16 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 = {
}
+PARTED_ESP_PATTERN = re.compile(r'^\s*(\d+)\s.*\sfat\d*\s.*esp(,|\s|$).*$')
+
+
def execute(*cmd, **kwargs):
"""Convenience wrapper around ironic_lib's execute() method.
@@ -437,3 +441,23 @@ def get_ssl_client_options(conf):
else:
cert = None
return verify, cert
+
+
+def get_efi_part_on_device(device):
+ """Looks for the efi partition on a given device
+
+ :param device: lock device upon which to check for the efi partition
+ :return: the efi partition or None
+ """
+ efi_part = None
+ out, _u = execute('parted', '-s', device, '--', 'print')
+ for line in out.splitlines():
+ m = PARTED_ESP_PATTERN.match(line)
+ if m:
+ efi_part = m.group(1)
+
+ LOG.debug("Found efi partition %s on device %s.", efi_part, device)
+ break
+ else:
+ LOG.debug("No efi partition found on device %s", device)
+ return efi_part