diff options
author | pmikus <peter.mikus@protonmail.ch> | 2023-05-05 09:26:12 +0000 |
---|---|---|
committer | Peter Mikus <peter.mikus@protonmail.ch> | 2023-05-05 09:32:26 +0000 |
commit | 4fef5ddc97a8acec3b3cb41e67736385f93081b6 (patch) | |
tree | 22501f61abfb4c49c551e99e3866485201b848df /resources/libraries/python | |
parent | d74acc4db2987d9ac40aae10be8453c922a16731 (diff) |
fix(core): Docker detection
Signed-off-by: pmikus <peter.mikus@protonmail.ch>
Change-Id: I976f96410b06b4f4d7500b03b1f5dd54486bbf42
Diffstat (limited to 'resources/libraries/python')
-rw-r--r-- | resources/libraries/python/DUTSetup.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/resources/libraries/python/DUTSetup.py b/resources/libraries/python/DUTSetup.py index 300248c448..363bb7243b 100644 --- a/resources/libraries/python/DUTSetup.py +++ b/resources/libraries/python/DUTSetup.py @@ -713,18 +713,15 @@ class DUTSetup: to detect. :rtype: bool """ - command = u"fgrep docker /proc/1/cgroup" - message = u"Failed to get cgroup settings." + command = "cat /.dockerenv" try: - exec_cmd_no_error( - node, command, timeout=30, sudo=False, message=message - ) + exec_cmd_no_error(node, command, timeout=30) except RuntimeError: return False return True @staticmethod - def get_docker_mergeddir(node, uuid): + def get_docker_mergeddir(node, uuid=None): """Get Docker overlay for MergedDir diff. :param node: DUT node. @@ -735,8 +732,15 @@ class DUTSetup: :rtype: str :raises RuntimeError: If getting output failed. """ - command = f"docker inspect " \ + if not uuid: + command = 'fgrep "hostname" /proc/self/mountinfo | cut -f 4 -d" "' + message = "Failed to get UUID!" + stdout, _ = exec_cmd_no_error(node, command, message=message) + uuid = stdout.split(sep="/")[-2] + command = ( + f"docker inspect " f"--format='{{{{.GraphDriver.Data.MergedDir}}}}' {uuid}" + ) message = f"Failed to get directory of {uuid} on host {node[u'host']}" stdout, _ = exec_cmd_no_error(node, command, sudo=True, message=message) |