Skip to content

Add servicenow-cmdb-export CLI#15

Draft
adamswbrown wants to merge 1 commit into
mainfrom
claude/export-server-app-mapping-Q2gRB
Draft

Add servicenow-cmdb-export CLI#15
adamswbrown wants to merge 1 commit into
mainfrom
claude/export-server-app-mapping-Q2gRB

Conversation

@adamswbrown
Copy link
Copy Markdown
Owner

Summary

  • New servicenow-cmdb-export Python CLI under servicenow-cmdb-export/. Connects to a ServiceNow instance over the Table API and writes a denormalized device-to-business-app-and-environment mapping to .xlsx.
  • Pulls both servers (cmdb_ci_server) and client devices (cmdb_ci_pc_hardware), joining each to business apps via cmdb_rel_ci (relationship types: Runs on::Runs, Depends on::Used by, Hosted on::Hosts).
  • Environment is resolved by edges to cmdb_ci_environment CIs (per the design call to model environment as a separate CI rather than the used_for field).
  • Client devices that have no direct app relationship fall back to apps where the assigned user is business_owner / managed_by / owned_by, capped by --max-apps-per-user (default 10).

Output schema (device_app_map sheet)

device_type | name | fqdn | environment | assigned_user | assigned_user_email | business_app | app_owner | criticality | support_group

--raw adds extra sheets dumping the underlying cmdb_ci_server, cmdb_ci_pc_hardware, cmdb_ci_business_app, and cmdb_ci_environment records for auditing.

Configuration

Env vars: SNOW_INSTANCE, SNOW_USER, SNOW_PASSWORD (HTTP basic). See .env.example.

Test plan

  • pip install -e servicenow-cmdb-export succeeds
  • snow-cmdb-export --help and snow-cmdb-export server-app-map --help render
  • Run against a real (non-prod) ServiceNow instance: snow-cmdb-export server-app-map --out cmdb.xlsx --device-type all
  • Open the resulting workbook and verify rows for at least one server with an app relationship and one client with assigned-user fallback
  • Spot-check environment populates from a known cmdb_ci_environment CI
  • Re-run with --raw and confirm raw sheets present
  • Try --query with a sysparm_query filter (e.g. operational_status=1) and confirm filtered results

https://claude.ai/code/session_01JgkCjwqTFGQBra1unq3d8v


Generated by Claude Code

Pulls CMDB server and client CIs from ServiceNow and writes a denormalized
device-to-business-app-and-environment mapping to Excel. Joins via
cmdb_rel_ci with an assigned-user ownership fallback for clients that have
no direct app relationship.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants