Skip to content

Addition of VM snapshots limits to the Resource tab#13288

Open
Tonitzpp wants to merge 1 commit into
apache:4.20from
scclouds:Add_info_of_vm_snapshots_limits_in_the_resource_tab
Open

Addition of VM snapshots limits to the Resource tab#13288
Tonitzpp wants to merge 1 commit into
apache:4.20from
scclouds:Add_info_of_vm_snapshots_limits_in_the_resource_tab

Conversation

@Tonitzpp
Copy link
Copy Markdown
Contributor

Description

Currently, information about the VM snapshot limits is not being displayed for accounts, domains or project in the Resources tab. Therefore, this PR adds the VM snapshots limits to the listResourceLimits API, and extends the GUI to display them.

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

Screenshots (if appropriate):

After the changes:
  • Admin tab:
    admin

  • User tab:
    user

How Has This Been Tested?

I updated my test environment and observed that the VM snapshot limit was now shown in the Resources tab of accounts, projects and domains.

@winterhazel
Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@winterhazel 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 1.66667% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (08b1d38) to head (0d6e8bf).
⚠️ Report is 6 commits behind head on 4.20.

Files with missing lines Patch % Lines
...main/java/com/cloud/api/query/vo/DomainJoinVO.java 0.00% 12 Missing ⚠️
...pache/cloudstack/api/response/AccountResponse.java 0.00% 9 Missing ⚠️
...apache/cloudstack/api/response/DomainResponse.java 0.00% 9 Missing ⚠️
...pache/cloudstack/api/response/ProjectResponse.java 0.00% 9 Missing ⚠️
...va/com/cloud/api/query/dao/AccountJoinDaoImpl.java 0.00% 7 Missing ⚠️
...ava/com/cloud/api/query/dao/DomainJoinDaoImpl.java 0.00% 7 Missing ⚠️
...ain/java/com/cloud/api/query/vo/AccountJoinVO.java 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #13288      +/-   ##
============================================
- Coverage     16.27%   16.26%   -0.02%     
+ Complexity    13439    13434       -5     
============================================
  Files          5665     5666       +1     
  Lines        500555   500705     +150     
  Branches      60789    60807      +18     
============================================
- Hits          81446    81420      -26     
- Misses       410004   410178     +174     
- Partials       9105     9107       +2     
Flag Coverage Δ
uitests 4.14% <ø> (-0.01%) ⬇️
unittests 17.11% <1.66%> (-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

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 extends CloudStack’s resource limits/counts plumbing to include VM snapshots (limit/total/available) so that the UI Resources tab can display VM snapshot limits for accounts, domains, and projects.

Changes:

  • Added vm_snapshot as a ResourceType (ordinal 12) and exposed corresponding fields/constants in API responses.
  • Extended account_view / domain_view DB views plus query VO/DAO mapping to fetch and compute VM snapshot limit/usage/available.
  • Updated the UI resource usage list and added i18n strings to render the new “VM snapshot limits” entry.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
ui/src/components/view/ResourceCountUsage.vue Adds vmsnapshot to the resources list rendered in the Resources tab.
ui/public/locales/pt_BR.json Adds pt-BR label for VM snapshot limits.
ui/public/locales/en.json Adds English label for VM snapshot limits.
server/src/main/java/com/cloud/api/query/vo/DomainJoinVO.java Adds VM snapshot limit/total columns + accessors for domain view mapping.
server/src/main/java/com/cloud/api/query/vo/AccountJoinVO.java Adds VM snapshot limit/total columns + accessors for account view mapping.
server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java Computes and populates VM snapshot limit/total/available in DomainResponse.
server/src/main/java/com/cloud/api/query/dao/AccountJoinDaoImpl.java Computes and populates VM snapshot limit/total/available in AccountResponse.
engine/schema/src/main/resources/META-INF/db/views/cloud.domain_view.sql Exposes VM snapshot limit/total via joins to resource_limit/resource_count.
engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql Exposes VM snapshot limit/total via joins to resource_limit/resource_count.
api/src/main/java/org/apache/cloudstack/api/response/ResourceLimitAndCountResponse.java Extends the shared response interface with VM snapshot setters.
api/src/main/java/org/apache/cloudstack/api/response/ProjectResponse.java Adds VM snapshot fields to project responses (serialized names + setters).
api/src/main/java/org/apache/cloudstack/api/response/DomainResponse.java Adds VM snapshot fields to domain responses (serialized names + setters).
api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java Adds VM snapshot fields to account responses (serialized names + setters).
api/src/main/java/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java Updates API parameter documentation to include type 12 (VM snapshots).
api/src/main/java/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java Updates API parameter documentation to include type 12 and vm_snapshot name.
api/src/main/java/org/apache/cloudstack/api/ApiConstants.java Adds API field-name constants for VM snapshot limit/total/available.
api/src/main/java/com/cloud/configuration/Resource.java Introduces ResourceType.vm_snapshot with ordinal 12.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

response.setSnapshotTotal(snapshotTotal);
response.setSnapshotAvailable(snapshotAvail);

Long vmSnapshotLimit = ApiDBUtils.findCorrectResourceLimitForDomain(domain.getVmSnapshotLimit(), ResourceType.vm_snapshot, domain.getId());
Comment on lines +178 to +181
String snapshotAvailable = (fullView || vmSnapshotLimit == -1) ? Resource.UNLIMITED : String.valueOf(vmSnapshotLimit - vmSnapshotTotal);
response.setVmSnapshotLimit(vmSnapshotLimitDisplay);
response.setVmSnapshotTotal(vmSnapshotTotal);
response.setVmSnapshotAvailable(snapshotAvailable);
Comment on lines +109 to +118
@Param(description = "the number of VM snapshots that can be stored by this account")
private String vmSnapshotLimit;

@SerializedName(ApiConstants.VM_SNAPSHOT_TOTAL)
@Param(description = "the number of VM snapshots stored by this account")
private Long vmSnapshotTotal;

@SerializedName(ApiConstants.VM_SNAPSHOT_AVAILABLE)
@Param(description = "the number of VM snapshots available for this account")
private String vmSnapshotAvailable;
Comment on lines +192 to +201
@Param(description = "the number of VM snapshots that can be stored by this account")
private String vmSnapshotLimit;

@SerializedName(ApiConstants.VM_SNAPSHOT_TOTAL)
@Param(description = "the number of VM snapshots stored by this account")
private Long vmSnapshotTotal;

@SerializedName(ApiConstants.VM_SNAPSHOT_AVAILABLE)
@Param(description = "the number of VM snapshots available for this account")
private String vmSnapshotAvailable;
private Long id;

@Parameter(name = ApiConstants.RESOURCE_TYPE, type = CommandType.INTEGER, description = "Type of resource. Values are 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 and 11. "
@Parameter(name = ApiConstants.RESOURCE_TYPE, type = CommandType.INTEGER, description = "Type of resource. Values are 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11 and 12. "
@Parameter(name = ApiConstants.RESOURCE_TYPE,
type = CommandType.INTEGER,
description = "Type of resource to update. If specifies valid values are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11. If not specified will update all resource counts"
description = "Type of resource to update. If specifies valid values are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12. If not specified will update all resource counts"
@blueorangutan
Copy link
Copy Markdown

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

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.

4 participants