Skip to content

Commit 745ba5c

Browse files
nitinmehDaanHoogland
authored andcommitted
CLOUDSTACK-6895: 1. Populate firstclass entities as uuids in the context instead of dbids for performance.
2. Add ctxDetails in the ParamGenericValidationWorker to avoid warning for api validation 3. Add some missing events. 4. Correcting mapping for ResourceObjectType.NetworkACL and ResourceObjectType.NetworkACLItem (cherry picked from commit 8a9092c)
1 parent f657de5 commit 745ba5c

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

‎api/src/com/cloud/event/EventTypes.java‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
import java.util.Map;
2121

2222
import com.cloud.network.IpAddress;
23+
import com.cloud.network.Site2SiteCustomerGateway;
2324
import com.cloud.network.Site2SiteVpnGateway;
2425
import com.cloud.network.rules.FirewallRule;
2526
import com.cloud.network.rules.HealthCheckPolicy;
2627
import com.cloud.network.rules.StickinessPolicy;
2728
import com.cloud.network.vpc.NetworkACL;
2829
import com.cloud.network.vpc.NetworkACLItem;
30+
import com.cloud.network.Site2SiteVpnConnection;
2931
import com.cloud.server.ResourceTag;
3032
import com.cloud.vm.ConsoleProxy;
3133
import com.cloud.vm.SecondaryStorageVm;
@@ -572,7 +574,7 @@ public class EventTypes {
572574
entityEventDetails.put(EVENT_ASSIGN_TO_LOAD_BALANCER_RULE, FirewallRule.class);
573575
entityEventDetails.put(EVENT_REMOVE_FROM_LOAD_BALANCER_RULE, FirewallRule.class);
574576
entityEventDetails.put(EVENT_LOAD_BALANCER_CREATE, LoadBalancer.class);
575-
entityEventDetails.put(EVENT_LOAD_BALANCER_DELETE, LoadBalancer.class);
577+
entityEventDetails.put(EVENT_LOAD_BALANCER_DELETE, FirewallRule.class);
576578
entityEventDetails.put(EVENT_LB_STICKINESSPOLICY_CREATE, StickinessPolicy.class);
577579
entityEventDetails.put(EVENT_LB_STICKINESSPOLICY_UPDATE, StickinessPolicy.class);
578580
entityEventDetails.put(EVENT_LB_STICKINESSPOLICY_DELETE, StickinessPolicy.class);
@@ -720,12 +722,12 @@ public class EventTypes {
720722
entityEventDetails.put(EVENT_VPN_USER_REMOVE, RemoteAccessVpn.class);
721723
entityEventDetails.put(EVENT_S2S_VPN_GATEWAY_CREATE, Site2SiteVpnGateway.class);
722724
entityEventDetails.put(EVENT_S2S_VPN_GATEWAY_DELETE, Site2SiteVpnGateway.class);
723-
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_CREATE, RemoteAccessVpn.class);
724-
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_DELETE, RemoteAccessVpn.class);
725-
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_UPDATE, RemoteAccessVpn.class);
726-
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_CREATE, RemoteAccessVpn.class);
727-
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_DELETE, RemoteAccessVpn.class);
728-
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_RESET, RemoteAccessVpn.class);
725+
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_CREATE, Site2SiteCustomerGateway.class);
726+
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_DELETE, Site2SiteCustomerGateway.class);
727+
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_UPDATE, Site2SiteCustomerGateway.class);
728+
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_CREATE, Site2SiteVpnConnection.class);
729+
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_DELETE, Site2SiteVpnConnection.class);
730+
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_RESET, Site2SiteVpnConnection.class);
729731

730732
// Custom certificates
731733
entityEventDetails.put(EVENT_UPLOAD_CUSTOM_CERTIFICATE, "Certificate");

‎api/src/org/apache/cloudstack/api/BaseCmd.java‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public boolean isDisplay(){
371371
Object key = entry.getKey();
372372
Class clz = Class.forName((String)key);
373373
if(Displayable.class.isAssignableFrom(clz)){
374-
final Object objVO = _entityMgr.findById(clz, getInternalId(entry.getValue()));
374+
final Object objVO = getEntityVO(clz, entry.getValue());
375375
isDisplay = ((Displayable) objVO).isDisplay();
376376
}
377377

@@ -388,17 +388,25 @@ public boolean isDisplay(){
388388

389389
}
390390

391-
private static Long getInternalId(Object internalIdObj){
392-
Long internalId = null;
391+
private Object getEntityVO(Class entityType, Object entityId){
393392

394-
// In case its an async job the value would be a string because of json deserialization
395-
if(internalIdObj instanceof String){
396-
internalId = Long.valueOf((String) internalIdObj);
397-
}else if (internalIdObj instanceof Long){
398-
internalId = (Long) internalIdObj;
393+
// entityId can be internal db id or UUID so accordingly call findbyId or findByUUID
394+
395+
if (entityId instanceof Long){
396+
// Its internal db id - use findById
397+
return _entityMgr.findById(entityType, (Long)entityId);
398+
} else if(entityId instanceof String){
399+
try{
400+
// In case its an async job the internal db id would be a string because of json deserialization
401+
Long internalId = Long.valueOf((String) entityId);
402+
return _entityMgr.findById(entityType, internalId);
403+
} catch (NumberFormatException e){
404+
// It is uuid - use findByUuid`
405+
return _entityMgr.findByUuid(entityType, (String)entityId);
406+
}
399407
}
400408

401-
return internalId;
409+
return null;
402410
}
403411

404412
}

0 commit comments

Comments
 (0)