Skip to content

ui,api,server: template categorization based on os #10773

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

Draft
wants to merge 29 commits into
base: 4.20
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
90294a6
ui,api,server: template categorization based on os
shwstppr Apr 10, 2025
7fc3865
reorganize os categories
shwstppr Apr 28, 2025
6d2c124
fixes for isoid as queryparam
shwstppr Apr 28, 2025
eda7679
tests
shwstppr Apr 30, 2025
f2e1b57
allow updating category for multiple os
shwstppr Apr 30, 2025
14cf02a
fix user template listing
shwstppr Apr 30, 2025
3ad581e
cosistent
shwstppr Apr 30, 2025
bcc64cc
ui fixes
shwstppr Apr 30, 2025
138c704
filter catedories for vnf templates
shwstppr Apr 30, 2025
d9f37ce
add review comments
shwstppr May 5, 2025
6dbc2cc
address ui comments
shwstppr May 5, 2025
01a66bd
fix issue with all category
shwstppr May 5, 2025
ce3402e
ui fix for tmplt pagination
shwstppr May 6, 2025
b25984c
fix reinstall form
shwstppr May 6, 2025
050d2f0
add tooltip, fix title overflow
shwstppr May 7, 2025
bff3d61
add userdata icon
shwstppr May 7, 2025
f23a32e
remove log
shwstppr May 7, 2025
ec23bf5
backend fixes
shwstppr May 7, 2025
fdc4cce
oscategoryid condition fix
shwstppr May 7, 2025
dac8d73
template/iso oscategoryid filter
shwstppr May 7, 2025
69e6627
fix icons
shwstppr May 7, 2025
e200b9e
fix for non-featured category
shwstppr May 8, 2025
3e7a9a1
refactor image search bar
shwstppr May 8, 2025
52a9908
add deploy button on infocard for images
shwstppr May 8, 2025
15bd888
category filter for guestos and fix bulk update
shwstppr May 8, 2025
7428baa
add showicon param for listOsCategories
shwstppr May 8, 2025
707b0ea
ui: show deploy button only if allowed
shwstppr May 8, 2025
9434391
Merge remote-tracking branch 'apache/4.20' into deployvm-improvements
shwstppr May 9, 2025
d7d970d
update help doc
shwstppr May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/src/main/java/com/cloud/server/ManagementService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
import org.apache.cloudstack.api.command.admin.config.ListCfgGroupsByCmd;
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
import org.apache.cloudstack.api.command.admin.config.UpdateHypervisorCapabilitiesCmd;
import org.apache.cloudstack.api.command.admin.guest.AddGuestOsCategoryCmd;
import org.apache.cloudstack.api.command.admin.guest.AddGuestOsCmd;
import org.apache.cloudstack.api.command.admin.guest.AddGuestOsMappingCmd;
import org.apache.cloudstack.api.command.admin.guest.DeleteGuestOsCategoryCmd;
import org.apache.cloudstack.api.command.admin.guest.GetHypervisorGuestOsNamesCmd;
import org.apache.cloudstack.api.command.admin.guest.ListGuestOsMappingCmd;
import org.apache.cloudstack.api.command.admin.guest.RemoveGuestOsCmd;
import org.apache.cloudstack.api.command.admin.guest.RemoveGuestOsMappingCmd;
import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsCategoryCmd;
import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsCmd;
import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsMappingCmd;
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
Expand Down Expand Up @@ -168,6 +171,12 @@ public interface ManagementService {
*/
Pair<List<? extends GuestOsCategory>, Integer> listGuestOSCategoriesByCriteria(ListGuestOsCategoriesCmd cmd);

GuestOsCategory addGuestOsCategory(AddGuestOsCategoryCmd cmd);

GuestOsCategory updateGuestOsCategory(UpdateGuestOsCategoryCmd cmd);

boolean deleteGuestOsCategory(DeleteGuestOsCategoryCmd cmd);

/**
* Obtains a list of all guest OS mappings
*
Expand Down
1 change: 1 addition & 0 deletions api/src/main/java/com/cloud/server/ResourceTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public enum ResourceObjectType {
LBStickinessPolicy(false, true),
LBHealthCheckPolicy(false, true),
SnapshotPolicy(true, true),
GuestOsCategory(false, false, true),
GuestOs(false, true),
NetworkOffering(false, true),
VpcOffering(true, false),
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/storage/GuestOsCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public interface GuestOsCategory extends Identity, InternalIdentity {

void setName(String name);

boolean isFeatured();

}
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public class ApiConstants {
public static final String IS_EXTRACTABLE = "isextractable";
public static final String IS_FEATURED = "isfeatured";
public static final String IS_IMPLICIT = "isimplicit";
public static final String IS_ISO = "isiso";
public static final String IS_PORTABLE = "isportable";
public static final String IS_PUBLIC = "ispublic";
public static final String IS_PERSISTENT = "ispersistent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.cloud.bgp.ASNumber;
import com.cloud.bgp.ASNumberRange;

import org.apache.cloudstack.api.response.GuestOSCategoryResponse;
import org.apache.cloudstack.storage.object.Bucket;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
Expand Down Expand Up @@ -227,6 +228,7 @@
import com.cloud.server.ResourceIcon;
import com.cloud.storage.GuestOS;
import com.cloud.storage.GuestOSHypervisor;
import com.cloud.storage.GuestOsCategory;
import com.cloud.storage.ImageStore;
import com.cloud.storage.Snapshot;
import com.cloud.storage.StoragePool;
Expand Down Expand Up @@ -481,6 +483,8 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine

AutoScaleVmGroupResponse createAutoScaleVmGroupResponse(AutoScaleVmGroup vmGroup);

GuestOSCategoryResponse createGuestOSCategoryResponse(GuestOsCategory guestOsCategory);

GuestOSResponse createGuestOSResponse(GuestOS os);

GuestOsMappingResponse createGuestOSMappingResponse(GuestOSHypervisor osHypervisor);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.cloudstack.api.command.admin.guest;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.GuestOSCategoryResponse;

import com.cloud.storage.GuestOsCategory;
import com.cloud.user.Account;

@APICommand(name = "addOsCategory",
description = "Adds a new OS category",
responseObject = GuestOSCategoryResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
since = "4.20.1",
authorized = {RoleType.Admin})
public class AddGuestOsCategoryCmd extends BaseCmd {


/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Name of the OS category",
required = true)
private String name;

@Parameter(name = ApiConstants.IS_FEATURED, type = CommandType.BOOLEAN,
description = "Whether the category is featured or not")
private Boolean featured;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public String getName() {
return name;
}

public boolean isFeatured() {
return Boolean.TRUE.equals(featured);
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public void execute() {
GuestOsCategory guestOs = _mgr.addGuestOsCategory(this);
if (guestOs != null) {
GuestOSCategoryResponse response = _responseGenerator.createGuestOSCategoryResponse(guestOs);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add new OS category");
}

}

@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.cloudstack.api.command.admin.guest;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.GuestOSCategoryResponse;
import org.apache.cloudstack.api.response.SuccessResponse;

import com.cloud.user.Account;


@APICommand(name = "deleteOsCategory",
description = "Deletes an OS category",
responseObject = SuccessResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
since = "4.20.1",
authorized = {RoleType.Admin})
public class DeleteGuestOsCategoryCmd extends BaseCmd {


/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOSCategoryResponse.class,
required = true, description = "ID of the OS category")
private Long id;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getId() {
return id;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public void execute() {
boolean result = _mgr.deleteGuestOsCategory(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove OS category");
}
}

@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.cloudstack.api.command.admin.guest;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.GuestOSCategoryResponse;

import com.cloud.storage.GuestOsCategory;
import com.cloud.user.Account;

@APICommand(name = "updateOsCategory",
description = "Updates an OS category",
responseObject = GuestOSCategoryResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false,
since = "4.20.1",
authorized = {RoleType.Admin})
public class UpdateGuestOsCategoryCmd extends BaseCmd {



/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOSCategoryResponse.class,
required = true, description = "ID of the OS category")
private Long id;

@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Name for the OS category")
private String name;

@Parameter(name = ApiConstants.IS_FEATURED, type = CommandType.BOOLEAN,
description = "Whether the category is featured or not")
private Boolean featured;

@Parameter(name = ApiConstants.SORT_KEY, type = CommandType.INTEGER,
description = "sort key of the OS category for listing")
private Integer sortKey;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getId() {
return id;
}

public String getName() {
return name;
}

public Boolean isFeatured() {
return featured;
}

public Integer getSortKey() {
return sortKey;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
}

@Override
public void execute() {
GuestOsCategory guestOs = _mgr.updateGuestOsCategory(this);
if (guestOs != null) {
GuestOSCategoryResponse response = _responseGenerator.createGuestOSCategoryResponse(guestOs);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update OS category");
}
}
}
Loading
Loading