mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Some code fixes
This commit is contained in:
parent
3f8a54bdee
commit
dea5a24f1f
@ -36,11 +36,11 @@ import com.cloud.user.Account;
|
|||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.StringUtils;
|
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},
|
@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",
|
since = "4.18.1",
|
||||||
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User},
|
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
|
||||||
requestHasSensitiveInfo = false,
|
|
||||||
responseHasSensitiveInfo = true)
|
|
||||||
public class CheckAndRepairVolumeCmd extends BaseCmd {
|
public class CheckAndRepairVolumeCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(CheckAndRepairVolumeCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(CheckAndRepairVolumeCmd.class.getName());
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public class CheckAndRepairVolumeCmd extends BaseCmd {
|
|||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
public enum RepairValues {
|
public enum RepairValues {
|
||||||
leaks, all
|
Leaks, All
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -72,7 +72,7 @@ public class CheckAndRepairVolumeCmd extends BaseCmd {
|
|||||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(repair)) {
|
if (org.apache.commons.lang3.StringUtils.isNotEmpty(repair)) {
|
||||||
RepairValues repairType = Enum.valueOf(RepairValues.class, repair);
|
RepairValues repairType = Enum.valueOf(RepairValues.class, repair);
|
||||||
if (repairType == null) {
|
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;
|
return repair;
|
||||||
|
|||||||
@ -290,11 +290,11 @@ public class VolumeResponse extends BaseResponseWithTagInformation implements Co
|
|||||||
private String externalUuid;
|
private String externalUuid;
|
||||||
|
|
||||||
@SerializedName(ApiConstants.VOLUME_CHECK_RESULT)
|
@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;
|
private Map<String, String> volumeCheckResult;
|
||||||
|
|
||||||
@SerializedName(ApiConstants.VOLUME_REPAIR_RESULT)
|
@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;
|
private Map<String, String> volumeRepairResult;
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
|
|||||||
@ -2770,7 +2770,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
if (HypervisorType.KVM.equals(host.getHypervisorType()) && DataObjectType.VOLUME.equals(dataObject.getType())) {
|
if (HypervisorType.KVM.equals(host.getHypervisorType()) && DataObjectType.VOLUME.equals(dataObject.getType())) {
|
||||||
if (com.cloud.storage.VolumeApiServiceImpl.AllowCheckAndRepairVolume.value()) {
|
if (com.cloud.storage.VolumeApiServiceImpl.AllowCheckAndRepairVolume.value()) {
|
||||||
s_logger.info(String.format("Trying to check and repair the volume %d", dataObject.getId()));
|
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);
|
CheckAndRepairVolumePayload payload = new CheckAndRepairVolumePayload(repair);
|
||||||
VolumeInfo volumeInfo = volFactory.getVolume(dataObject.getId());
|
VolumeInfo volumeInfo = volFactory.getVolume(dataObject.getId());
|
||||||
volumeInfo.addPayload(payload);
|
volumeInfo.addPayload(payload);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user