Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTV-1596 | Add new NetworkNameTemplate field to plan CR #1327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yaacov
Copy link
Member

@yaacov yaacov commented Feb 2, 2025

Ref:
https://issues.redhat.com/browse/MTV-1596

RFE:
Requesting the ability for choosing a custom name for the network and disks during migration for VM's. Currently migrations end up with 'net-0' or 'vol-1' and cannot be modified. A newly created vm typically allows for you to name these.

Fix:
Add an optional network template:

NetworkNameTemplate is a template for generating network interface names in the target virtual machine.
It follows Go template syntax and has access to the following variables:
   - .NetworkName: If target network is multus, name of the Multus network attachment definition, empty otherwise.
   - .NetworkNamespace: If target network is multus, namespace where the network attachment definition is located.  
   - .NetworkType: type of the network ("Multus" or "Pod")
   - .NetworkIndex: sequential index of the network interface (0-based)
The template can be used to customize network interface names based on target network configuration.
 Note:
   - This template can be overridden at the individual VM level
   - If not specified on VM level and on Plan leverl, default naming conventions will be used
 Examples:
   "net-{{.NetworkIndex}}"
   "{{if eq .NetworkType "pod"}}pod{{else}}multus-{{.NetworkIndex}}{{end}}"

In the plan YAML:

spec:
   ...
   networkNameTemplate:   "net-{{.NetworkIndex}}"

   vms:
    - name: some-vm
      networkNameTemplate:   "{{if eq .NetworkType "pod"}}pod{{else}}multus-{{.NetworkIndex}}{{end}}"

Screenshots:
plan-yaml-custom-net

vm-yaml-custom-net

@yaacov yaacov changed the title MTV-1596: Add new NetworkNameTemplate field to plan CR MTV-1596 | Add new NetworkNameTemplate field to plan CR Feb 2, 2025
@yaacov yaacov force-pushed the mtv-1596-allow-for-customizing-names-for-network branch 4 times, most recently from 80d9785 to 775d5cd Compare February 2, 2025 12:18
@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 121 lines in your changes missing coverage. Please review.

Project coverage is 15.33%. Comparing base (f1fe5d0) to head (c23efaf).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controller/plan/validation.go 0.00% 68 Missing ⚠️
pkg/controller/plan/adapter/vsphere/builder.go 0.00% 53 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1327      +/-   ##
==========================================
- Coverage   15.45%   15.33%   -0.13%     
==========================================
  Files         112      112              
  Lines       23377    23620     +243     
==========================================
+ Hits         3613     3621       +8     
- Misses      19479    19711     +232     
- Partials      285      288       +3     
Flag Coverage Δ
unittests 15.33% <0.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yaacov yaacov marked this pull request as ready for review February 2, 2025 13:46
@yaacov yaacov requested a review from mnecas as a code owner February 2, 2025 13:46
@yaacov yaacov marked this pull request as draft February 2, 2025 14:23
@yaacov yaacov force-pushed the mtv-1596-allow-for-customizing-names-for-network branch from 775d5cd to 650e7c4 Compare February 2, 2025 16:27
@yaacov yaacov marked this pull request as ready for review February 2, 2025 16:27
@yaacov yaacov force-pushed the mtv-1596-allow-for-customizing-names-for-network branch 2 times, most recently from 0481ec9 to 8538f45 Compare February 2, 2025 19:34

networkName, err = r.executeTemplate(networkNameTemplate, &templateData)
if err != nil {
// fallback to default name and reset error
Copy link
Member

Choose a reason for hiding this comment

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

Maybe adding a log that the template execution failed?

Copy link
Member Author

Choose a reason for hiding this comment

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

re based and added a log line

@yaacov yaacov force-pushed the mtv-1596-allow-for-customizing-names-for-network branch from 8538f45 to 5a5cd54 Compare February 6, 2025 08:57
@yaacov yaacov force-pushed the mtv-1596-allow-for-customizing-names-for-network branch from 5a5cd54 to c23efaf Compare February 6, 2025 09:19
Copy link

sonarqubecloud bot commented Feb 6, 2025

Copy link
Member

@mnecas mnecas left a comment

Choose a reason for hiding this comment

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

lgtm

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.

3 participants