Some code fixes

This commit is contained in:
Harikrishna Patnala 2024-01-29 16:21:34 +05:30
parent 3f8a54bdee
commit dea5a24f1f
3 changed files with 8 additions and 8 deletions

View File

@ -36,11 +36,11 @@ import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.utils.StringUtils;
import java.util.Arrays;
@APICommand(name = "checkVolume", description = "Check the volume for any errors or leaks and also repairs when repair parameter is passed, this is currently supported for KVM only", responseObject = VolumeResponse.class, entityType = {Volume.class},
since = "4.18.1",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User},
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = true)
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class CheckAndRepairVolumeCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CheckAndRepairVolumeCmd.class.getName());
@ -61,7 +61,7 @@ public class CheckAndRepairVolumeCmd extends BaseCmd {
/////////////////////////////////////////////////////
public enum RepairValues {
leaks, all
Leaks, All
}
public Long getId() {
@ -72,7 +72,7 @@ public class CheckAndRepairVolumeCmd extends BaseCmd {
if (org.apache.commons.lang3.StringUtils.isNotEmpty(repair)) {
RepairValues repairType = Enum.valueOf(RepairValues.class, repair);
if (repairType == null) {
throw new InvalidParameterValueException("repair parameter only takes either leaks or all as value");
throw new InvalidParameterValueException(String.format("Repair parameter can only take the following values: %s" + Arrays.toString(RepairValues.values())));
}
}
return repair;

View File

@ -290,11 +290,11 @@ public class VolumeResponse extends BaseResponseWithTagInformation implements Co
private String externalUuid;
@SerializedName(ApiConstants.VOLUME_CHECK_RESULT)
@Param(description = "details for the volume check result, they may vary for different hypervisors")
@Param(description = "details for the volume check result, they may vary for different hypervisors, since = 4.18.1")
private Map<String, String> volumeCheckResult;
@SerializedName(ApiConstants.VOLUME_REPAIR_RESULT)
@Param(description = "details for the volume repair result, they may vary for different hypervisors")
@Param(description = "details for the volume repair result, they may vary for different hypervisors, since = 4.18.1")
private Map<String, String> volumeRepairResult;
public String getPath() {

View File

@ -2770,7 +2770,7 @@ public class VolumeServiceImpl implements VolumeService {
if (HypervisorType.KVM.equals(host.getHypervisorType()) && DataObjectType.VOLUME.equals(dataObject.getType())) {
if (com.cloud.storage.VolumeApiServiceImpl.AllowCheckAndRepairVolume.value()) {
s_logger.info(String.format("Trying to check and repair the volume %d", dataObject.getId()));
String repair = CheckAndRepairVolumeCmd.RepairValues.leaks.name();
String repair = CheckAndRepairVolumeCmd.RepairValues.Leaks.name();
CheckAndRepairVolumePayload payload = new CheckAndRepairVolumePayload(repair);
VolumeInfo volumeInfo = volFactory.getVolume(dataObject.getId());
volumeInfo.addPayload(payload);