feat: sanitize VM names for OpenStack resource naming#219
feat: sanitize VM names for OpenStack resource naming#219fdiazbra merged 2 commits intoos-migrate:mainfrom
Conversation
fdiazbra
left a comment
There was a problem hiding this comment.
Thanks for this comprehensive PR! The SafeVmName enhancement is a real improvement for handling non-ASCII VM names. However, there are a couple of issues that need to be addressed before merging:
- Remove changes from another PR
- Verify transliteration tests
| } | ||
| } else { | ||
| logger.Log.Infof("Skipping V2V conversion...") | ||
| volMetadata = map[string]string{ |
There was a problem hiding this comment.
It looks like this PR includes changes from another PR
Could you please rebase this branch on the current main branch to include only the SafeVmName changes? This will make the review cleaner and avoid merge conflicts.
Extend SafeVmName to transliterate common non-ASCII characters (Spanish, Portuguese, French, German), collapse consecutive underscores, truncate to 64 characters, and strip trailing underscores. Apply it consistently across migrate, create_server and create_network_port.
7300417 to
c1020cf
Compare
|
Thanks for the review! I've addressed both points: 1. Removed changes from another PR 2. Fixed transliteration tests
|
Summary
VM names in VMware environments often contain accented characters,
special symbols or other characters that are not valid in OpenStack
resource names. This was causing failures or unexpected names in
Cinder volumes, Nova instances and Neutron ports.
Changes
plugins/module_utils/utils.goExtended
SafeVmNamewith three additional sanitization steps:ASCII equivalent before the regex runs (e.g.
ñ→n,ß→ss,ç→c,á→a). Covers Spanish, Portuguese, French, German and extended Latin.replacement step are collapsed into one (e.g.
vm--01 → vm_01).trailing underscore left after truncation is stripped.
plugins/modules/src/migrate/migrate.goSafeVmNameis now applied tovmNamewhen looking up an existingvolume and when setting the name of a newly created volume.
plugins/modules/src/create_server/create_server.goSafeVmNameis now applied tomoduleArgs.Namein both code pathsthat create a Nova instance.
plugins/modules/src/create_network_port/create_network_port.goSafeVmNameis now applied tomoduleArgs.VmNamewhen constructingthe Neutron port name.
tests/unit/utils_test.goUpdated existing test expectations to match the new behaviour and added
test cases covering underscore collapsing, transliteration (accented
vowels, ñ, ß, ç), truncation to 64 characters and trailing-underscore
stripping after truncation.
Testing