Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c9bdac4
Resource Icon support - backend
Pearl1594 Jun 14, 2021
fd9502a
Add API support for resourceicon
Pearl1594 Jun 16, 2021
fcd5eb6
update reponse params + ui support
Pearl1594 Jun 17, 2021
af7b969
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Jun 23, 2021
25d5272
Add exclusive list api for icons and UI changes
Pearl1594 Jun 24, 2021
2e30bfd
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Jun 25, 2021
23d5bdb
refactor upload view
Pearl1594 Jun 25, 2021
1378cc7
UI changes to support resource icon wherever necessary
Pearl1594 Jun 28, 2021
96beb7b
convert api to POST + refactor icon view
Pearl1594 Jun 28, 2021
8a69934
Add response name to list API + cosmetic changes in UI
Pearl1594 Jun 29, 2021
301310c
Added support for the following:
Pearl1594 Jul 1, 2021
48064cf
List resourceicon cmds to be allowed for user role too
Pearl1594 Jul 5, 2021
cf3a101
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Jul 5, 2021
5626793
cosmetic changes
Pearl1594 Jul 5, 2021
a5cceea
optimize ui code
Pearl1594 Jul 6, 2021
574c96e
fix reload issue for domain view
Pearl1594 Jul 7, 2021
977b60a
add access check for delete operation
Pearl1594 Jul 7, 2021
e57e8fa
ui-related changes to show iso icons
Pearl1594 Jul 8, 2021
e1c6407
iso image in uservm response
Pearl1594 Jul 9, 2021
014178e
add icons to custom form's list resources
Pearl1594 Jul 12, 2021
b21d672
some more custom forms aligned to show icon for resources
Pearl1594 Jul 12, 2021
7ed4649
conmitic changes + add listing of icons to listdomainchildren cmd
Pearl1594 Jul 13, 2021
d491ff3
Add backend/server-side validation for base64 string passed for image
Pearl1594 Jul 14, 2021
1f939c5
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Jul 14, 2021
ace32f8
change preview border
Pearl1594 Aug 10, 2021
1daa432
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Aug 10, 2021
e7fe12a
preselect zone if there's only one
Pearl1594 Aug 11, 2021
386fdd6
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Aug 11, 2021
1c9ec47
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Aug 12, 2021
91cfd2e
add default icon
Pearl1594 Aug 12, 2021
5d86a78
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Aug 12, 2021
d2e5bdd
show icon for network list in deploy vm view
Pearl1594 Aug 13, 2021
5dcb121
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Aug 17, 2021
180bd04
add custom icons if any to the import-export VM view
Pearl1594 Aug 17, 2021
7af6fa9
preselect zone persistence on clearing cache
Pearl1594 Aug 17, 2021
297c69b
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Aug 17, 2021
4516d1d
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Aug 18, 2021
fda1340
prevent root vol from inheriting template/iso icon
Pearl1594 Aug 18, 2021
5e6ab80
show tempalte icon in the info card details
Pearl1594 Aug 19, 2021
835b6f5
fix icon not being show on hard-refresh / initial traversal
Pearl1594 Aug 20, 2021
12cdcf5
fx success message
Pearl1594 Aug 20, 2021
2469d67
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Sep 8, 2021
d0ba725
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Sep 9, 2021
7d1686f
Merge branch 'main' of https://github.com/apache/cloudstack into add-…
Pearl1594 Sep 14, 2021
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
4 changes: 4 additions & 0 deletions api/src/main/java/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ public class EventTypes {
public static final String EVENT_TAGS_CREATE = "CREATE_TAGS";
public static final String EVENT_TAGS_DELETE = "DELETE_TAGS";

// resource icon related events
public static final String EVENT_RESOURCE_ICON_UPLOAD = "UPLOAD.RESOURCE.ICON";
public static final String EVENT_RESOURCE_ICON_DELETE = "DELETE.RESOURCE.ICON";

// meta data related events
public static final String EVENT_RESOURCE_DETAILS_CREATE = "CREATE_RESOURCE_DETAILS";
public static final String EVENT_RESOURCE_DETAILS_DELETE = "DELETE_RESOURCE_DETAILS";
Expand Down
32 changes: 32 additions & 0 deletions api/src/main/java/com/cloud/server/ResourceIcon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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 com.cloud.server;

import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;

public interface ResourceIcon extends Identity, InternalIdentity {
long getResourceId();

void setResourceId(long resourceId);

ResourceTag.ResourceObjectType getResourceType();

String getResourceUuid();

String getIcon();
}
28 changes: 28 additions & 0 deletions api/src/main/java/com/cloud/server/ResourceIconManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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 com.cloud.server;

import java.util.List;

public interface ResourceIconManager {

boolean uploadResourceIcon(List<String> resourceIds, ResourceTag.ResourceObjectType resourceType, String base64Image);

boolean deleteResourceIcon(List<String> resourceIds, ResourceTag.ResourceObjectType resourceType);

ResourceIcon getByResourceTypeAndUuid(ResourceTag.ResourceObjectType type, String resourceId);
}
24 changes: 24 additions & 0 deletions api/src/main/java/com/cloud/server/ResourceManagerUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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 com.cloud.server;

public interface ResourceManagerUtil {
long getResourceId(String resourceId, ResourceTag.ResourceObjectType resourceType);
String getUuid(String resourceId, ResourceTag.ResourceObjectType resourceType);
ResourceTag.ResourceObjectType getResourceType(String resourceTypeStr);
void checkResourceAccessible(Long accountId, Long domainId, String exceptionMessage);
}
31 changes: 21 additions & 10 deletions api/src/main/java/com/cloud/server/ResourceTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,36 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit

// FIXME - extract enum to another interface as its used both by resourceTags and resourceMetaData code
public enum ResourceObjectType {
UserVm(true, true),
Template(true, true),
ISO(true, false),
UserVm(true, true, true),
Template(true, true, true),
ISO(true, false, true),
Volume(true, true),
Snapshot(true, false),
Backup(true, false),
Network(true, true),
Network(true, true, true),
Nic(false, true),
LoadBalancer(true, true),
PortForwardingRule(true, true),
FirewallRule(true, true),
SecurityGroup(true, false),
SecurityGroupRule(true, false),
PublicIpAddress(true, true),
Project(true, false),
Account(true, false),
Vpc(true, true),
Project(true, false, true),
Account(true, false, true),
Vpc(true, true, true),
NetworkACL(true, true),
StaticRoute(true, false),
VMSnapshot(true, false),
RemoteAccessVpn(true, true),
Zone(false, true),
Zone(false, true, true),
ServiceOffering(false, true),
Storage(false, true),
PrivateGateway(false, true),
NetworkACLList(false, true),
VpnGateway(false, true),
CustomerGateway(false, true),
VpnConnection(false, true),
User(true, true),
User(true, true, true),
DiskOffering(false, true),
AutoScaleVmProfile(false, true),
AutoScaleVmGroup(false, true),
Expand All @@ -62,16 +62,23 @@ public enum ResourceObjectType {
SnapshotPolicy(true, true),
GuestOs(false, true),
NetworkOffering(false, true),
VpcOffering(true, false);
VpcOffering(true, false),
Domain(false, false, true);


ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) {
this.resourceTagsSupport = resourceTagsSupport;
metadataSupport = resourceMetadataSupport;
}

ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport, boolean resourceIconSupport) {
this(resourceTagsSupport, resourceMetadataSupport);
this.resourceIconSupport = resourceIconSupport;
}

private final boolean resourceTagsSupport;
private final boolean metadataSupport;
private boolean resourceIconSupport;

public boolean resourceTagsSupport() {
return resourceTagsSupport;
Expand All @@ -80,6 +87,10 @@ public boolean resourceTagsSupport() {
public boolean resourceMetadataSupport() {
return metadataSupport;
}

public boolean resourceIconSupport() {
return resourceIconSupport;
}
}

/**
Expand Down
12 changes: 0 additions & 12 deletions api/src/main/java/com/cloud/server/TaggedResourceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ public interface TaggedResourceService {

List<? extends ResourceTag> listByResourceTypeAndId(ResourceObjectType type, long resourceId);

//FIXME - the methods below should be extracted to its separate manager/service responsible just for retrieving object details
ResourceObjectType getResourceType(String resourceTypeStr);

/**
* @param resourceId
* @param resourceType
* @return
*/
String getUuid(String resourceId, ResourceObjectType resourceType);

public long getResourceId(String resourceId, ResourceObjectType resourceType);

/**
* Retrieves tags from resource.
* @param type
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class ApiConstants {
public static final String BACKUP_ID = "backupid";
public static final String BACKUP_OFFERING_NAME = "backupofferingname";
public static final String BACKUP_OFFERING_ID = "backupofferingid";
public static final String BASE64_IMAGE = "base64image";
public static final String BITS = "bits";
public static final String BOOTABLE = "bootable";
public static final String BIND_DN = "binddn";
Expand Down Expand Up @@ -333,6 +334,7 @@ public class ApiConstants {
public static final String SESSIONKEY = "sessionkey";
public static final String SHOW_CAPACITIES = "showcapacities";
public static final String SHOW_REMOVED = "showremoved";
public static final String SHOW_RESOURCE_ICON = "showicon";
public static final String SHOW_UNIQUE = "showunique";
public static final String SIGNATURE = "signature";
public static final String SIGNATURE_VERSION = "signatureversion";
Expand Down Expand Up @@ -747,6 +749,7 @@ public class ApiConstants {
public static final String ACCESS_TYPE = "accesstype";

public static final String RESOURCE_DETAILS = "resourcedetails";
public static final String RESOURCE_ICON = "icon";
public static final String EXPUNGE = "expunge";
public static final String FOR_DISPLAY = "fordisplay";
public static final String PASSIVE = "passive";
Expand Down
12 changes: 9 additions & 3 deletions api/src/main/java/org/apache/cloudstack/api/BaseCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

import javax.inject.Inject;

import com.cloud.server.ManagementService;
import com.cloud.server.ResourceIconManager;
import com.cloud.server.ResourceManagerUtil;
import com.cloud.server.ResourceMetaDataService;
import com.cloud.server.TaggedResourceService;
import org.apache.cloudstack.acl.ProjectRoleService;
import org.apache.cloudstack.acl.RoleService;
import org.apache.cloudstack.acl.RoleType;
Expand Down Expand Up @@ -67,9 +72,6 @@
import com.cloud.network.vpn.Site2SiteVpnService;
import com.cloud.projects.ProjectService;
import com.cloud.resource.ResourceService;
import com.cloud.server.ManagementService;
import com.cloud.server.ResourceMetaDataService;
import com.cloud.server.TaggedResourceService;
import com.cloud.storage.DataStoreProviderApiService;
import com.cloud.storage.StorageService;
import com.cloud.storage.VolumeApiService;
Expand Down Expand Up @@ -164,6 +166,8 @@ public static enum CommandType {
@Inject
public TaggedResourceService _taggedResourceService;
@Inject
public ResourceManagerUtil resourceManagerUtil;
@Inject
public ResourceMetaDataService _resourceMetaDataService;
@Inject
public VpcService _vpcService;
Expand Down Expand Up @@ -201,6 +205,8 @@ public static enum CommandType {
public UUIDManager _uuidMgr;
@Inject
public AnnotationService annotationService;
@Inject
public ResourceIconManager resourceIconManager;

public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException, NetworkRuleConflictException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.Map;
import java.util.Set;

import com.cloud.server.ResourceIcon;
import org.apache.cloudstack.api.response.ResourceIconResponse;
import org.apache.cloudstack.api.response.RouterHealthCheckResultResponse;
import com.cloud.resource.RollingMaintenanceManager;
import org.apache.cloudstack.api.response.RollingMaintenanceResponse;
Expand Down Expand Up @@ -270,7 +272,7 @@ public interface ResponseGenerator {

PodResponse createPodResponse(Pod pod, Boolean showCapacities);

ZoneResponse createZoneResponse(ResponseView view, DataCenter dataCenter, Boolean showCapacities);
ZoneResponse createZoneResponse(ResponseView view, DataCenter dataCenter, Boolean showCapacities, Boolean showResourceIcon);

VolumeResponse createVolumeResponse(ResponseView view, Volume volume);

Expand Down Expand Up @@ -487,4 +489,6 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine

RollingMaintenanceResponse createRollingMaintenanceResponse(Boolean success, String details, List<RollingMaintenanceManager.HostUpdated> hostsUpdated, List<RollingMaintenanceManager.HostSkipped> hostsSkipped);

ResourceIconResponse createResourceIconResponse(ResourceIcon resourceIcon);

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import java.util.ArrayList;
import java.util.List;

import com.cloud.server.ResourceIcon;
import com.cloud.server.ResourceTag;
import org.apache.cloudstack.api.response.ResourceIconResponse;
import org.apache.log4j.Logger;

import org.apache.cloudstack.api.APICommand;
Expand Down Expand Up @@ -58,6 +61,10 @@ public class ListDomainChildrenCmd extends BaseListCmd {
description = "If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false")
private Boolean listAll;

@Parameter(name = ApiConstants.SHOW_RESOURCE_ICON, type = CommandType.BOOLEAN,
description = "flag to display the resource icon for domains")
private Boolean showIcon;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand All @@ -78,6 +85,10 @@ public boolean isRecursive() {
return recursive == null ? false : recursive;
}

public Boolean getShowIcon() {
return showIcon != null ? showIcon : false;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand All @@ -100,6 +111,20 @@ public void execute() {

response.setResponses(domainResponses, result.second());
response.setResponseName(getCommandName());
if (response != null && response.getCount() > 0 && getShowIcon()) {
updateDomainResponse(response.getResponses());
}
this.setResponseObject(response);
}

private void updateDomainResponse(List<DomainResponse> response) {
for (DomainResponse domainResponse : response) {
ResourceIcon resourceIcon = resourceIconManager.getByResourceTypeAndUuid(ResourceTag.ResourceObjectType.Domain, domainResponse.getId());
if (resourceIcon == null) {
continue;
}
ResourceIconResponse iconResponse = _responseGenerator.createResourceIconResponse(resourceIcon);
domainResponse.setResourceIconResponse(iconResponse);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import java.util.EnumSet;
import java.util.List;

import com.cloud.server.ResourceIcon;
import com.cloud.server.ResourceTag;
import org.apache.cloudstack.api.response.ResourceIconResponse;
import org.apache.log4j.Logger;

import org.apache.cloudstack.api.APICommand;
Expand Down Expand Up @@ -66,6 +69,10 @@ public class ListDomainsCmd extends BaseListCmd implements UserCmd {
description = "comma separated list of domain details requested, value can be a list of [ all, resource, min]")
private List<String> viewDetails;

@Parameter(name = ApiConstants.SHOW_RESOURCE_ICON, type = CommandType.BOOLEAN,
description = "flag to display the resource icon for domains")
private Boolean showIcon;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -105,6 +112,10 @@ public EnumSet<DomainDetails> getDetails() throws InvalidParameterValueException
return dv;
}

public Boolean getShowIcon() {
return showIcon != null ? showIcon : false;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand All @@ -119,5 +130,19 @@ public void execute() {
ListResponse<DomainResponse> response = _queryService.searchForDomains(this);
response.setResponseName(getCommandName());
this.setResponseObject(response);
if (response != null && response.getCount() > 0 && getShowIcon()) {
updateDomainResponse(response.getResponses());
}
}

private void updateDomainResponse(List<DomainResponse> response) {
for (DomainResponse domainResponse : response) {
ResourceIcon resourceIcon = resourceIconManager.getByResourceTypeAndUuid(ResourceTag.ResourceObjectType.Domain, domainResponse.getId());
if (resourceIcon == null) {
continue;
}
ResourceIconResponse iconResponse = _responseGenerator.createResourceIconResponse(resourceIcon);
domainResponse.setResourceIconResponse(iconResponse);
}
}
}
Loading