cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Service offering category feature

Open Hanarion opened this issue 3 weeks ago • 22 comments

Description

When using Cloudstack, when creating instance with a lot of offerings, it could be hard to differentiate between all of the offerings. For that, categories could be useful.

This pull request introduces the concept of "Service Offering Categories" to the API, allowing service offerings to be grouped, managed, and queried by category. It adds a new interface for categories, updates the API to support creating, updating, deleting, and listing categories, and enables associating service offerings with a category. The changes also extend existing API commands and responses to work with categories.

Service Offering Category API Support:

  • Added new API commands for service offering categories: CreateServiceOfferingCategoryCmd, DeleteServiceOfferingCategoryCmd, UpdateServiceOfferingCategoryCmd, and ListServiceOfferingCategoriesCmd, enabling full CRUD operations and listing for categories.
  • Updated ConfigurationService interface to include methods for creating, deleting, and updating service offering categories.
  • Added a new interface ServiceOfferingCategory that defines category properties and behaviors.

API Parameter and Response Enhancements:

  • Introduced new API parameters and constants for category ID and name (SERVICE_OFFERING_CATEGORY_ID, SERVICE_OFFERING_CATEGORY_NAME) in ApiConstants, and updated related commands (CreateServiceOfferingCmd, UpdateServiceOfferingCmd, ListServiceOfferingsCmd) to accept or filter by category.
  • Extended ResponseGenerator to support generating responses for service offering categories.

Service Offering Model Update:

  • Added a getCategoryId() method to the ServiceOffering interface, allowing offerings to be associated with a specific category.

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [X] 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

  • [X] Major
  • [ ] Minor

Bug Severity

  • [ ] BLOCKER
  • [ ] Critical
  • [ ] Major
  • [ ] Minor
  • [ ] Trivial

Screenshots (if appropriate):

image image image image

How Has This Been Tested?

On my dev environment, through the API and cloudmonkey

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

Those changes should not break any features as it is only adding a new column to serviceoffering and adding a new table, it is only a way to filter and categorize.

-- I'm sorry if the formatting isn't perfect, i couldn't get the pre-commit to work, and it is my first code PR. Warning, i put the SQL where i thought it made sense, but i think you will want to move it where it really should be.

Hanarion avatar Nov 26 '25 18:11 Hanarion

Codecov Report

:x: Patch coverage is 0.37879% with 263 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 17.56%. Comparing base (2600965) to head (4ff6cf3).

Files with missing lines Patch % Lines
.../cloud/configuration/ConfigurationManagerImpl.java 0.00% 60 Missing :warning:
...a/com/cloud/service/ServiceOfferingCategoryVO.java 0.00% 37 Missing :warning:
...ain/java/com/cloud/api/query/QueryManagerImpl.java 0.00% 30 Missing :warning:
...min/offering/UpdateServiceOfferingCategoryCmd.java 0.00% 22 Missing :warning:
...min/offering/CreateServiceOfferingCategoryCmd.java 0.00% 19 Missing :warning:
.../api/response/ServiceOfferingCategoryResponse.java 0.00% 19 Missing :warning:
...min/offering/DeleteServiceOfferingCategoryCmd.java 0.00% 15 Missing :warning:
...ud/service/dao/ServiceOfferingCategoryDaoImpl.java 0.00% 14 Missing :warning:
...min/offering/ListServiceOfferingCategoriesCmd.java 0.00% 12 Missing :warning:
...src/main/java/com/cloud/api/ApiResponseHelper.java 0.00% 8 Missing :warning:
... and 8 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #12144      +/-   ##
============================================
- Coverage     17.57%   17.56%   -0.01%     
+ Complexity    15550    15549       -1     
============================================
  Files          5913     5920       +7     
  Lines        529427   529717     +290     
  Branches      64677    64708      +31     
============================================
- Hits          93024    93023       -1     
- Misses       425940   426232     +292     
+ Partials      10463    10462       -1     
Flag Coverage Δ
uitests 3.58% <ø> (-0.01%) :arrow_down:
unittests 18.62% <0.37%> (-0.02%) :arrow_down:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Nov 27 '25 04:11 codecov[bot]

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

github-actions[bot] avatar Nov 27 '25 15:11 github-actions[bot]

Dear @Hanarion,

This is a nice feature to have. Are you considering extending it to allow a domain or account to be limited to one (or a specific list) of categories?

For example, we distinguish between Core (higher-performance hardware) and Essentials (lower-performance hardware), in a tiered fashion (with different costs, of course). With "Offering Category", we could define which groups of offerings a client (domain/account) is allowed to use.

What do you think?

daviftorres avatar Nov 28 '25 18:11 daviftorres

@daviftorres it could be interesting yes. An association between accounts, domains and the categories ? And if none are found, we show everything ? But that would mean that we would need to add a check for "permission" to use the specific service offering category when creating a VM if we want to do things right. What do you think ?

Hanarion avatar Nov 28 '25 18:11 Hanarion

@daviftorres it could be interesting yes. An association between accounts, domains and the categories ? And if none are found, we show everything ? But that would mean that we would need to add a check for "permission" to use the specific service offering category when creating a VM if we want to do things right. What do you think ?

Sounds great!

daviftorres avatar Nov 28 '25 18:11 daviftorres

@blueorangutan package

rajujith avatar Dec 01 '25 06:12 rajujith

@rajujith 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 avatar Dec 01 '25 06:12 blueorangutan

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

blueorangutan avatar Dec 01 '25 07:12 blueorangutan

@rajujith thanks for the review. Can you give me a bit more detail about that ? Is it showing the default one in the list UI, detail or edit ? Or do you mean that the return object isn't updated with the new category on the edit service offering call ?

I'll check today in order to fix this issue

Hanarion avatar Dec 02 '25 09:12 Hanarion

@Hanarion

https://github.com/user-attachments/assets/53355d0d-9afb-4e0a-a826-11e0fac9a485

rajujith avatar Dec 03 '25 04:12 rajujith

@rajujith Indeed when refactoring the names of the fields before comitting, i broke the functionnality, i fixed it.

Also, i dont know where i should put the SQL, currently i put it in schema-42200to42300.sql, but I think it should be moved to schema-42210to42300.sql

Do you confirm ?

Hanarion avatar Dec 03 '25 15:12 Hanarion

@rajujith Indeed when refactoring the names of the fields before comitting, i broke the functionnality, i fixed it.

Also, i dont know where i should put the SQL, currently i put it in schema-42200to42300.sql, but I think it should be moved to schema-42210to42300.sql

Do you confirm ?

Thanks for fixing it @Hanarion , regarding the schema lets ask a dev @DaanHoogland @harikrishna-patnala

rajujith avatar Dec 04 '25 04:12 rajujith

@blueorangutan package

rajujith avatar Dec 04 '25 04:12 rajujith

@rajujith 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 avatar Dec 04 '25 04:12 blueorangutan

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

blueorangutan avatar Dec 04 '25 06:12 blueorangutan

@rajujith Indeed when refactoring the names of the fields before comitting, i broke the functionnality, i fixed it.

Also, i dont know where i should put the SQL, currently i put it in schema-42200to42300.sql, but I think it should be moved to schema-42210to42300.sql

Do you confirm ?

Thanks for fixing it @Hanarion , regarding the schema lets ask a dev @DaanHoogland @harikrishna-patnala

Yes @Hanarion , 42210 to 42300 seems appropriate.

DaanHoogland avatar Dec 04 '25 15:12 DaanHoogland

@blueorangutan package

rajujith avatar Dec 05 '25 04:12 rajujith

@rajujith 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 avatar Dec 05 '25 04:12 blueorangutan

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

blueorangutan avatar Dec 05 '25 06:12 blueorangutan

@blueorangutan test

DaanHoogland avatar Dec 08 '25 09:12 DaanHoogland

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

blueorangutan avatar Dec 08 '25 09:12 blueorangutan

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

Test Result Time (s) Test File
test_updating_nics_on_two_shared_networks Error 1.80 test_gateway_on_shared_networks.py
ContextSuite context=TestGatewayOnSharedNetwork>:teardown Error 4.04 test_gateway_on_shared_networks.py
test_11_destroy_ssvm Error 3.23 test_ssvm.py
test_01_vpn_usage Error 1.12 test_usage.py
test_01_secure_vm_migration Error 135.45 test_vm_life_cycle.py
test_01_secure_vm_migration Error 135.46 test_vm_life_cycle.py
test_hostha_enable_ha_when_host_disabled Error 3.92 test_hostha_kvm.py
test_hostha_enable_ha_when_host_in_maintenance Error 306.19 test_hostha_kvm.py

blueorangutan avatar Dec 09 '25 02:12 blueorangutan