Skip to content

Conversation

@Hanarion
Copy link

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)
  • 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):

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.

Landry JUGE added 5 commits November 26, 2025 19:23
- Introduced new API commands for creating, updating, and deleting service offering categories.
- Added support for associating service offerings with categories.
- Updated database schema to include service offering categories.
- Enhanced existing service offering commands to handle category IDs.
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 0.37879% with 263 lines in your changes missing coverage. Please review.
✅ 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 ⚠️
...a/com/cloud/service/ServiceOfferingCategoryVO.java 0.00% 37 Missing ⚠️
...ain/java/com/cloud/api/query/QueryManagerImpl.java 0.00% 30 Missing ⚠️
...min/offering/UpdateServiceOfferingCategoryCmd.java 0.00% 22 Missing ⚠️
...min/offering/CreateServiceOfferingCategoryCmd.java 0.00% 19 Missing ⚠️
.../api/response/ServiceOfferingCategoryResponse.java 0.00% 19 Missing ⚠️
...min/offering/DeleteServiceOfferingCategoryCmd.java 0.00% 15 Missing ⚠️
...ud/service/dao/ServiceOfferingCategoryDaoImpl.java 0.00% 14 Missing ⚠️
...min/offering/ListServiceOfferingCategoriesCmd.java 0.00% 12 Missing ⚠️
...src/main/java/com/cloud/api/ApiResponseHelper.java 0.00% 8 Missing ⚠️
... 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%) ⬇️
unittests 18.62% <0.37%> (-0.02%) ⬇️

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.

@github-actions
Copy link

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

@bernardodemarco bernardodemarco self-requested a review November 28, 2025 11:22
@daviftorres
Copy link
Contributor

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?

@Hanarion
Copy link
Author

@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 ?

@daviftorres
Copy link
Contributor

@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!

@rajujith
Copy link

rajujith commented Dec 1, 2025

@blueorangutan package

@blueorangutan
Copy link

@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
Copy link

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

Copy link

@rajujith rajujith left a comment

Choose a reason for hiding this comment

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

@Hanarion I added service offering to a new category but it gets added the default one although the API has the correct one.

@Hanarion
Copy link
Author

Hanarion commented Dec 2, 2025

@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

@rajujith
Copy link

rajujith commented Dec 3, 2025

@Hanarion

Screen.Recording.2025-12-03.at.10.03.17.AM.mov

Landry JUGE added 2 commits December 3, 2025 14:56
@Hanarion
Copy link
Author

Hanarion commented Dec 3, 2025

@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 ?

@rajujith
Copy link

rajujith commented Dec 4, 2025

@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
Copy link

rajujith commented Dec 4, 2025

@blueorangutan package

@blueorangutan
Copy link

@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
Copy link

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

@DaanHoogland
Copy link
Contributor

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

@rajujith
Copy link

rajujith commented Dec 5, 2025

@blueorangutan package

@blueorangutan
Copy link

@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
Copy link

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

Copy link
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 pull request introduces a "Service Offering Categories" feature to CloudStack, enabling administrators to organize and categorize service offerings for better user experience when deploying VMs. The feature adds complete CRUD API support for categories, database schema changes, and UI enhancements for category selection and filtering.

Key Changes:

  • Added new database table service_offering_category and foreign key relationship to service_offering table
  • Implemented full CRUD API operations: createServiceOfferingCategory, listServiceOfferingCategories, updateServiceOfferingCategory, and deleteServiceOfferingCategory
  • Enhanced UI with category selection widgets in VM deployment and service offering management interfaces

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql Database migration script adding the service_offering_category table and foreign key to service_offering
engine/schema/src/main/java/com/cloud/service/ServiceOfferingCategoryVO.java Entity class for service offering category with name, UUID, and sort key
engine/schema/src/main/java/com/cloud/service/ServiceOfferingVO.java Added categoryId field to associate service offerings with categories
engine/schema/src/main/java/com/cloud/service/dao/ServiceOfferingCategoryDao.java DAO interface for category persistence operations
engine/schema/src/main/java/com/cloud/service/dao/ServiceOfferingCategoryDaoImpl.java DAO implementation with name-based lookup and list operations
api/src/main/java/com/cloud/offering/ServiceOfferingCategory.java Interface defining category properties and behaviors
api/src/main/java/com/cloud/offering/ServiceOffering.java Added getCategoryId() method to the ServiceOffering interface
api/src/main/java/org/apache/cloudstack/api/ApiConstants.java Added constants for category ID and name parameters
api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCategoryCmd.java API command for creating service offering categories
api/src/main/java/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCategoryCmd.java API command for updating service offering categories
api/src/main/java/org/apache/cloudstack/api/command/admin/offering/DeleteServiceOfferingCategoryCmd.java API command for deleting service offering categories
api/src/main/java/org/apache/cloudstack/api/command/admin/offering/ListServiceOfferingCategoriesCmd.java API command for listing service offering categories
api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java Extended to accept categoryId parameter
api/src/main/java/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java Extended to accept categoryId parameter for updates
api/src/main/java/org/apache/cloudstack/api/command/user/offering/ListServiceOfferingsCmd.java Extended to filter by categoryId
api/src/main/java/org/apache/cloudstack/api/response/ServiceOfferingResponse.java Added categoryId and categoryName fields to API response
api/src/main/java/org/apache/cloudstack/api/response/ServiceOfferingCategoryResponse.java Response object for service offering category with ID, name, and sort key
api/src/main/java/org/apache/cloudstack/api/ResponseGenerator.java Added method to generate service offering category responses
api/src/main/java/com/cloud/configuration/ConfigurationService.java Extended interface with category management methods
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java Implementation of create, update, and delete operations for categories with validation
server/src/main/java/com/cloud/api/ApiResponseHelper.java Helper method to create category response objects
server/src/main/java/com/cloud/api/query/QueryManagerImpl.java Query implementation for listing categories with filtering and added categoryId filtering to service offering queries
server/src/main/java/com/cloud/api/query/vo/ServiceOfferingJoinVO.java Added categoryId field to the join view object
server/src/main/java/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java Populates category information in service offering responses
server/src/main/java/com/cloud/server/ManagementServerImpl.java Registered new category API commands
engine/schema/src/main/resources/META-INF/db/views/cloud.service_offering_view.sql Added category_id to the service offering database view
engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-common-daos-between-management-and-usage-context.xml Registered ServiceOfferingCategoryDaoImpl bean
ui/src/views/offering/AddComputeOffering.vue Added category dropdown in compute offering creation form
ui/src/views/compute/wizard/ComputeOfferingSelection.vue Added category filter widget for VM deployment wizard
ui/src/views/compute/DeployVM.vue Fetches and handles category filtering in VM deployment flow
ui/src/config/section/offering.js Added category to searchFilters, columns, details, and edit parameters
ui/src/config/section/config.js Added new config section for service offering category management
ui/src/components/view/ListView.vue Added category column with router-link and updateServiceOfferingCategory command mapping
ui/public/locales/en.json Added localization strings for category features
server/src/test/java/com/cloud/vpc/MockConfigurationManagerImpl.java Mock implementation stubs for category methods

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


CREATE TABLE IF NOT EXISTS `cloud`.`service_offering_category` (
`id` bigint unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The name column should have a UNIQUE constraint to prevent duplicate category names, as the application logic in ConfigurationManagerImpl.java checks for duplicate names when creating/updating categories (lines 8634-8636 and 8692-8695).

Copilot uses AI. Check for mistakes.
if (categoryId == 1L) {
throw new InvalidParameterValueException("Cannot delete the default service offering category");
}

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The delete validation is incomplete. The comment on line 8659 states "Check if any service offering is using this category", but the actual implementation only checks if it's the default category (id=1). Due to the foreign key constraint with ON DELETE RESTRICT in the schema, attempting to delete a category that's in use will cause a database error. The code should query for service offerings using this category and provide a clear error message before attempting deletion.

Suggested change
// Check if any service offering is using this category
List<ServiceOfferingVO> offeringsUsingCategory = _serviceOfferingDao.listByCategoryId(categoryId);
if (offeringsUsingCategory != null && !offeringsUsingCategory.isEmpty()) {
throw new InvalidParameterValueException("Cannot delete service offering category with id " + categoryId +
" because it is in use by one or more service offerings.");
}

Copilot uses AI. Check for mistakes.
width: 100%;
height: 100%;
.radio-opion__icon {
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

There is a typo in the CSS class name: 'radio-opion__icon' should be 'radio-option__icon' (missing 't' in 'option').

Copilot uses AI. Check for mistakes.

@Override
public long getEntityOwnerId() {
return Account.Type.ADMIN.ordinal();
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The getEntityOwnerId() method returns Account.Type.ADMIN.ordinal(), which is incorrect. The ordinal() of an enum returns its position (0 for ADMIN), not an account ID. This should return Account.ACCOUNT_ID_SYSTEM to match the pattern used in similar commands like UpdateServiceOfferingCategoryCmd (line 80-82).

Suggested change
return Account.Type.ADMIN.ordinal();
return Account.ACCOUNT_ID_SYSTEM;

Copilot uses AI. Check for mistakes.
Comment on lines +290 to +294
@Param(description = "the ID of the service offering category", since = "4.23")
private String categoryId;

@SerializedName("category")
@Param(description = "the name of the service offering category", since = "4.23")
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The version format should be consistent across the codebase. Most new features use "4.23.0" format (as seen in the API commands), but this uses "4.23". Please use "4.23.0" to maintain consistency.

Suggested change
@Param(description = "the ID of the service offering category", since = "4.23")
private String categoryId;
@SerializedName("category")
@Param(description = "the name of the service offering category", since = "4.23")
@Param(description = "the ID of the service offering category", since = "4.23.0")
private String categoryId;
@SerializedName("category")
@Param(description = "the name of the service offering category", since = "4.23.0")

Copilot uses AI. Check for mistakes.

@Override
public long getEntityOwnerId() {
return Account.Type.ADMIN.ordinal();
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The getEntityOwnerId() method returns Account.Type.ADMIN.ordinal(), which is incorrect. The ordinal() of an enum returns its position (0 for ADMIN), not an account ID. This should return Account.ACCOUNT_ID_SYSTEM to match the pattern used in other admin commands, such as CreateServiceOfferingCategoryCmd (line 82-83) and UpdateServiceOfferingCategoryCmd (line 80-82).

Suggested change
return Account.Type.ADMIN.ordinal();
return Account.ACCOUNT_ID_SYSTEM;

Copilot uses AI. Check for mistakes.

@Parameter(name = ApiConstants.SERVICE_OFFERING_CATEGORY_ID,
type = CommandType.UUID,
entityType = ServiceOfferingCategoryResponse .class,
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

There is an extra space before .class in the entityType parameter: 'ServiceOfferingCategoryResponse .class' should be 'ServiceOfferingCategoryResponse.class'.

Suggested change
entityType = ServiceOfferingCategoryResponse .class,
entityType = ServiceOfferingCategoryResponse.class,

Copilot uses AI. Check for mistakes.
entityType = ServiceOfferingCategoryResponse.class,
required = false,
description = "the ID of the service offering category to associate",
since = "4.23")
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The version format should be consistent. This parameter uses "4.23" while most other API commands use "4.23.0" format. Please use "4.23.0" for consistency.

Suggested change
since = "4.23")
since = "4.23.0")

Copilot uses AI. Check for mistakes.
Comment on lines +2312 to +2313
} else {
params.categoryid = null
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

Setting params.categoryid = null may not properly remove the filter parameter. Instead, consider using delete params.categoryid or simply not setting it when categoryId is '-1', to avoid sending categoryid=null in the API request which may not be handled as "no filter".

Copilot uses AI. Check for mistakes.
<template v-if="column.key === 'vgpuActions'">
<slot name="actionButtons" :record="record" :actions="actions"></slot>
</template>
<template v-if="column.key === 'category' && $route.path.split('/')[1] === 'computeoffering'">
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

There is an extra space in the condition: column.key === 'category' && has two spaces before &&. Should be a single space for consistency.

Copilot uses AI. Check for mistakes.
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.

5 participants