Skip to content

Commit 98ae513

Browse files
authored
validates the inputs for capacity bytes in update storage pool to be positive (#14219)
1 parent af9764b commit 98ae513

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎api/src/main/java/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import java.net.UnknownHostException;
2020
import java.util.Map;
2121

22-
2322
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.ApiArgValidator;
2424
import org.apache.cloudstack.api.ApiConstants;
2525
import org.apache.cloudstack.api.ApiErrorCode;
2626
import org.apache.cloudstack.api.BaseCmd;
@@ -80,10 +80,10 @@ public class CreateStoragePoolCmd extends BaseCmd {
8080
@Parameter(name = ApiConstants.MANAGED, type = CommandType.BOOLEAN, required = false, description = "Whether the storage should be managed by CloudStack")
8181
private Boolean managed;
8282

83-
@Parameter(name = ApiConstants.CAPACITY_IOPS, type = CommandType.LONG, required = false, description = "IOPS CloudStack can provision from this storage pool")
83+
@Parameter(name = ApiConstants.CAPACITY_IOPS, type = CommandType.LONG, required = false, description = "IOPS CloudStack can provision from this storage pool", validations = {ApiArgValidator.PositiveNumber})
8484
private Long capacityIops;
8585

86-
@Parameter(name = ApiConstants.CAPACITY_BYTES, type = CommandType.LONG, required = false, description = "Bytes CloudStack can provision from this storage pool")
86+
@Parameter(name = ApiConstants.CAPACITY_BYTES, type = CommandType.LONG, required = false, description = "Bytes CloudStack can provision from this storage pool", validations = {ApiArgValidator.PositiveNumber})
8787
private Long capacityBytes;
8888

8989
@Parameter(name = ApiConstants.HYPERVISOR,

‎api/src/main/java/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22-
import org.apache.cloudstack.api.ApiCommandResourceType;
23-
2422
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.ApiArgValidator;
24+
import org.apache.cloudstack.api.ApiCommandResourceType;
2525
import org.apache.cloudstack.api.ApiConstants;
2626
import org.apache.cloudstack.api.ApiErrorCode;
2727
import org.apache.cloudstack.api.BaseCmd;
2828
import org.apache.cloudstack.api.Parameter;
2929
import org.apache.cloudstack.api.ServerApiException;
3030
import org.apache.cloudstack.api.response.StoragePoolResponse;
31+
import org.apache.commons.collections.MapUtils;
32+
import org.apache.commons.lang3.ObjectUtils;
3133

3234
import com.cloud.storage.StoragePool;
3335
import com.cloud.user.Account;
34-
import org.apache.commons.collections.MapUtils;
35-
import org.apache.commons.lang3.ObjectUtils;
3636

3737
@SuppressWarnings("rawtypes")
3838
@APICommand(name = "updateStoragePool", description = "Updates a storage pool.", responseObject = StoragePoolResponse.class, since = "3.0.0",
@@ -53,10 +53,10 @@ public class UpdateStoragePoolCmd extends BaseCmd {
5353
@Parameter(name = ApiConstants.TAGS, type = CommandType.LIST, collectionType = CommandType.STRING, description = "Comma-separated list of tags for the storage pool")
5454
private List<String> tags;
5555

56-
@Parameter(name = ApiConstants.CAPACITY_IOPS, type = CommandType.LONG, required = false, description = "IOPS CloudStack can provision from this storage pool")
56+
@Parameter(name = ApiConstants.CAPACITY_IOPS, type = CommandType.LONG, required = false, description = "IOPS CloudStack can provision from this storage pool", validations={ApiArgValidator.PositiveNumber})
5757
private Long capacityIops;
5858

59-
@Parameter(name = ApiConstants.CAPACITY_BYTES, type = CommandType.LONG, required = false, description = "Bytes CloudStack can provision from this storage pool")
59+
@Parameter(name = ApiConstants.CAPACITY_BYTES, type = CommandType.LONG, required = false, description = "Bytes CloudStack can provision from this storage pool",validations={ApiArgValidator.PositiveNumber})
6060
private Long capacityBytes;
6161

6262
@Parameter(name = ApiConstants.ENABLED, type = CommandType.BOOLEAN, required = false, description = "False to disable the pool for allocation of new volumes, true to" +

0 commit comments

Comments
 (0)