Skip to content

Conversation

shwstppr
Copy link
Contributor

@shwstppr shwstppr commented Sep 11, 2025

Description

Add statuses action in extensions to report VM power states

This PR introduces support for retrieving the power state of all VMs on a host directly from an extension using the new statuses action.
When available, this provides a single aggregated response, reducing the need for multiple calls.

If the extension does not implement statuses, the server will gracefully fall back to querying individual VMs using the existing status action.

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?

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

This PR adds change to get power state report of all VMs on the host from the extension itself.

Signed-off-by: Abhishek Kumar <[email protected]>
Signed-off-by: Abhishek Kumar <[email protected]>
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.40%. Comparing base (8089d32) to head (cac5d92).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...al/provisioner/ExternalPathPayloadProvisioner.java 88.88% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11619      +/-   ##
============================================
+ Coverage     17.36%   17.40%   +0.04%     
- Complexity    15245    15291      +46     
============================================
  Files          5888     5888              
  Lines        525831   526171     +340     
  Branches      64183    64238      +55     
============================================
+ Hits          91298    91580     +282     
- Misses       424227   424256      +29     
- Partials      10306    10335      +29     
Flag Coverage Δ
uitests 3.62% <ø> (-0.01%) ⬇️
unittests 18.45% <88.88%> (+0.04%) ⬆️

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.

@boring-cyborg boring-cyborg bot added the Python Warning... Python code Ahead! label Sep 11, 2025
@shwstppr shwstppr changed the title extension/proxmox: improve host vm power reporting extension: improve host vm power reporting Sep 11, 2025
@shwstppr shwstppr requested a review from Copilot September 11, 2025 14:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new statuses action to extensions that allows querying the power state of all VMs on a host with a single call, improving efficiency over individual VM queries. The server gracefully falls back to the existing status action when the extension doesn't support the new functionality.

Key changes:

  • Add statuses action implementation to existing extensions (Proxmox, HyperV, sample provisioner)
  • Implement Java logic to use batch VM status retrieval with fallback to individual calls
  • Add comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/vm/hypervisor/external/provisioner/provisioner.sh Adds sample statuses action implementation that returns "Not supported" error
plugins/hypervisors/external/src/main/java/org/apache/cloudstack/hypervisor/external/provisioner/ExternalPathPayloadProvisioner.java Implements batch VM status retrieval with fallback logic and modernizes JSON parsing
plugins/hypervisors/external/src/test/java/org/apache/cloudstack/hypervisor/external/provisioner/ExternalPathPayloadProvisionerTest.java Adds comprehensive test coverage for new batch status functionality
extensions/Proxmox/proxmox.sh Implements statuses action to query all VMs via Proxmox API
extensions/HyperV/hyperv.py Implements statuses action using PowerShell Get-VM command

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -647,7 +654,7 @@ protected VirtualMachine.PowerState parsePowerStateFromResponse(UserVmVO userVmV
return getPowerStateFromString(response);
}
try {
JsonObject jsonObj = new JsonParser().parse(response).getAsJsonObject();
JsonObject jsonObj = JsonParser.parseString(response).getAsJsonObject();
Copy link
Preview

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

The deprecated new JsonParser().parse() method has been replaced with JsonParser.parseString(), but this change should be consistent throughout the file. The same pattern should be applied to line 702 where JsonParser.parseString() is used in the new code.

Copilot uses AI. Check for mistakes.

@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

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

@shwstppr
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_03_deploy_and_scale_kubernetes_cluster Failure 1.16 test_kubernetes_clusters.py
test_04_autoscale_kubernetes_cluster Failure 26.82 test_kubernetes_clusters.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:extensions Python Warning... Python code Ahead!
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants