-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from 6 commits
90294a6
7fc3865
6d2c124
eda7679
f2e1b57
14cf02a
3ad581e
bcc64cc
138c704
d9f37ce
6dbc2cc
01a66bd
ce3402e
b25984c
050d2f0
bff3d61
f23a32e
ec23bf5
fdc4cce
dac8d73
69e6627
e200b9e
3e7a9a1
52a9908
15bd888
7428baa
707b0ea
9434391
d7d970d
8e1786f
6ab7123
d96afd6
551ec47
52778c1
b252f41
90c2ed5
cf522b0
75ecb4d
c9aec4a
039e1ec
3139ece
fceb522
e3e8ea3
a9c00ca
5e56234
ed5239f
c5c2f37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
|
Check warning on line 72 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/AddGuestOsCategoryCmd.java
|
||
| 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"); | ||
|
Check warning on line 78 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/AddGuestOsCategoryCmd.java
|
||
| } | ||
|
|
||
| } | ||
|
Check warning on line 81 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/AddGuestOsCategoryCmd.java
|
||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return Account.ACCOUNT_ID_SYSTEM; | ||
| } | ||
|
Check warning on line 86 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/AddGuestOsCategoryCmd.java
|
||
| } | ||
| 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 guest OS") | ||
| private Long id; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////////// Accessors /////////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
Check warning on line 57 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/DeleteGuestOsCategoryCmd.java
|
||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////// API Implementation/////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| boolean result = _mgr.deleteGuestOsCategory(this); | ||
|
Check warning on line 65 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/DeleteGuestOsCategoryCmd.java
|
||
| if (result) { | ||
| SuccessResponse response = new SuccessResponse(getCommandName()); | ||
| setResponseObject(response); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove guest OS"); | ||
|
Check warning on line 70 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/DeleteGuestOsCategoryCmd.java
|
||
shwstppr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
Check warning on line 72 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/DeleteGuestOsCategoryCmd.java
|
||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return Account.ACCOUNT_ID_SYSTEM; | ||
| } | ||
|
Check warning on line 77 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/DeleteGuestOsCategoryCmd.java
|
||
| } | ||
| 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; | ||
| } | ||
|
Check warning on line 68 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCategoryCmd.java
|
||
|
|
||
| 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; | ||
| } | ||
|
Check warning on line 89 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCategoryCmd.java
|
||
|
|
||
| @Override | ||
| public void execute() { | ||
| GuestOsCategory guestOs = _mgr.updateGuestOsCategory(this); | ||
|
Check warning on line 93 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCategoryCmd.java
|
||
| if (guestOs != null) { | ||
| GuestOSCategoryResponse response = _responseGenerator.createGuestOSCategoryResponse(guestOs); | ||
| response.setResponseName(getCommandName()); | ||
| setResponseObject(response); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update guest OS type"); | ||
|
Check warning on line 99 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCategoryCmd.java
|
||
shwstppr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
Check warning on line 101 in api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCategoryCmd.java
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.