Skip to content

Commit e9a0c4c

Browse files
committed
fix: raise memory on esxi before loading target
1 parent 5748e82 commit e9a0c4c

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

acquire/acquire.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import argparse
4+
import contextlib
45
import enum
56
import functools
67
import io
@@ -2411,19 +2412,20 @@ def main() -> None:
24112412
target_path = f"{target_path}?{target_query}"
24122413
target_paths.append(target_path)
24132414

2415+
# Use esxi_memory_context_manager only if running on ESXi host
2416+
if platform.system().lower() == "vmkernel":
2417+
context_mgr = esxi_memory_context_manager()
2418+
else:
2419+
context_mgr = contextlib.nullcontext()
2420+
24142421
try:
24152422
target_name = "Unknown" # just in case open_all already fails
2416-
for target in Target.open_all(target_paths):
2417-
target_name = "Unknown" # overwrite previous target name
2418-
target_name = target.name
2419-
log.info("Loading target %s", target_name)
2420-
log.info(target)
2421-
if target.os == "esxi" and target.name == "local":
2422-
# Loader found that we are running on an esxi host
2423-
# Perform operations to "enhance" memory
2424-
with esxi_memory_context_manager():
2425-
files_to_upload = acquire_children_and_targets(target, args)
2426-
else:
2423+
with context_mgr:
2424+
for target in Target.open_all(target_paths):
2425+
target_name = "Unknown" # overwrite previous target name
2426+
target_name = target.name
2427+
log.info("Loading target %s", target_name)
2428+
log.info(target)
24272429
files_to_upload = acquire_children_and_targets(target, args)
24282430
except Exception:
24292431
log.error("Failed to acquire target: %s", target_name) # noqa: TRY400

0 commit comments

Comments
 (0)