Skip to content

Commit 90294a6

Browse files
committed
ui,api,server: template categorization based on os
Adds new interface for image selection (template/iso) for an instance in UI. Old interface can still be used and it can be configured using UI configuration (config.json) OS categories/Guest OS categories have been improved with ability to create new categories, delete an existing category, and marking a category as featured to allow it to show up in the UI in the image selection interface. New APIs added: - addOsCategory - deleteOsCategory - updateOsCategory APIs updated: - updateOsType - listTemplates - listOsCategories Several improvements in UI especially related to forms - DeloyVM, ReinstallVM, CreateVnfAppliance, AddAutoscaleGroup. DeployVM form can now be opened from template details view with query params. Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 5d28e66 commit 90294a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2808
-794
lines changed

api/src/main/java/com/cloud/server/ManagementService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525
import org.apache.cloudstack.api.command.admin.config.ListCfgGroupsByCmd;
2626
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
2727
import org.apache.cloudstack.api.command.admin.config.UpdateHypervisorCapabilitiesCmd;
28+
import org.apache.cloudstack.api.command.admin.guest.AddGuestOsCategoryCmd;
2829
import org.apache.cloudstack.api.command.admin.guest.AddGuestOsCmd;
2930
import org.apache.cloudstack.api.command.admin.guest.AddGuestOsMappingCmd;
31+
import org.apache.cloudstack.api.command.admin.guest.DeleteGuestOsCategoryCmd;
3032
import org.apache.cloudstack.api.command.admin.guest.GetHypervisorGuestOsNamesCmd;
3133
import org.apache.cloudstack.api.command.admin.guest.ListGuestOsMappingCmd;
3234
import org.apache.cloudstack.api.command.admin.guest.RemoveGuestOsCmd;
3335
import org.apache.cloudstack.api.command.admin.guest.RemoveGuestOsMappingCmd;
36+
import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsCategoryCmd;
3437
import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsCmd;
3538
import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsMappingCmd;
3639
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
@@ -168,6 +171,12 @@ public interface ManagementService {
168171
*/
169172
Pair<List<? extends GuestOsCategory>, Integer> listGuestOSCategoriesByCriteria(ListGuestOsCategoriesCmd cmd);
170173

174+
GuestOsCategory addGuestOsCategory(AddGuestOsCategoryCmd cmd);
175+
176+
GuestOsCategory updateGuestOsCategory(UpdateGuestOsCategoryCmd cmd);
177+
178+
boolean deleteGuestOsCategory(DeleteGuestOsCategoryCmd cmd);
179+
171180
/**
172181
* Obtains a list of all guest OS mappings
173182
*

api/src/main/java/com/cloud/server/ResourceTag.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public enum ResourceObjectType {
6666
LBStickinessPolicy(false, true),
6767
LBHealthCheckPolicy(false, true),
6868
SnapshotPolicy(true, true),
69+
GuestOsCategory(false, false, true),
6970
GuestOs(false, true),
7071
NetworkOffering(false, true),
7172
VpcOffering(true, false),

api/src/main/java/com/cloud/storage/GuestOsCategory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ public interface GuestOsCategory extends Identity, InternalIdentity {
2727

2828
void setName(String name);
2929

30+
boolean isFeatured();
31+
3032
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ public class ApiConstants {
290290
public static final String IS_EXTRACTABLE = "isextractable";
291291
public static final String IS_FEATURED = "isfeatured";
292292
public static final String IS_IMPLICIT = "isimplicit";
293+
public static final String IS_ISO = "isiso";
293294
public static final String IS_PORTABLE = "isportable";
294295
public static final String IS_PUBLIC = "ispublic";
295296
public static final String IS_PERSISTENT = "ispersistent";

api/src/main/java/org/apache/cloudstack/api/ResponseGenerator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.cloud.bgp.ASNumber;
2626
import com.cloud.bgp.ASNumberRange;
2727

28+
import org.apache.cloudstack.api.response.GuestOSCategoryResponse;
2829
import org.apache.cloudstack.storage.object.Bucket;
2930
import org.apache.cloudstack.affinity.AffinityGroup;
3031
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -227,6 +228,7 @@
227228
import com.cloud.server.ResourceIcon;
228229
import com.cloud.storage.GuestOS;
229230
import com.cloud.storage.GuestOSHypervisor;
231+
import com.cloud.storage.GuestOsCategory;
230232
import com.cloud.storage.ImageStore;
231233
import com.cloud.storage.Snapshot;
232234
import com.cloud.storage.StoragePool;
@@ -481,6 +483,8 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine
481483

482484
AutoScaleVmGroupResponse createAutoScaleVmGroupResponse(AutoScaleVmGroup vmGroup);
483485

486+
GuestOSCategoryResponse createGuestOSCategoryResponse(GuestOsCategory guestOsCategory);
487+
484488
GuestOSResponse createGuestOSResponse(GuestOS os);
485489

486490
GuestOsMappingResponse createGuestOSMappingResponse(GuestOSHypervisor osHypervisor);
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.command.admin.guest;
19+
20+
import org.apache.cloudstack.acl.RoleType;
21+
import org.apache.cloudstack.api.APICommand;
22+
import org.apache.cloudstack.api.ApiConstants;
23+
import org.apache.cloudstack.api.ApiErrorCode;
24+
import org.apache.cloudstack.api.BaseCmd;
25+
import org.apache.cloudstack.api.Parameter;
26+
import org.apache.cloudstack.api.ServerApiException;
27+
import org.apache.cloudstack.api.response.GuestOSCategoryResponse;
28+
29+
import com.cloud.storage.GuestOsCategory;
30+
import com.cloud.user.Account;
31+
32+
@APICommand(name = "addOsCategory",
33+
description = "Adds a new OS category",
34+
responseObject = GuestOSCategoryResponse.class,
35+
requestHasSensitiveInfo = false,
36+
responseHasSensitiveInfo = false,
37+
since = "4.20.1",
38+
authorized = {RoleType.Admin})
39+
public class AddGuestOsCategoryCmd extends BaseCmd {
40+
41+
42+
/////////////////////////////////////////////////////
43+
//////////////// API parameters /////////////////////
44+
/////////////////////////////////////////////////////
45+
46+
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Name of the OS category",
47+
required = true)
48+
private String name;
49+
50+
@Parameter(name = ApiConstants.IS_FEATURED, type = CommandType.BOOLEAN,
51+
description = "Whether the category is featured or not")
52+
private Boolean featured;
53+
54+
/////////////////////////////////////////////////////
55+
/////////////////// Accessors ///////////////////////
56+
/////////////////////////////////////////////////////
57+
58+
public String getName() {
59+
return name;
60+
}
61+
62+
public boolean isFeatured() {
63+
return Boolean.TRUE.equals(featured);
64+
}
65+
66+
/////////////////////////////////////////////////////
67+
/////////////// API Implementation///////////////////
68+
/////////////////////////////////////////////////////
69+
70+
@Override
71+
public void execute() {
72+
GuestOsCategory guestOs = _mgr.addGuestOsCategory(this);
73+
if (guestOs != null) {
74+
GuestOSCategoryResponse response = _responseGenerator.createGuestOSCategoryResponse(guestOs);
75+
response.setResponseName(getCommandName());
76+
setResponseObject(response);
77+
} else {
78+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add new OS category");
79+
}
80+
81+
}
82+
83+
@Override
84+
public long getEntityOwnerId() {
85+
return Account.ACCOUNT_ID_SYSTEM;
86+
}
87+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.command.admin.guest;
19+
20+
import org.apache.cloudstack.acl.RoleType;
21+
import org.apache.cloudstack.api.APICommand;
22+
import org.apache.cloudstack.api.ApiConstants;
23+
import org.apache.cloudstack.api.ApiErrorCode;
24+
import org.apache.cloudstack.api.BaseCmd;
25+
import org.apache.cloudstack.api.Parameter;
26+
import org.apache.cloudstack.api.ServerApiException;
27+
import org.apache.cloudstack.api.response.GuestOSCategoryResponse;
28+
import org.apache.cloudstack.api.response.SuccessResponse;
29+
30+
import com.cloud.user.Account;
31+
32+
33+
@APICommand(name = "deleteOsCategory",
34+
description = "Deletes an OS category",
35+
responseObject = SuccessResponse.class,
36+
requestHasSensitiveInfo = false,
37+
responseHasSensitiveInfo = false,
38+
since = "4.20.1",
39+
authorized = {RoleType.Admin})
40+
public class DeleteGuestOsCategoryCmd extends BaseCmd {
41+
42+
43+
/////////////////////////////////////////////////////
44+
//////////////// API parameters /////////////////////
45+
/////////////////////////////////////////////////////
46+
47+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOSCategoryResponse.class,
48+
required = true, description = "ID of the guest OS")
49+
private Long id;
50+
51+
/////////////////////////////////////////////////////
52+
/////////////////// Accessors ///////////////////////
53+
/////////////////////////////////////////////////////
54+
55+
public Long getId() {
56+
return id;
57+
}
58+
59+
/////////////////////////////////////////////////////
60+
/////////////// API Implementation///////////////////
61+
/////////////////////////////////////////////////////
62+
63+
@Override
64+
public void execute() {
65+
boolean result = _mgr.deleteGuestOsCategory(this);
66+
if (result) {
67+
SuccessResponse response = new SuccessResponse(getCommandName());
68+
setResponseObject(response);
69+
} else {
70+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove guest OS");
71+
}
72+
}
73+
74+
@Override
75+
public long getEntityOwnerId() {
76+
return Account.ACCOUNT_ID_SYSTEM;
77+
}
78+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.command.admin.guest;
19+
20+
import org.apache.cloudstack.acl.RoleType;
21+
import org.apache.cloudstack.api.APICommand;
22+
import org.apache.cloudstack.api.ApiConstants;
23+
import org.apache.cloudstack.api.ApiErrorCode;
24+
import org.apache.cloudstack.api.BaseCmd;
25+
import org.apache.cloudstack.api.Parameter;
26+
import org.apache.cloudstack.api.ServerApiException;
27+
import org.apache.cloudstack.api.response.GuestOSCategoryResponse;
28+
29+
import com.cloud.storage.GuestOsCategory;
30+
import com.cloud.user.Account;
31+
32+
@APICommand(name = "updateOsCategory",
33+
description = "Updates an OS category",
34+
responseObject = GuestOSCategoryResponse.class,
35+
requestHasSensitiveInfo = false,
36+
responseHasSensitiveInfo = false,
37+
since = "4.20.1",
38+
authorized = {RoleType.Admin})
39+
public class UpdateGuestOsCategoryCmd extends BaseCmd {
40+
41+
42+
43+
/////////////////////////////////////////////////////
44+
//////////////// API parameters /////////////////////
45+
/////////////////////////////////////////////////////
46+
47+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOSCategoryResponse.class,
48+
required = true, description = "ID of the OS Category")
49+
private Long id;
50+
51+
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Name for the OS category")
52+
private String name;
53+
54+
@Parameter(name = ApiConstants.IS_FEATURED, type = CommandType.BOOLEAN,
55+
description = "Whether the category is featured or not")
56+
private Boolean featured;
57+
58+
@Parameter(name = ApiConstants.SORT_KEY, type = CommandType.INTEGER,
59+
description = "sort key of the OS category for listing")
60+
private Integer sortKey;
61+
62+
/////////////////////////////////////////////////////
63+
/////////////////// Accessors ///////////////////////
64+
/////////////////////////////////////////////////////
65+
66+
public Long getId() {
67+
return id;
68+
}
69+
70+
public String getName() {
71+
return name;
72+
}
73+
74+
public Boolean isFeatured() {
75+
return featured;
76+
}
77+
78+
public Integer getSortKey() {
79+
return sortKey;
80+
}
81+
82+
/////////////////////////////////////////////////////
83+
/////////////// API Implementation///////////////////
84+
/////////////////////////////////////////////////////
85+
86+
@Override
87+
public long getEntityOwnerId() {
88+
return Account.ACCOUNT_ID_SYSTEM;
89+
}
90+
91+
@Override
92+
public void execute() {
93+
GuestOsCategory guestOs = _mgr.updateGuestOsCategory(this);
94+
if (guestOs != null) {
95+
GuestOSCategoryResponse response = _responseGenerator.createGuestOSCategoryResponse(guestOs);
96+
response.setResponseName(getCommandName());
97+
setResponseObject(response);
98+
} else {
99+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update guest OS type");
100+
}
101+
}
102+
}

0 commit comments

Comments
 (0)