Skip to content

List usage records for network offering (usage type 13) when offering id is specified in usage id #10852

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

Conversation

sureshanaparti
Copy link
Contributor

@sureshanaparti sureshanaparti commented May 13, 2025

Description

This PR improves the List usage records API, to list network offering usages (usage type 13) when offering id is specified in usage id.

Doc PR: apache/cloudstack-documentation#505

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?

Before Fix:

(usageenv) 🐱 > list usagerecords startdate=2025-05-11 enddate=2025-05-13 type=13 usageid=bfcb52bf-cb33-4c7d-bd9d-9b4b57d65a77
(usageenv) 🐱 > 

After Fix:

(usageenv) 🐱 > list usagerecords startdate=2025-05-11 enddate=2025-05-13 type=13 usageid=bfcb52bf-cb33-4c7d-bd9d-9b4b57d65a77
{
  "count": 110,
  "usagerecord": [
    {
      "account": "admin",
      "accountid": "a5f9d055-1ea1-11f0-8a38-1e00b50002f5",
      "description": "Network offering DefaultIsolatedNetworkOfferingWithSourceNatService (bfcb52bf-cb33-4c7d-bd9d-9b4b57d65a77) usage for VM testvm01 (0c74f18a-2f1b-4bbe-b17e-bd16f4e55d86) ",
      "domain": "ROOT",
      "domainid": "676c3952-1ea1-11f0-8a38-1e00b50002f5",
      "domainpath": "/",
      "enddate": "2025-05-11'T'00:59:59+00:00",
      "isdefault": true,
      "offeringid": "bfcb52bf-cb33-4c7d-bd9d-9b4b57d65a77",
      "rawusage": "1",
      "startdate": "2025-05-11'T'00:00:00+00:00",
      "tags": [],
      "usage": "1 Hrs",
      "usagetype": 13,
      "virtualmachineid": "0c74f18a-2f1b-4bbe-b17e-bd16f4e55d86",
      "zoneid": "cd989e1a-0024-439d-8164-7db39e046c6f"
    },
    {
      "account": "admin",
      "accountid": "a5f9d055-1ea1-11f0-8a38-1e00b50002f5",
      "description": "Network offering DefaultIsolatedNetworkOfferingWithSourceNatService (bfcb52bf-cb33-4c7d-bd9d-9b4b57d65a77) usage for VM testvm02 (617f7798-7a5f-4eb7-9d13-40a3eab641df) ",
      "domain": "ROOT",
      "domainid": "676c3952-1ea1-11f0-8a38-1e00b50002f5",
      "domainpath": "/",
      "enddate": "2025-05-11'T'00:59:59+00:00",
      "isdefault": true,
      "offeringid": "bfcb52bf-cb33-4c7d-bd9d-9b4b57d65a77",
      "rawusage": "1",
      "startdate": "2025-05-11'T'00:00:00+00:00",
      "tags": [],
      "usage": "1 Hrs",
      "usagetype": 13,
      "virtualmachineid": "617f7798-7a5f-4eb7-9d13-40a3eab641df",
      "zoneid": "cd989e1a-0024-439d-8164-7db39e046c6f"
    },
    {
      "account": "admin",
      "accountid": "a5f9d055-1ea1-11f0-8a38-1e00b50002f5",
      "description": "Network offering DefaultIsolatedNetworkOfferingWithSourceNatService (bfcb52bf-cb33-4c7d-bd9d-9b4b57d65a77) usage for VM testvm01 (0c74f18a-2f1b-4bbe-b17e-bd16f4e55d86) ",
      "domain": "ROOT",
      "domainid": "676c3952-1ea1-11f0-8a38-1e00b50002f5",
      "domainpath": "/",
      "enddate": "2025-05-11'T'01:59:59+00:00",
      "isdefault": true,
      "offeringid": "bfcb52bf-cb33-4c7d-bd9d-9b4b57d65a77",
      "rawusage": "1",
      "startdate": "2025-05-11'T'01:00:00+00:00",
      "tags": [],
      "usage": "1 Hrs",
      "usagetype": 13,
      "virtualmachineid": "0c74f18a-2f1b-4bbe-b17e-bd16f4e55d86",
      "zoneid": "cd989e1a-0024-439d-8164-7db39e046c6f"
    },
...

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

@sureshanaparti sureshanaparti added this to the 4.19.3 milestone May 13, 2025
@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@DaanHoogland DaanHoogland requested a review from winterhazel May 13, 2025 08:14
Copy link

codecov bot commented May 13, 2025

Codecov Report

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

Project coverage is 15.17%. Comparing base (47a2682) to head (86e29e4).
Report is 3 commits behind head on 4.19.

Files with missing lines Patch % Lines
...rc/main/java/com/cloud/usage/UsageServiceImpl.java 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.19   #10852   +/-   ##
=========================================
  Coverage     15.17%   15.17%           
- Complexity    11343    11344    +1     
=========================================
  Files          5415     5415           
  Lines        475342   475349    +7     
  Branches      58001    58004    +3     
=========================================
+ Hits          72132    72137    +5     
- Misses       395144   395147    +3     
+ Partials       8066     8065    -1     
Flag Coverage Δ
uitests 4.28% <ø> (ø)
unittests 15.90% <0.00%> (+<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
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

new code lgtm, getUsageRecords(ListUsageRecordsCmd) is now over 200 lines long and overdue a refactor. (not necessarily in scope of this change)

@blueorangutan
Copy link

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

@DaanHoogland
Copy link
Contributor

DaanHoogland commented May 14, 2025

tested and reported on in apache/cloudstack-documentation#505 (review)

@DaanHoogland DaanHoogland merged commit a4cce70 into apache:4.19 May 14, 2025
24 of 25 checks passed
@DaanHoogland DaanHoogland deleted the list-usagerecord-for-network-offering-with-usage-id branch May 14, 2025 08:25
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