Add dmc-prepop CLI — Phase 1: SCCM extraction#16
Draft
adamswbrown wants to merge 1 commit into
Draft
Conversation
New tool that extracts System Center inventory into CSV files for Dr Migrate pre-population. Phase 1 ships the SCCM module: all eight queries from the spec (servers, CPU, storage, network, software, services, roles, patches) with schema verification, streaming CSV output, hostname normalisation, and a coverage_summary.json. SCOM CMDB and SCOM DW modules will follow in later PRs.
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dmc-prepopPython CLI underdmc-prepop/. Extracts System Center inventory into CSV files for Dr Migrate (DMC) pre-population.Architecture
dmc_prepop/db.py— Connection abstraction. Default driver ispymssql(no ODBC install, works on Linux).--auth integratedflips topyodbcwith Windows Integrated Auth (requirespip install -e .[odbc]).dmc_prepop/output.py— Streaming CSV writer. UTF-8 with BOM, comma-delimited, quoted strings,csv.QUOTE_NONNUMERICto match the spec's documented DMC import format.dmc_prepop/normalize.py— Hostname normaliser (lowercase, strip whitespace, strip trailing$, NetBIOS-only). Applied to every Hostname-bearing column so SCCM ↔ SCOM ↔ SCOMDW joins work without further normalisation downstream.dmc_prepop/sccm/queries.py— All 8 queries asQuerydataclasses. Each lists itsrequired_viewsso the extractor can schema-verify before execution.dmc_prepop/sccm/extract.py— For each query: checkINFORMATION_SCHEMA.VIEWSfor required views, skip with a clear log message if any are missing, otherwise run in streamingfetchmanymode and write CSV.dmc_prepop/coverage.py— Emitscoverage_summary.jsonwith per-query status (executed/skipped/failed), row counts, missing views, and distinct host count from the spine. Phase 4 will add cross-source gap analysis.dmc_prepop/cli.py— Click-based CLI. Phase 1 ships thesccmsubcommand; future phases addscom/scom-dw/all.Outputs (8 CSVs + summary)
sccm_servers.csv,sccm_cpu.csv,sccm_storage.csv,sccm_network.csv,sccm_software.csv,sccm_services.csv,sccm_roles.csv,sccm_patches.csv,coverage_summary.json.Filenames match the spec exactly so downstream merge tooling can be built against a stable contract.
Spec adherence notes
COUNT(CASE WHEN ucs.Status = 2 THEN 1 END)is changed toSUM(CASE WHEN ucs.Status = 2 THEN 1 ELSE 0 END)— semantically equivalent for this counter pattern, more portable across SQL Server versions.Operating_System_Name_and0 LIKE '%Server%' AND Obsolete0 = 0 AND Active0 = 1) is applied to every query that joinsv_R_System.--timestamp-outputflag implemented per spec implementation note 7 (idempotency).INFORMATION_SCHEMA.VIEWSchecked before each query, graceful skip with logged reason.logging; coverage summary written to JSON at end of run.Deferred to follow-up PRs
MTV_*runtime view enumeration).Perf.vPerfHourly(millions of rows).Test plan
pip install -e dmc-prepopsucceedsdmc-prepop --helpanddmc-prepop sccm --helprenderdmc-prepop sccm --server <db> --database CM_<site> --user <reader> --password <...> --out output/missing_viewsrecorded incoverage_summary.json)sccm_servers.csvin Excel and confirm UTF-8 BOM, headers, and Hostname normalisation (lowercase, NetBIOS only)--timestamp-outputand confirm dated subdirectory createdv_GS_SERVER_FEATURE) and confirm graceful skip rather than crashcoverage_summary.jsonhas correct executed/skipped/failed counts and per-query row totalshttps://claude.ai/code/session_01JgkCjwqTFGQBra1unq3d8v
Generated by Claude Code