normalize descriptions to use string contatenation and enhance some descriptions

This commit is contained in:
erikbocks 2026-01-20 09:47:44 -03:00
parent 3381c7d7c0
commit 1cb2f1b875
11 changed files with 35 additions and 47 deletions

View File

@ -115,7 +115,7 @@ public class MigrateNetworkCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
StringBuilder eventMsg = new StringBuilder("Migrating network with ID: " + getResourceUuid(ApiConstants.NETWORK_ID));
String description = "Migrating network with ID: " + getResourceUuid(ApiConstants.NETWORK_ID);
if (getNetworkOfferingId() != null) {
Network network = _networkService.getNetwork(getId());
if (network == null) {
@ -128,11 +128,11 @@ public class MigrateNetworkCmd extends BaseAsyncCmd {
throw new InvalidParameterValueException("Network offering id supplied is invalid");
}
eventMsg.append(". Original network offering id: " + oldOff.getUuid() + ", new network offering id: " + newOff.getUuid());
description += ". Original network offering id: " + oldOff.getUuid() + ", new network offering id: " + newOff.getUuid();
}
}
return eventMsg.toString();
return description;
}
@Override

View File

@ -124,15 +124,15 @@ public class MigrateVMCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
String eventDescription;
String description = "Attempting to migrate Instance with ID: " + getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID);
if (getHostId() != null) {
eventDescription = String.format("Attempting to migrate Instance with ID: %s to host with ID: %s", getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID), getResourceUuid(ApiConstants.HOST_ID));
description += " to host with ID: " +getResourceUuid(ApiConstants.HOST_ID);
} else if (getStoragePoolId() != null) {
eventDescription = String.format("Attempting to migrate Instance with ID: %s to storage pool with ID: %s", getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID), getResourceUuid(ApiConstants.STORAGE_ID));
} else {
eventDescription = String.format("Attempting to migrate Instance with ID: %s", getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID));
description = " to storage pool with ID: " + getResourceUuid(ApiConstants.STORAGE_ID);
}
return eventDescription;
return description;
}
@Override

View File

@ -81,7 +81,7 @@ public class UnmanageVolumeCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
return String.format("Unmanaging Volume with ID %s", getResourceUuid(ApiConstants.ID));
return "Unmanaging Volume with ID: " + getResourceUuid(ApiConstants.ID);
}
/////////////////////////////////////////////////////

View File

@ -136,21 +136,21 @@ public class CopyTemplateCmd extends BaseAsyncCmd implements UserCmd {
@Override
public String getEventDescription() {
StringBuilder descBuilder = new StringBuilder("Copying template: " + getResourceUuid(ApiConstants.ID));
String description = "Copying template: " + getResourceUuid(ApiConstants.ID);
if (getSourceZoneId() != null) {
descBuilder.append(" from zone: ").append(getResourceUuid(ApiConstants.SOURCE_ZONE_ID));
description += " from zone: " + getResourceUuid(ApiConstants.SOURCE_ZONE_ID);
}
if (getDestinationZoneIds() != null) {
descBuilder.append(" to zones: ");
description += " to zones: ";
for (Long destId : getDestinationZoneIds()) {
descBuilder.append(this._uuidMgr.getUuid(DataCenter.class, destId));
descBuilder.append(", ");
description += this._uuidMgr.getUuid(DataCenter.class, destId);
description += ", ";
}
}
return descBuilder.toString();
return description;
}
@Override

View File

@ -100,14 +100,14 @@ public class ExtractTemplateCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
String baseDescription = String.format("Extracting Template with ID: %s", getResourceUuid(ApiConstants.ID));
String description = "Extracting Template with ID: " + getResourceUuid(ApiConstants.ID);
Long zoneId = getZoneId();
if (zoneId == null) {
return baseDescription;
if (zoneId != null) {
description += "from zone with ID: " + getResourceUuid(ApiConstants.ZONE_ID);
}
return String.format("%s from zone with ID: %s", baseDescription, getResourceUuid(ApiConstants.ZONE_ID));
return description;
}
@Override

View File

@ -105,7 +105,7 @@ public class CheckAndRepairVolumeCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
return String.format("Starting checking and repairing operation on volume: %s", getResourceUuid(ApiConstants.ID));
return "Starting checking and repairing operation on volume: " + getResourceUuid(ApiConstants.ID);
}
@Override

View File

@ -38,7 +38,7 @@ import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
import com.cloud.vm.VirtualMachine;
@APICommand(name = "detachVolume", description = "Detaches a disk volume from an Instance.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
@APICommand(name = "detachVolume", description = "Detaches a disk volume from an Instance.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class DetachVolumeCmd extends BaseAsyncCmd implements UserCmd {
private static final String s_name = "detachvolumeresponse";
@ -126,17 +126,19 @@ public class DetachVolumeCmd extends BaseAsyncCmd implements UserCmd {
@Override
public String getEventDescription() {
StringBuilder sb = new StringBuilder("Detaching volume");
String description = "Detaching volume";
if (id != null) {
sb.append(": ").append(getResourceUuid(ApiConstants.ID));
} else if ((deviceId != null) && (virtualMachineId != null)) {
sb.append(" with device id: " + deviceId + " from Instance: " + ((getVirtualMachineId() != null) ? getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID) : ""));
} else {
sb.append(" <error: either volume id or deviceId/vmId need to be specified>");
description += ": " + getResourceUuid(ApiConstants.ID);
}
return sb.toString();
if ((deviceId != null) && (virtualMachineId != null)) {
description += " with device id: " + deviceId + " from Instance: " + getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID);
} else {
description += " <error: either volume id or deviceId/vmId need to be specified>";
}
return description;
}
@Override

View File

@ -99,7 +99,7 @@ public class AddNodesToKubernetesClusterCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
return String.format("Adding %s nodes to the Kubernetes cluster with ID: %s", nodeIds.size(), getResourceUuid(ApiConstants.ID));
return "Adding " + nodeIds.size() + " nodes to Kubernetes cluster with ID: " + getResourceUuid(ApiConstants.ID);
}
@Override

View File

@ -126,14 +126,7 @@ public class DeleteKubernetesClusterCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
String description = "Deleting Kubernetes cluster";
KubernetesCluster cluster = _entityMgr.findById(KubernetesCluster.class, getId());
if (cluster != null) {
description += String.format(" with ID: %s", cluster.getUuid());
} else {
description += String.format(" with ID: %s", getResourceUuid(ApiConstants.ID));
}
return description;
return "Deleting Kubernetes cluster with ID: " + getResourceUuid(ApiConstants.ID);
}
}

View File

@ -89,7 +89,7 @@ public class RemoveNodesFromKubernetesClusterCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
return String.format("Removing %s nodes from the Kubernetes Cluster with ID: %s", nodeIds.size(), getResourceUuid(ApiConstants.ID));
return "Removing " + nodeIds.size() + " nodes from the Kubernetes Cluster with ID: " + getResourceUuid(ApiConstants.ID);
}
@Override

View File

@ -82,14 +82,7 @@ public class UpgradeKubernetesClusterCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
String description = "Upgrading Kubernetes cluster";
KubernetesCluster cluster = _entityMgr.findById(KubernetesCluster.class, getId());
if (cluster != null) {
description += String.format(" ID: %s", cluster.getUuid());
} else {
description += String.format(" ID: %d", getResourceUuid(ApiConstants.ID));
}
return description;
return "Upgrading Kubernetes cluster with ID: " + getResourceUuid(ApiConstants.ID);
}
@Override