Changed the API to Async and the setting scope to storage pool

This commit is contained in:
Harikrishna Patnala 2024-02-05 13:54:26 +05:30
parent e67c43497e
commit d80782b145
2 changed files with 14 additions and 3 deletions

View File

@ -16,13 +16,14 @@
// under the License.
package org.apache.cloudstack.api.command.user.volume;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -41,7 +42,7 @@ 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.19.1",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class CheckAndRepairVolumeCmd extends BaseCmd {
public class CheckAndRepairVolumeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CheckAndRepairVolumeCmd.class.getName());
private static final String s_name = "checkandrepairvolumeresponse";
@ -98,6 +99,16 @@ public class CheckAndRepairVolumeCmd extends BaseCmd {
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public String getEventType() {
return EventTypes.EVENT_VOLUME_CHECK;
}
@Override
public String getEventDescription() {
return String.format("check and repair operation on volume: %s", this._uuidMgr.getUuid(Volume.class, getId()));
}
@Override
public Long getApiResourceId() {
return id;

View File

@ -382,7 +382,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
+ " in milliseconds, to execute a storage tag rule; if it is reached, a timeout will happen.", true);
public static final ConfigKey<Boolean> AllowCheckAndRepairVolume = new ConfigKey<Boolean>("Advanced", Boolean.class, "volume.check.and.repair.leaks.before.use", "false",
"To check and repair the volume if it has any leaks before performing volume attach or VM start operations", true);
"To check and repair the volume if it has any leaks before performing volume attach or VM start operations", true, ConfigKey.Scope.StoragePool);
private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;