Commit Graph

16 Commits

Author SHA1 Message Date
26279f91e8 Rename truenas_migrate.py to migrate.py
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:10:53 -05:00
5f7ef09ad5 Add __pycache__ to .gitignore, remove tracked bytecode
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 21:50:18 -05:00
c157e14fa9 Restructure into package: truenas_migrate/
Split single-file script into focused modules:
  colors.py   – ANSI helpers and shared logger
  summary.py  – Summary dataclass and report renderer
  archive.py  – Debug archive parser (SCALE + CORE layouts)
  client.py   – WebSocket engine, TrueNASClient, dataset utilities
  migrate.py  – Payload builders, migrate_smb_shares, migrate_nfs_shares
  cli.py      – Interactive wizard, argparse, run(), main()
  __main__.py – python -m truenas_migrate entry point

truenas_migrate.py retained as a one-line compatibility shim.
Both 'python truenas_migrate.py' and 'python -m truenas_migrate' work.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 21:50:00 -05:00
543ca6b471 Revert "Add interactive checkbox share selector with arrow keys and spacebar"
This reverts commit d0f3a7e77b.
2026-03-04 21:27:25 -05:00
d0f3a7e77b Add interactive checkbox share selector with arrow keys and spacebar
Replaces the numbered-input share picker with a full TTY checkbox UI:
  ↑/↓ to move cursor, Space to toggle, A to select/deselect all, Enter to confirm.
Falls back to the original numbered text input when stdin is not a TTY.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 21:24:21 -05:00
e6e9d4a000 Remove SMB global config migration
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 21:13:13 -05:00
8353b50924 Add per-share selection in interactive wizard
After parsing the archive, present a numbered list of SMB and NFS
shares and let the user pick which ones to migrate. Entering nothing
(or 'all') keeps everything; 'n' skips the type entirely; space-
separated numbers select specific shares.

Because archive_data is filtered before the dry run, only selected
shares are processed in both the dry and live runs, and the dataset
existence check covers exactly the chosen share paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 11:22:16 -05:00
684a21e28f Add color and improved formatting to CLI output
- Auto-detected ANSI colors (disabled when stderr is not a TTY)
- Colored log formatter: dim timestamps, level names styled by severity
- Migration status keywords colored: SKIP=yellow, CREATED=bold-green,
  FAILED=bold-red, [DRY RUN]=cyan
- Share/export header lines bold with share name in bold-cyan
- Dry-run banner rendered as a bold-yellow framed box
- Summary report: cyan border, colored per-stat counts (green/yellow/red),
  errors and warnings highlighted; fixed box width (w=60) with ANSI-aware
  padding so columns stay aligned with color codes present
- Interactive wizard: styled header, cyan numbered list items

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 11:08:12 -05:00
e094c05cae Fix CORE→SCALE compatibility for SMB and NFS share payloads
Strip CORE-only SMB share field (vuid) and NFS share fields
(paths, alldirs, quiet) that are rejected by the SCALE API.
Convert CORE's NFS paths list to the single path string SCALE expects.
Also include NFS paths in dry-run dataset existence checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 10:03:41 -05:00
7d4921e71a Untrack CLAUDE.md; add to .gitignore (local-only file)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 09:38:46 -05:00
ddb3fbd3ff Add dry-run dataset existence checks with option to create missing datasets
During dry runs, query pool.dataset.query on the destination to verify that
every share path would have a backing ZFS dataset. Missing paths are collected
in Summary.missing_datasets and surfaced as a WARNING block in the report.

In interactive mode the user is prompted to create any auto-creatable
(/mnt/…) datasets before the live migration proceeds. Non-interactive
--dry-run mode prints the same warning in the summary report.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 09:37:44 -05:00
ab1781dbe2 Add interactive wizard mode
When run with no arguments the script now guides the user through the
full migration interactively:
  1. Lists debug archives found in the current directory and prompts
     for selection (auto-selects when only one is present)
  2. Prompts for destination host, port, and API key (key input hidden)
  3. Prompts for migration scope (SMB shares / NFS shares / SMB config)
  4. Runs a dry run and displays the summary
  5. Asks for confirmation before applying changes live

The archive is parsed once and reused for both the dry and live runs.
The existing CLI flag interface is unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 21:37:11 -05:00
1e2a972d33 Remove websockets dependency; implement RFC 6455 WebSocket client using stdlib
Replaces the third-party `websockets` package with a self-contained
implementation built on asyncio.open_connection, ssl, hashlib, base64,
struct, and os — all Python stdlib modules available on TrueNAS OS.

The script now runs directly on TrueNAS without any pip install.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 18:39:55 -05:00
9c5612e85a Update for Core Debugs 2026-03-03 14:54:03 -05:00
0a42cb572f Update to debug paths 2026-03-03 13:57:52 -05:00
3adb11487f intitial commit 2026-03-02 17:38:35 -05:00