Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/BaseCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Pattern;

import javax.inject.Inject;
Expand Down Expand Up @@ -498,4 +499,14 @@ public Map<String, String> convertExternalDetailsToMap(Map externalDetails) {
}
return details;
}

public String getResourceUuid(String parameterName) {
UUID resourceUuid = CallContext.current().getApiResourceUuid(parameterName);

if (resourceUuid != null) {
return resourceUuid.toString();
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public long getEntityOwnerId() {
@Override
public void execute() {
validateParams();
CallContext.current().setEventDetails("Account Name: " + getUsername() + ", Domain Id:" + getDomainId());
CallContext.current().setEventDetails("Account Name: " + getUsername() + ", Domain ID:" + getResourceUuid(ApiConstants.DOMAIN_ID));
UserAccount userAccount =
_accountService.createUserAccount(this);
if (userAccount != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,20 @@ public long getEntityOwnerId() {

@Override
public String getEventDescription() {
return "Disabling Account: " + getAccountName() + " in domain: " + getDomainId();
String message = "Disabling Account ";

if (getId() != null) {
message += "with ID: " + getResourceUuid(ApiConstants.ID);
} else {
message += getAccountName() + " in Domain: " + getResourceUuid(ApiConstants.DOMAIN_ID);
}

return message;
}

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
CallContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getDomainId());
CallContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getResourceUuid(ApiConstants.DOMAIN_ID));
Account result = _regionService.disableAccount(this);
if (result != null){
AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void execute() {
if (role == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role id provided");
}
CallContext.current().setEventDetails("Role id: " + role.getId() + ", rule:" + getRule() + ", permission: " + getPermission() + ", description: " + getDescription());
CallContext.current().setEventDetails("Role ID: " + role.getUuid() + ", rule:" + getRule() + ", permission: " + getPermission() + ", description: " + getDescription());
final RolePermission rolePermission = roleService.createRolePermission(role, getRule(), getPermission(), getDescription());
if (rolePermission == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create role permission");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void execute() {
if (role == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Cannot find the role with provided id");
}
CallContext.current().setEventDetails("Role id: " + role.getId());
CallContext.current().setEventDetails("Role ID: " + role.getUuid());
boolean result = roleService.deleteRole(role);
SuccessResponse response = new SuccessResponse(getCommandName());
response.setSuccess(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void execute() {
if (rolePermission == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role permission id provided");
}
CallContext.current().setEventDetails("Role permission id: " + rolePermission.getId());
CallContext.current().setEventDetails("Role permission ID: " + rolePermission.getUuid());
boolean result = roleService.deleteRolePermission(rolePermission);
SuccessResponse response = new SuccessResponse(getCommandName());
response.setSuccess(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
if (role == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Cannot find the role with provided id");
}
CallContext.current().setEventDetails("Role id: " + role.getId());
CallContext.current().setEventDetails("Role ID: " + role.getUuid());
boolean result = roleService.disableRole(role);
SuccessResponse response = new SuccessResponse(getCommandName());
response.setSuccess(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
if (role == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Cannot find the role with provided id");
}
CallContext.current().setEventDetails("Role id: " + role.getId());
CallContext.current().setEventDetails("Role ID: " + role.getUuid());
boolean result = roleService.enableRole(role);
SuccessResponse response = new SuccessResponse(getCommandName());
response.setSuccess(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void execute() {
if (getRuleId() != null || getRulePermission() != null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Parameters permission and ruleid must be mutually exclusive with ruleorder");
}
CallContext.current().setEventDetails("Reordering permissions for role id: " + role.getId());
CallContext.current().setEventDetails("Reordering permissions for role with ID: " + role.getUuid());
final List<RolePermission> rolePermissionsOrder = new ArrayList<>();
for (Long rolePermissionId : getRulePermissionOrder()) {
final RolePermission rolePermission = roleService.findRolePermission(rolePermissionId);
Expand All @@ -129,7 +129,7 @@ public void execute() {
if (rolePermission == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid rule id provided");
}
CallContext.current().setEventDetails("Updating permission for rule id: " + getRuleId() + " to: " + getRulePermission().toString());
CallContext.current().setEventDetails("Updating permission for rule with ID: " + getResourceUuid(ApiConstants.RULE_ID) + " to: " + getRulePermission().toString());
result = roleService.updateRolePermission(role, rolePermission, getRulePermission());
}
SuccessResponse response = new SuccessResponse(getCommandName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void execute() {
if (projectRole == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid project role ID provided");
}
CallContext.current().setEventDetails("Project Role ID: " + projectRole.getId() + ", Rule:" + getRule() + ", Permission: " + getPermission() + ", Description: " + getDescription());
CallContext.current().setEventDetails("Project Role ID: " + projectRole.getUuid() + ", Rule:" + getRule() + ", Permission: " + getPermission() + ", Description: " + getDescription());
final ProjectRolePermission projectRolePermission = projRoleService.createProjectRolePermission(this);
if (projectRolePermission == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create project role permission");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void execute() {
if (role == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Cannot find project role with provided id");
}
CallContext.current().setEventDetails("Deleting Project Role with id: " + role.getId());
CallContext.current().setEventDetails("Deleting Project Role with ID: " + role.getUuid());
boolean result = projRoleService.deleteProjectRole(role, getProjectId());
SuccessResponse response = new SuccessResponse(getCommandName());
response.setSuccess(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void execute() {
if (rolePermission == null || rolePermission.getProjectId() != getProjectId()) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role permission id provided for the project");
}
CallContext.current().setEventDetails("Deleting Project Role permission with id: " + rolePermission.getId());
CallContext.current().setEventDetails("Deleting Project Role permission with ID: " + rolePermission.getUuid());
boolean result = projRoleService.deleteProjectRolePermission(rolePermission);
SuccessResponse response = new SuccessResponse();
response.setSuccess(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ public void execute() {
if (getProjectRuleId() != null || getProjectRolePermission() != null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Parameters permission and ruleid must be mutually exclusive with ruleorder");
}
CallContext.current().setEventDetails("Reordering permissions for role id: " + projectRole.getId());
CallContext.current().setEventDetails("Reordering permissions for role with ID: " + projectRole.getUuid());
result = updateProjectRolePermissionOrder(projectRole);

} else if (getProjectRuleId() != null || getProjectRolePermission() != null ) {
if (getProjectRulePermissionOrder() != null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Parameters permission and ruleid must be mutually exclusive with ruleorder");
}
ProjectRolePermission rolePermission = getValidProjectRolePermission();
CallContext.current().setEventDetails("Updating project role permission for rule id: " + getProjectRuleId() + " to: " + getProjectRolePermission().toString());
CallContext.current().setEventDetails("Updating project role permission for rule ID: " + getProjectRuleId() + " to: " + getProjectRolePermission().toString());
result = projRoleService.updateProjectRolePermission(projectId, projectRole, rolePermission, getProjectRolePermission());
}
SuccessResponse response = new SuccessResponse(getCommandName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void create() {

@Override
public void execute() {
CallContext.current().setEventDetails("Counter ID: " + getEntityId());
CallContext.current().setEventDetails("Counter ID: " + getEntityUuid());
Counter ctr = _autoScaleService.getCounter(getEntityId());
CounterResponse response = _responseGenerator.createCounterResponse(ctr);
response.setResponseName(getCommandName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ public String getEventType() {

@Override
public String getEventDescription() {
return "Deleting a counter.";
return "Deleting auto scaling counter with ID: " + getResourceUuid(ApiConstants.ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ public String getEventType() {

@Override
public String getEventDescription() {
return "Importing backup offering: " + name + " (external ID: " + externalId + ") on zone ID " + zoneId ;
return "Importing backup offering: " + name + " (external ID: " + externalId + ") on zone with ID: " + getResourceUuid(ApiConstants.ZONE_ID) ;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,6 @@ public String getEventType() {

@Override
public String getEventDescription() {
return "issuing certificate for domain(s)=" + domains + ", ip(s)=" + addresses;
return "Issuing certificate for domain(s)=" + domains + ", ip(s)=" + addresses;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public String getEventType() {

@Override
public String getEventDescription() {
return "Provisioning certificate for host id=" + hostId + " using provider=" + provider;
return "Provisioning certificate for host with ID: " + getResourceUuid(ApiConstants.HOST_ID) + " using provider: " + provider;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ public String getEventType() {

@Override
public String getEventDescription() {
return String.format("Executing DRS plan for cluster: %d", getId());
return "Executing DRS plan for cluster with ID: " + getResourceUuid(ApiConstants.ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public String getEventType() {

@Override
public String getEventDescription() {
return "Getting diagnostics data files from System VM: " + this._uuidMgr.getUuid(VirtualMachine.class, getId());
return "Getting diagnostics data files from System Instance with ID: " + getResourceUuid(ApiConstants.TARGET_ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public ApiCommandResourceType getApiResourceType() {

@Override
public String getEventDescription() {
return "Executing diagnostics on System VM: " + this._uuidMgr.getUuid(VirtualMachine.class, getId());
return "Executing diagnostics on System Instance with ID: " + getResourceUuid(ApiConstants.TARGET_ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public long getEntityOwnerId() {

@Override
public void execute() {
CallContext.current().setEventDetails("Domain Name: " + getDomainName() + ((getParentDomainId() != null) ? ", Parent DomainId :" + getParentDomainId() : ""));
CallContext.current().setEventDetails("Domain Name: " + getDomainName() + ((getParentDomainId() != null) ? ", Parent Domain ID:" + getResourceUuid(ApiConstants.PARENT_DOMAIN_ID) : ""));
Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID());
if (domain != null) {
DomainResponse response = _responseGenerator.createDomainResponse(domain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ public String getEventType() {

@Override
public String getEventDescription() {
return "Deleting domain: " + getId();
return "Deleting domain with ID: " + getResourceUuid(ApiConstants.ID);
}

@Override
public void execute() {
CallContext.current().setEventDetails("Domain Id: " + getId());
CallContext.current().setEventDetails("Domain ID: " + getResourceUuid(ApiConstants.ID));
boolean result = _regionService.deleteDomain(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public long getEntityOwnerId() {

@Override
public void execute() {
CallContext.current().setEventDetails("Domain Id: " + getId());
CallContext.current().setEventDetails("Domain ID: " + getResourceUuid(ApiConstants.ID));
Domain domain = _regionService.updateDomain(this);

if (domain != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class DiscoverGpuDevicesCmd extends BaseListCmd {

@Override
public void execute() {
CallContext.current().setEventDetails("Discovering GPU Devices on host id: " + getId());
CallContext.current().setEventDetails("Discovering GPU Devices on host with ID: " + getResourceUuid(ApiConstants.ID));
ListResponse<GpuDeviceResponse> response = gpuService.discoverGpuDevices(this);
response.setResponseName(getCommandName());
setResponseObject(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void create() {

@Override
public void execute() {
CallContext.current().setEventDetails("Guest OS Id: " + getEntityId());
CallContext.current().setEventDetails("Guest OS ID: " + getEntityUuid());
GuestOS guestOs = _mgr.getAddedGuestOs(getEntityId());
if (guestOs != null) {
GuestOSResponse response = _responseGenerator.createGuestOSResponse(guestOs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public long getEntityOwnerId() {

@Override
public void execute() {
CallContext.current().setEventDetails("Guest OS Id: " + id);
CallContext.current().setEventDetails("Guest OS ID: " + getResourceUuid(ApiConstants.ID));
boolean result = _mgr.removeGuestOs(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
Expand All @@ -74,7 +74,7 @@ public void execute() {

@Override
public String getEventDescription() {
return "Removing Guest OS: " + getId();
return "Removing Guest OS with ID: " + getResourceUuid(ApiConstants.ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public long getEntityOwnerId() {

@Override
public void execute() {
CallContext.current().setEventDetails("Guest OS Mapping Id: " + id);
CallContext.current().setEventDetails("Guest OS Mapping ID: " + getResourceUuid(ApiConstants.ID));
boolean result = _mgr.removeGuestOsMapping(this);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
Expand All @@ -74,7 +74,7 @@ public void execute() {

@Override
public String getEventDescription() {
return "Removing Guest OS Mapping: " + getId();
return "Removing Guest OS Mapping with ID: " + getResourceUuid(ApiConstants.ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void execute() {

@Override
public String getEventDescription() {
return "Updating guest OS: " + getId();
return "Updating guest OS with ID: " + getResourceUuid(ApiConstants.ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public long getEntityOwnerId() {

@Override
public String getEventDescription() {
return "Updating Guest OS Mapping: " + getId();
return "Updating Guest OS with ID: " + getResourceUuid(ApiConstants.ID) + " mapping.";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
if (!result) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure HA provider for the host");
}
CallContext.current().setEventDetails("Host Id:" + host.getId() + " HA configured with provider: " + getHaProvider());
CallContext.current().setEventDetails("Host ID:" + host.getUuid() + " HA configured with provider: " + getHaProvider());
CallContext.current().putContextParameter(Host.class, host.getUuid());

setupResponse(result, host.getUuid());
Expand All @@ -115,6 +115,6 @@ public String getEventType() {

@Override
public String getEventDescription() {
return "Configure HA for host: " + getHostId();
return "Configuring HA for host with ID: " + getResourceUuid(ApiConstants.HOST_ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find cluster by ID: " + getClusterId());
}
final boolean result = haConfigManager.disableHA(cluster);
CallContext.current().setEventDetails("Cluster Id:" + cluster.getId() + " HA enabled: false");
CallContext.current().setEventDetails("Cluster ID:" + cluster.getUuid() + " HA enabled: false");
CallContext.current().putContextParameter(Cluster.class, cluster.getUuid());

setupResponse(result);
Expand All @@ -102,7 +102,7 @@ public String getEventType() {

@Override
public String getEventDescription() {
return "Disable HA for cluster: " + getClusterId();
return "Disabling HA for cluster with ID: " + getResourceUuid(ApiConstants.CLUSTER_ID);
}

}
Loading
Loading