Skip to content

feat: support vm_dest_name for OpenStack resource naming#222

Open
miguelntt wants to merge 2 commits intoos-migrate:mainfrom
miguelntt:feature/vm-dest-name
Open

feat: support vm_dest_name for OpenStack resource naming#222
miguelntt wants to merge 2 commits intoos-migrate:mainfrom
miguelntt:feature/vm-dest-name

Conversation

@miguelntt
Copy link
Copy Markdown

Summary

VM names in VMware environments often contain spaces, accented characters
or other characters that are not valid or practical in OpenStack resource
names. This PR adds an optional vm_dest_name field to the migration
workload data. When provided, it is used instead of the VMware display
name when naming all OpenStack resources (Cinder volumes, Nova instance,
Neutron ports).

The original vm_name is not affected: it continues to be used to
locate the VM in vCenter and to organise local data directories.
If vm_dest_name is omitted, behaviour is identical to before.

Usage

No new parameters are required. To override the destination name:

os_migrate_vmw_workloads_dict:
  "Virtual Machine Name 01":
    vm_dest_name: "vm-name-01"
    openstack:
      ...

Files changed

  • roles/convert_metadata/tasks/main.yml — propagates vm_dest_name into the migration JSON
  • roles/convert_metadata/templates/import_workloads.json.j2 — adds vm_dest_name to the JSON template
  • playbooks/run_migration_from_conversion_host.yml — passes vm_dest_name to the import role
  • roles/import_workloads/tasks/nbdkit.yml — passes destname to the migrate Go module
  • roles/import_workloads/tasks/create_network_port.yml — passes destname to the create_network_port Go module
  • roles/import_workloads/tasks/create_os_instance.yml — looks up volumes by vm_dest_name, passes destname to create_server
  • plugins/modules/src/migrate/migrate.go — adds DestName field and resourceName() method
  • plugins/modules/src/create_server/create_server.go — adds DestName field and resolveInstanceName() function
  • plugins/modules/src/create_network_port/create_network_port.go — adds DestName field

Allow specifying an optional destination name (vm_dest_name) for a VM
being migrated. When provided, it is used instead of the VMware VM name
when naming OpenStack resources (Cinder volumes, Nova instance, Neutron
ports). The original vm_name continues to be used to locate the VM in
vCenter.

This is useful when the target name in OpenStack must differ from the
source name in VMware, for example to apply a naming convention or to
avoid conflicts.
@miguelntt
Copy link
Copy Markdown
Author

Hey @fdiazbra, would love to get your eyes on this one when you get a chance!

if args.DestName != "" {
return args.DestName
}
return moduleutils.SafeVmName(args.Name)
Copy link
Copy Markdown
Contributor

@fdiazbra fdiazbra Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the import of the module is missing at the beginning of the file. Something like:
moduleutils "vmware-migration-kit/plugins/module_utils"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right! Yesterday while testing a new build I fixed it locally and forgot to push it. Sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants