Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed Dec 4, 2024
1 parent 4115616 commit 5b5bd14
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,20 @@ options:
Show script version and exit
Malcolm Git repo:
-g, --github-url <string>
-g <string>, --github-url <string>
Malcolm repository url (e.g., https://github.com/idaholab/Malcolm)
-b, --github-branch <string>
-b <string>, --github-branch <string>
Malcolm repository branch (e.g., main)
Virtual machine specifications:
-c, --cpus <integer> Number of CPUs for virtual Malcolm instance
-m, --memory <integer>
-c <integer>, --cpus <integer>
Number of CPUs for virtual Malcolm instance
-m <integer>, --memory <integer>
System memory (GB) for virtual Malcolm instance
-d, --disk <integer> Disk size (GB) for virtual Malcolm instance
-i, --image <string> Malcolm virtual instance base image name (e.g., debian-12)
-d <integer>, --disk <integer>
Disk size (GB) for virtual Malcolm instance
-i <string>, --image <string>
Malcolm virtual instance base image name (e.g., debian-12)
--image-user <string>
Malcolm virtual instance base image username (e.g., debian)
--vm-name-prefix <string>
Expand All @@ -75,29 +78,31 @@ Virtual machine specifications:
--vm-provision-malcolm [true|false]
Perform VM provisioning (Malcolm-specific)
--vm-provision-path <string>
Path containing subdirectories with TOML files for VM provisioning
Path containing subdirectories with TOML files for VM provisioning (e.g., /home/user/.local/lib/python3.12/site-packages/maltest/virter)
--build-vm <string> The name for a new VM image to build and commit instead of running one
--build-vm-keep-layers [true|false]
Don't remove intermediate layers when building a new VM image
Malcolm runtime configuration:
--container-image-file <string>
Malcolm container images .tar.xz file for installation (instead of "docker pull")
-s, --start [true|false]
--netbox-restore-file <string>
NetBox backup file to place in ./netbox/preload/
-s [true|false], --start [true|false]
Start Malcolm once provisioning is complete (default true)
-r, --rm [true|false]
-r [true|false], --rm [true|false]
Remove virtual Malcolm instance after execution is complete
--stay-up [true|false]
Stay running until CTRL+C or SIGKILL is received
--sleep <integer> Seconds to sleep after init before starting Malcolm (default 30)
Testing configuration:
--test-path <string> Path containing test definitions
-p, --pcap-path <string>
--test-path <string> Path containing test definitions (e.g., /home/user/.local/lib/python3.12/site-packages/maltest/tests)
-p <string>, --pcap-path <string>
Path containing PCAP files used by tests (UPLOAD_ARTIFACTS in tests should resolve relative to this path)
-t, --run-tests [true|false]
-t [true|false], --run-tests [true|false]
Run test suite once Malcolm is started
-w, --wait-for-idle [true|false]
-w [true|false], --wait-for-idle [true|false]
Wait for ingest idle state before running tests
```

Expand Down
9 changes: 9 additions & 0 deletions src/maltest/maltest.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ def main():
default='',
help='Malcolm container images .tar.xz file for installation (instead of "docker pull")',
)
configArgGroup.add_argument(
'--netbox-restore-file',
required=False,
dest='netboxRestoreFile',
metavar='<string>',
type=str,
default='',
help='NetBox backup file to place in ./netbox/preload/',
)
configArgGroup.add_argument(
'-s',
'--start',
Expand Down
12 changes: 12 additions & 0 deletions src/maltest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ def __init__(
'MALCOLM_REPO_URL',
'MALCOLM_REPO_BRANCH',
'MALCOLM_TEST_PATH',
'MALCOLM_TEST_PCAP_PATH',
'MALCOLM_AUTH_PASSWORD',
'MALCOLM_AUTH_USERNAME',
)
Expand Down Expand Up @@ -1242,6 +1243,17 @@ def ProvisionInit(self):
for provisionFile in sorted(glob.glob(os.path.join(self.vmTomlMalcolmInitPath, '*.toml'))):
self.ProvisionFile(provisionFile)

# rsync the netbox database restore file to the VM if specified
if self.netboxRestoreFile:
if (
self.CopyFile(
self.netboxRestoreFile,
f'/home/{self.vmImageUsername}/Malcolm/netbox/preload/{os.path.basename(self.netboxRestoreFile)}',
)
!= 0
):
self.logger.warning(f"Error copying the NetBox backup file to ./netbox/preload")

# sleep a bit, if indicated
sleepCtr = 0
while (ShuttingDown[0] == False) and (self.buildMode == False) and (sleepCtr < self.postInitSleep):
Expand Down
13 changes: 10 additions & 3 deletions src/maltest/virter/malcolm-init/01-clone-install.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ REPO_BRANCH = "main"

VERBOSE = "false"
CONFIGURE_ONLY = "false"
EXTRA = ""
RUNTIME = "docker"
IMAGE_FILE = ""
MALCOLM_PROFILE = "true"
Expand Down Expand Up @@ -75,8 +76,8 @@ VIRUSTOTAL_API_KEY = ""
FILE_SCAN_RULE_UPDATE = "false"
NETBOX = "true"
NETBOX_ENRICH = "true"
NETBOX_AUTOPOPULATE = "true"
NETBOX_AUTO_PREFIXES = "true"
NETBOX_AUTOPOPULATE = "false"
NETBOX_AUTO_PREFIXES = "false"
NETBOX_SITE_NAME = ""
LIVE_CAPTURE_IFACE = ""
LIVE_CAPTURE_FILTER = ""
Expand Down Expand Up @@ -118,6 +119,11 @@ ln -s -r -f "$HOME"/Malcolm/malcolm-iso/config/includes.chroot/etc/skel/.config/
OLD_GRUB_HASH=$(sha256sum /etc/default/grub | awk '{print $1}')
EXTRA_ARRAY=()
if [[ -n "$EXTRA" ]]; then
readarray -td '' EXTRA_ARRAY < <(awk '{ gsub(/\|/,"\0"); print; }' <<<"$EXTRA|"); unset 'EXTRA_ARRAY[-1]';
fi
pushd Malcolm
python3 ./scripts/install.py --defaults \
--verbose "$VERBOSE" \
Expand Down Expand Up @@ -202,7 +208,8 @@ python3 ./scripts/install.py --defaults \
--live-capture-tcpdump "$LIVE_CAPTURE_TCPDUMP" \
--live-capture-zeek "$LIVE_CAPTURE_ZEEK" \
--live-capture-suricata "$LIVE_CAPTURE_SURICATA" \
--node-name "$NODE_NAME" || true
--node-name "$NODE_NAME" \
--extra "${EXTRA_ARRAY[@]}" || true
if command -v direnv &>/dev/null; then
eval "$(direnv hook bash)"
Expand Down

0 comments on commit 5b5bd14

Please sign in to comment.