Skip to content

feat(v2): add mtv_maps role for StorageMap and NetworkMap CRs - #80

Draft
tech2734 wants to merge 3 commits into
redhat-cop:v2from
tech2734:feature/mtv-maps
Draft

feat(v2): add mtv_maps role for StorageMap and NetworkMap CRs#80
tech2734 wants to merge 3 commits into
redhat-cop:v2from
tech2734:feature/mtv-maps

Conversation

@tech2734

Copy link
Copy Markdown

Summary

  • Adds a new mtv_maps role that creates Forklift/MTV StorageMap and NetworkMap custom resources on target OpenShift clusters
  • Queries the MTV inventory (via mtv_query_inventory) for datastores, storage classes, networks, and NADs, then builds and applies the mapping CRs
  • Integrates with aap_seed by adding a new "MTV Maps" job template definition

Key Features

  • Single or multiple named storage maps with per-datastore storage class overrides
  • Network map with annotation-based NAD auto-matching (infra.openshift-virtualization-migration/source-portgroup)
  • Include/exclude filtering for both storage and network entries
  • Default storage class auto-detection from cluster annotation
  • Block/rescue error handling with full diagnostic context output
  • OpenShift connection variable cascade from K8S_AUTH_* env vars (AAP credential injection)
  • Full argument_specs validation (17 documented parameters)

Dependencies

Test Plan

  • Validated against homelab environment (Forklift 2.8.7)
    • StorageMap: 9 datastore→storageClass mappings created
    • NetworkMap: 4 network→pod mappings created
    • ok=88 changed=2 failed=0 rescued=0
  • Test idempotency (re-run, expect changed=0)
  • Test with network map overrides (explicit multus/pod destinations)
  • Test multiple named storage maps
  • Test include/exclude filtering
  • Test from AAP with credential injection
  • Verify rescue block output on intentional failure

Note on mtv_query_inventory endpoint regex

During testing, the mtv_query_inventory role's endpoint path validation regex was found to reject query parameters (?detail=4). This needs to be addressed in PR #75 before this role can work end-to-end from AAP.

Implements a new role that creates Forklift/MTV StorageMap and
NetworkMap custom resources on target OpenShift clusters. Queries
the MTV inventory for datastores, storage classes, networks, and
NADs, then builds and applies the mapping CRs.

Features:
- Single or multiple named storage maps with per-datastore overrides
- Network map with annotation-based NAD auto-matching
- Include/exclude filtering for both storage and network entries
- Default storage class auto-detection
- Block/rescue error handling with diagnostic output
- Full argument_specs validation
- aap_seed integration with new job template definition

Tested against homelab environment:
- StorageMap: 9 datastore mappings created successfully
- NetworkMap: 4 network mappings created successfully
- Idempotent apply via server-side merge

Co-authored-by: Cursor <cursoragent@cursor.com>
Add title, required, and description comment blocks above each
variable in defaults/main.yml to enable docsible README generation,
matching the pattern established in mtv_query_inventory.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace hardcoded app.kubernetes.io/managed-by value with
mtv_maps_managed_by_label variable, consistent with the approach
in mtv_provider (PR redhat-cop#82).

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant