Skip to content

Refactor duplicate XML/UUID logic into shared module#88

Merged
dupremathieu merged 3 commits intoseapath:mainfrom
dupremathieu:improvments
Mar 13, 2026
Merged

Refactor duplicate XML/UUID logic into shared module#88
dupremathieu merged 3 commits intoseapath:mainfrom
dupremathieu:improvments

Conversation

@dupremathieu
Copy link
Member

@dupremathieu dupremathieu commented Mar 13, 2026

  • Add UUID collision detection for predefined VM UUIDs
  • Add explicit errors when a UUID conflict is detected
  • Add UUID cluster tests
  • Extract duplicated XML name/UUID handling and UUID conflict checking from vm_manager_cluster.py and vm_manager_libvirt.py into a new vm_manager/xml_utils.py module
  • Both modules now call shared prepare_xml_base() and check_uuid_conflict() functions, reducing code duplication by ~50 lines

dupremathieu and others added 2 commits March 13, 2026 10:39
Prevent creating VMs with duplicate UUIDs by checking existing UUIDs
before defining a new VM. In standalone mode, checks local libvirt
domains; in cluster mode, reads XML metadata from RBD system disks
to detect collisions across all nodes.

Add explicit errors when a UUID conflict is detected.

Add TestListAllUuids (2 tests), and TestUuidCollision (1 test) classes.
Update TestCreateXml to cover predefined UUID preservation, empty UUID,
and missing UUID cases.

Strip the hardcoded UUID from the test XML helper to avoid collisions
with existing VMs on the cluster, and add _read_test_xml_with_uuid()
for tests that specifically need the predefined UUID.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Mathieu Dupré <mathieu.dupre@savoirfairelinux.com>
Extract prepare_xml_base() and check_uuid_conflict() from both
vm_manager_cluster.py and vm_manager_libvirt.py into a new
xml_utils.py module to eliminate code duplication.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Mathieu Dupré <mathieu.dupre@savoirfairelinux.com>
- Add assert that generated UUIDs differ from the predefined one
- Remove redundant UUID stripping in cluster test (already done by
  _read_test_xml)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Mathieu Dupré <mathieu.dupre@savoirfairelinux.com>
@sonarqubecloud
Copy link

@dupremathieu dupremathieu requested a review from eroussy March 13, 2026 16:56
@dupremathieu dupremathieu merged commit 1a6d5b6 into seapath:main Mar 13, 2026
5 checks passed
@dupremathieu dupremathieu deleted the improvments branch March 13, 2026 17:01
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