Skip to content

Add API to enable/disable NICs for KVM#12819

Merged
DaanHoogland merged 3 commits intoapache:mainfrom
scclouds:api-to-enable-disable-nics
Mar 31, 2026
Merged

Add API to enable/disable NICs for KVM#12819
DaanHoogland merged 3 commits intoapache:mainfrom
scclouds:api-to-enable-disable-nics

Conversation

@hsato03
Copy link
Copy Markdown
Member

@hsato03 hsato03 commented Mar 16, 2026

Description

This PR introduces the updateVmNic API, allowing users to enable or disable their VMs network interface cards (NICs).

Currently, this API supports only KVM with the following parameters:

Parameter Description Required
nicid The ID of the NIC that will be updated Yes
enabled If true, sets the NIC state to Enabled; otherwise, sets the NIC state to Disabled No

Future updates will extend this API to support additional NIC properties and hypervisors.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

All tests were performed using only one NIC in the VM. Furthermore, the results of all tests were obtained using the ip a command executed inside the VM.

N Test Result
1 With the VM running, I changed the state of its NIC from Enabled to Disabled The NIC was DOWN
2 With the VM running, I changed the state of its NIC from Disabled to Enabled The NIC was UP
3 With the VM stopped, I started it with its NIC in the Enabled state The NIC was UP
4 With the VM stopped, I started it with its NIC in the Disabled state The NIC was DOWN

How did you try to break this feature and the system with this change?

@hsato03
Copy link
Copy Markdown
Member Author

hsato03 commented Mar 16, 2026

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@hsato03 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17163

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 13.15789% with 198 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.01%. Comparing base (1bff543) to head (939ba82).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...n/java/com/cloud/vm/VirtualMachineManagerImpl.java 0.00% 52 Missing ⚠️
...cloudstack/api/command/user/vm/UpdateVmNicCmd.java 0.00% 32 Missing ⚠️
...urce/wrapper/LibvirtUpdateVmNicCommandWrapper.java 4.00% 24 Missing ⚠️
...n/java/com/cloud/agent/api/UpdateVmNicCommand.java 0.00% 20 Missing ⚠️
...on/src/main/java/com/cloud/vm/VmWorkUpdateNic.java 0.00% 11 Missing ⚠️
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 67.74% 7 Missing and 3 partials ⚠️
...pi/src/main/java/com/cloud/agent/api/to/NicTO.java 0.00% 6 Missing ⚠️
api/src/main/java/com/cloud/vm/NicProfile.java 14.28% 6 Missing ⚠️
...rg/apache/cloudstack/api/response/NicResponse.java 0.00% 6 Missing ⚠️
...in/java/com/cloud/agent/api/UpdateVmNicAnswer.java 0.00% 5 Missing ⚠️
... and 10 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #12819      +/-   ##
============================================
- Coverage     18.02%   18.01%   -0.01%     
- Complexity    16460    16462       +2     
============================================
  Files          5968     5973       +5     
  Lines        537213   537461     +248     
  Branches      65975    65989      +14     
============================================
+ Hits          96825    96833       +8     
- Misses       429469   429707     +238     
- Partials      10919    10921       +2     
Flag Coverage Δ
uitests 3.52% <ø> (-0.01%) ⬇️
unittests 19.18% <13.15%> (-0.01%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@JoaoJandre JoaoJandre left a comment

Choose a reason for hiding this comment

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

Minor nit

Copy link
Copy Markdown
Contributor

@GaOrtiga GaOrtiga left a comment

Choose a reason for hiding this comment

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

@hsato03
Code lgtm (apart from @JoaoJandre's review)

I also tested locally by enabling/disabling the NIC and using ip a inside the VM, I also tested:

  • Using the API through the UI and CMK.
  • Editing the default NIC when the VM has multiple NICs.
  • Editing the NIC with the VM stopped and then starting it.

Everything worked as expected.

@hsato03
Copy link
Copy Markdown
Member Author

hsato03 commented Mar 18, 2026

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@hsato03 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17189

@JoaoJandre
Copy link
Copy Markdown
Contributor

@DaanHoogland @vishesh92 @abh1sar could we run the CI here?

@sureshanaparti
Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-15735)

@github-actions
Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@hsato03
Copy link
Copy Markdown
Member Author

hsato03 commented Mar 30, 2026

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@hsato03 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17291

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

[SF] Trillian test result (tid-15775)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 51066 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12819-t15775-kvm-ol8.zip
Smoke tests completed. 151 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@DaanHoogland DaanHoogland merged commit 7eea9ed into apache:main Mar 31, 2026
23 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants