Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8a0b439
schema,server,api: events improvement
shwstppr Feb 11, 2022
aa0a0b8
Merge branch 'main' into events-improvement
shwstppr Feb 16, 2022
bdfa269
Merge branch 'main' into events-improvement
shwstppr Feb 22, 2022
3ac99db
wip
shwstppr Feb 25, 2022
f770ba6
refactor resourcetype association with API class
shwstppr Feb 25, 2022
c7af47f
add resource anme to the response
shwstppr Feb 25, 2022
31ef90b
Merge branch 'main' into events-improvement
shwstppr Mar 2, 2022
868dcc3
changes
shwstppr Mar 3, 2022
3a16daf
test
shwstppr Mar 3, 2022
4fa055b
more tests
shwstppr Mar 3, 2022
be0e9f1
new line
shwstppr Mar 3, 2022
4c154f2
add resource test
shwstppr Mar 4, 2022
4d5d1f1
changes
shwstppr Mar 7, 2022
7f6aa2a
fix
shwstppr Mar 7, 2022
cbdefc7
smoke test for events resource
shwstppr Mar 8, 2022
f4ca131
fix
shwstppr Mar 9, 2022
069dcd7
changes
shwstppr Mar 9, 2022
f23247b
fix
shwstppr Mar 10, 2022
634ed86
Merge branch 'main' into events-improvement
shwstppr Mar 10, 2022
9a48aac
Merge branch 'main' into events-improvement
shwstppr Mar 14, 2022
68e798f
ui improvements
shwstppr Mar 15, 2022
0b33e00
refactor
shwstppr Mar 15, 2022
724d41c
api,ui: add support for listing events for a resource
shwstppr Mar 15, 2022
a1f5fc0
since key
shwstppr Mar 16, 2022
1736caa
tests and permission changes
shwstppr Mar 16, 2022
b6bd32a
missing test
shwstppr Mar 16, 2022
cd5f01c
events for domain
shwstppr Mar 16, 2022
7bacc43
improvements
shwstppr Mar 17, 2022
6b49d6a
fix
shwstppr Mar 17, 2022
54610f8
Merge branch 'main' into events-improvement
shwstppr Mar 17, 2022
58c8e61
add missing license
shwstppr Mar 17, 2022
9252489
Merge branch 'main' into events-improvement
shwstppr Mar 30, 2022
d9a52b6
ui: fix js console errors
shwstppr Mar 30, 2022
3de1518
sort enumeration
shwstppr Mar 30, 2022
088d7e7
fix event resource for vpc
shwstppr Mar 30, 2022
bc31d84
feedback changes
shwstppr Mar 30, 2022
7db9e06
Merge branch 'main' into events-improvement
shwstppr Mar 30, 2022
905e86c
fix order
shwstppr Mar 30, 2022
ebc13ca
Merge branch 'main' into events-improvement
shwstppr Apr 4, 2022
17f9e67
events with parent resource
shwstppr Apr 8, 2022
3d89a28
missing UI labels
shwstppr Apr 8, 2022
e601dc5
donot call cmd resource methods before dispatch
shwstppr Apr 13, 2022
b9b80a8
add restore vm to procedure
shwstppr Apr 13, 2022
23ca819
Merge branch 'main' into events-improvement
shwstppr Apr 13, 2022
517ba36
add missing imports
shwstppr Apr 13, 2022
86e2170
resource details for more events
shwstppr Apr 18, 2022
03448b7
add test for changes
shwstppr Apr 19, 2022
74d09ca
more test, license fix
shwstppr Apr 19, 2022
50dc833
Merge branch 'main' into events-improvement
shwstppr Apr 20, 2022
4f174b0
wrong merge fix
shwstppr Apr 20, 2022
7d9cf1f
fix for more event types
shwstppr Apr 21, 2022
303353f
Merge branch 'main' into events-improvement
shwstppr Apr 22, 2022
488706b
Merge branch 'main' into events-improvement
shwstppr Apr 22, 2022
294b0b3
Merge branch 'main' into events-improvement
shwstppr Apr 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions api/src/main/java/com/cloud/event/ActionEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@
String eventType();

String eventDescription();

long resourceId() default -1;

String resourceType() default "";
}
4 changes: 4 additions & 0 deletions api/src/main/java/com/cloud/event/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public enum State {

String getDescription();

Long getResourceId();

String getResourceType();

Date getCreateDate();

long getUserId();
Expand Down
13 changes: 10 additions & 3 deletions api/src/main/java/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.cloudstack.acl.Role;
import org.apache.cloudstack.acl.RolePermission;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.annotation.Annotation;
import org.apache.cloudstack.api.response.ClusterResponse;
import org.apache.cloudstack.api.response.HostResponse;
Expand Down Expand Up @@ -63,6 +64,7 @@
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
Expand Down Expand Up @@ -972,9 +974,9 @@ public class EventTypes {
entityEventDetails.put(EVENT_VPC_RESTART, Vpc.class);

// VPC offerings
entityEventDetails.put(EVENT_VPC_OFFERING_CREATE, Vpc.class);
entityEventDetails.put(EVENT_VPC_OFFERING_UPDATE, Vpc.class);
entityEventDetails.put(EVENT_VPC_OFFERING_DELETE, Vpc.class);
entityEventDetails.put(EVENT_VPC_OFFERING_CREATE, VpcOffering.class);
entityEventDetails.put(EVENT_VPC_OFFERING_UPDATE, VpcOffering.class);
entityEventDetails.put(EVENT_VPC_OFFERING_DELETE, VpcOffering.class);

// Private gateway
entityEventDetails.put(EVENT_PRIVATE_GATEWAY_CREATE, PrivateGateway.class);
Expand Down Expand Up @@ -1014,6 +1016,11 @@ public class EventTypes {
entityEventDetails.put(EVENT_GUEST_VLAN_RANGE_DEDICATE, GuestVlan.class);
entityEventDetails.put(EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, GuestVlan.class);

entityEventDetails.put(EVENT_AFFINITY_GROUP_CREATE, AffinityGroup.class);
entityEventDetails.put(EVENT_AFFINITY_GROUP_DELETE, AffinityGroup.class);
entityEventDetails.put(EVENT_AFFINITY_GROUP_ASSIGN, AffinityGroup.class);
entityEventDetails.put(EVENT_AFFINITY_GROUP_REMOVE, AffinityGroup.class);

// OpenDaylight
entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_ADD_CONTROLLER, "OpenDaylightController");
entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_DELETE_CONTROLLER, "OpenDaylightController");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public interface Site2SiteVpnService {

Site2SiteVpnGateway getVpnGateway(Long vpnGatewayId);

Site2SiteCustomerGateway getCustomerGateway(Long customerGatewayId);

Site2SiteVpnConnection createVpnConnection(CreateVpnConnectionCmd cmd) throws NetworkRuleConflictException;

boolean deleteCustomerGateway(DeleteVpnCustomerGatewayCmd deleteVpnCustomerGatewayCmd);
Expand Down
58 changes: 0 additions & 58 deletions api/src/main/java/org/apache/cloudstack/api/ApiCommandJobType.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// 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;

import java.util.ArrayList;
import java.util.List;

import org.apache.cloudstack.region.PortableIp;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;

public enum ApiCommandResourceType {
None(null),
VirtualMachine(com.cloud.vm.VirtualMachine.class),
DomainRouter(com.cloud.network.router.VirtualRouter.class),
Volume(com.cloud.storage.Volume.class),
ConsoleProxy(com.cloud.vm.VirtualMachine.class),
Snapshot(com.cloud.storage.Snapshot.class),
Backup(org.apache.cloudstack.backup.Backup.class),
Template(com.cloud.template.VirtualMachineTemplate.class),
Iso(com.cloud.template.VirtualMachineTemplate.class),
SystemVm(com.cloud.vm.VirtualMachine.class),
Host(com.cloud.host.Host.class),
StoragePool(com.cloud.storage.StoragePool.class),
ImageStore(com.cloud.storage.ImageStore.class),
IpAddress(com.cloud.network.IpAddress.class),
PortableIpAddress(PortableIp.class),
SecurityGroup(com.cloud.network.security.SecurityGroup.class),
PhysicalNetwork(com.cloud.network.PhysicalNetwork.class),
TrafficType(com.cloud.network.PhysicalNetworkTrafficType.class),
PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider.class),
FirewallRule(com.cloud.network.rules.FirewallRule.class),
Account(com.cloud.user.Account.class),
User(com.cloud.user.User.class),
PrivateGateway(com.cloud.network.vpc.PrivateGateway.class),
StaticRoute(com.cloud.network.vpc.StaticRoute.class),
Counter(com.cloud.network.as.Counter.class),
Condition(com.cloud.network.as.Condition.class),
AutoScalePolicy(com.cloud.network.as.AutoScalePolicy.class),
AutoScaleVmProfile(com.cloud.network.as.AutoScaleVmProfile.class),
AutoScaleVmGroup(com.cloud.network.as.AutoScaleVmGroup.class),
GlobalLoadBalancerRule(com.cloud.region.ha.GlobalLoadBalancerRule.class),
LoadBalancerRule(com.cloud.network.lb.LoadBalancingRule.class),
AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup.class),
InternalLbVm(com.cloud.network.router.VirtualRouter.class),
DedicatedGuestVlanRange(com.cloud.network.GuestVlan.class),
GuestOs(com.cloud.storage.GuestOS.class),
GuestOsMapping(com.cloud.storage.GuestOSHypervisor.class),
Network(com.cloud.network.Network.class),
NetworkAcl(com.cloud.network.vpc.NetworkACL.class),
NetworkAclItem(com.cloud.network.vpc.NetworkACLItem.class),
Project(com.cloud.projects.Project.class),
Domain(com.cloud.domain.Domain.class),
DiskOffering(com.cloud.offering.DiskOffering.class),
ServiceOffering(com.cloud.offering.ServiceOffering.class),
NetworkOffering(com.cloud.offering.NetworkOffering.class),
VpcOffering(com.cloud.network.vpc.VpcOffering.class),
BackupOffering(org.apache.cloudstack.backup.BackupOffering.class),
Zone(com.cloud.dc.DataCenter.class),
Vpc(com.cloud.network.vpc.Vpc.class),
Cluster(com.cloud.org.Cluster.class),
Pod(com.cloud.dc.Pod.class),
VmSnapshot(com.cloud.vm.snapshot.VMSnapshot.class),
Role(org.apache.cloudstack.acl.Role.class),
VpnCustomerGateway(com.cloud.network.Site2SiteCustomerGateway.class);

private final Class<?> clazz;

private ApiCommandResourceType(Class<?> clazz) {
this.clazz = clazz;
}

public Class<?> getAssociatedClass() {
return this.clazz;
}

public static List<ApiCommandResourceType> valuesFromAssociatedClass(Class<?> clazz) {
List<ApiCommandResourceType> types = new ArrayList<>();
for (ApiCommandResourceType type : ApiCommandResourceType.values()) {
if (type.getAssociatedClass() == clazz) {
types.add(type);
}
}
return types;
}

public static ApiCommandResourceType valueFromAssociatedClass(Class<?> clazz) {
List<ApiCommandResourceType> types = valuesFromAssociatedClass(clazz);
return CollectionUtils.isEmpty(types) ? null : types.get(0);
}

@Override
public String toString() {
return this.name();
}

public static ApiCommandResourceType fromString(String value) {
if (StringUtils.isNotEmpty(value) && EnumUtils.isValidEnum(ApiCommandResourceType.class, value)) {
return valueOf(value);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ public class ApiConstants {
public static final String RECONNECT = "reconnect";
public static final String RECOVER = "recover";
public static final String REQUIRES_HVM = "requireshvm";
public static final String RESOURCE_NAME = "resourcename";
public static final String RESOURCE_TYPE = "resourcetype";
public static final String RESOURCE_TYPE_NAME = "resourcetypename";
public static final String RESPONSE = "response";
Expand Down
15 changes: 0 additions & 15 deletions api/src/main/java/org/apache/cloudstack/api/BaseAsyncCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,6 @@ public void setStartEventId(Long startEventId) {
this.startEventId = startEventId;
}

/**
* Async commands that want to be tracked as part of the listXXX commands need to
* provide implementations of the two following methods, getInstanceId() and getInstanceType()
*
* getObjectId() should return the id of the object the async command is executing on
* getObjectType() should return a type from the AsyncJob.Type enumeration
*/
public Long getInstanceId() {
return null;
}

public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.None;
}

public String getSyncObjType() {
return null;
}
Expand Down
27 changes: 22 additions & 5 deletions api/src/main/java/org/apache/cloudstack/api/BaseCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@

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 @@ -72,6 +67,11 @@
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.ResourceIconManager;
import com.cloud.server.ResourceManagerUtil;
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 @@ -430,4 +430,21 @@ private Object getEntityVO(Class entityType, Object entityId){
return null;
}

/**
* Commands that generate action events associated to a resource and
* async commands that want to be tracked as part of the listXXX commands
* need to provide implementations of the two following methods,
* getApiResourceId() and getApiResourceType()
*
* getApiResourceId() should return the id of the object the async command is executing on
* getApiResourceType() should return a type from the ApiCommandResourceType enumeration
*/
public Long getApiResourceId() {
return null;
}

public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.None;
}

}
5 changes: 0 additions & 5 deletions api/src/main/java/org/apache/cloudstack/api/BaseListCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ public Long getStartIndex() {
return startIndex;
}

@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.None;
}

@Override
public void validateSpecificParameters(final Map<String, String> params){
super.validateSpecificParameters(params);
Expand Down
2 changes: 0 additions & 2 deletions api/src/main/java/org/apache/cloudstack/api/IBaseListCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@ public interface IBaseListCmd {
Long getPageSizeVal();

Long getStartIndex();

ApiCommandJobType getInstanceType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Collection;
import java.util.Map;

import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

Expand Down Expand Up @@ -207,4 +208,9 @@ private void validateParams() {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Neither account type and role ID are not provided");
}
}

@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Account;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -110,12 +110,12 @@ public void execute() {
}

@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Account;
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Account;
}

@Override
public Long getInstanceId() {
public Long getApiResourceId() {
return id;
}
}
Loading