mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
storagetype API param in list service/disk offerings (#8215)
This commit is contained in:
parent
96b07d797b
commit
04061f12e5
@ -25,6 +25,7 @@ import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListDomainResourcesCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.BaseCmd.CommandType;
|
||||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
|
||||
@ -60,6 +61,12 @@ public class ListDiskOfferingsCmd extends BaseListDomainResourcesCmd {
|
||||
@Parameter(name = ApiConstants.ENCRYPT, type = CommandType.BOOLEAN, description = "listed offerings support disk encryption", since = "4.18")
|
||||
private Boolean encrypt;
|
||||
|
||||
@Parameter(name = ApiConstants.STORAGE_TYPE,
|
||||
type = CommandType.STRING,
|
||||
description = "the storage type of the service offering. Values are local and shared.",
|
||||
since = "4.19")
|
||||
private String storageType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -84,6 +91,10 @@ public class ListDiskOfferingsCmd extends BaseListDomainResourcesCmd {
|
||||
|
||||
public Boolean getEncrypt() { return encrypt; }
|
||||
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -23,6 +23,7 @@ import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListDomainResourcesCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.BaseCmd.CommandType;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
@ -88,6 +89,12 @@ public class ListServiceOfferingsCmd extends BaseListDomainResourcesCmd {
|
||||
since = "4.18")
|
||||
private Boolean encryptRoot;
|
||||
|
||||
@Parameter(name = ApiConstants.STORAGE_TYPE,
|
||||
type = CommandType.STRING,
|
||||
description = "the storage type of the service offering. Values are local and shared.",
|
||||
since = "4.19")
|
||||
private String storageType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -130,6 +137,10 @@ public class ListServiceOfferingsCmd extends BaseListDomainResourcesCmd {
|
||||
|
||||
public Boolean getEncryptRoot() { return encryptRoot; }
|
||||
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -237,6 +237,7 @@ import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.security.SecurityGroupVMMapVO;
|
||||
import com.cloud.network.security.dao.SecurityGroupVMMapDao;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
@ -3130,6 +3131,8 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
Long volumeId = cmd.getVolumeId();
|
||||
Long storagePoolId = cmd.getStoragePoolId();
|
||||
Boolean encrypt = cmd.getEncrypt();
|
||||
String storageType = cmd.getStorageType();
|
||||
|
||||
// Keeping this logic consistent with domain specific zones
|
||||
// if a domainId is provided, we just return the disk offering
|
||||
// associated with this domain
|
||||
@ -3181,6 +3184,8 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
sc.addAnd("encrypt", SearchCriteria.Op.EQ, encrypt);
|
||||
}
|
||||
|
||||
useStorageType(sc, storageType);
|
||||
|
||||
if (zoneId != null) {
|
||||
SearchBuilder<DiskOfferingJoinVO> sb = _diskOfferingJoinDao.createSearchBuilder();
|
||||
sb.and("zoneId", sb.entity().getZoneId(), Op.FIND_IN_SET);
|
||||
@ -3260,6 +3265,17 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
return new Pair<>(result.first(), result.second());
|
||||
}
|
||||
|
||||
private void useStorageType(SearchCriteria<?> sc, String storageType) {
|
||||
if (storageType != null) {
|
||||
if (storageType.equalsIgnoreCase(ServiceOffering.StorageType.local.toString())) {
|
||||
sc.addAnd("useLocalStorage", Op.EQ, true);
|
||||
|
||||
} else if (storageType.equalsIgnoreCase(ServiceOffering.StorageType.shared.toString())) {
|
||||
sc.addAnd("useLocalStorage", Op.EQ, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Long> findRelatedDomainIds(Domain domain, boolean isRecursive) {
|
||||
List<Long> domainIds = _domainDao.getDomainParentIds(domain.getId())
|
||||
.stream().collect(Collectors.toList());
|
||||
@ -3309,6 +3325,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
Integer memory = cmd.getMemory();
|
||||
Integer cpuSpeed = cmd.getCpuSpeed();
|
||||
Boolean encryptRoot = cmd.getEncryptRoot();
|
||||
String storageType = cmd.getStorageType();
|
||||
|
||||
SearchCriteria<ServiceOfferingJoinVO> sc = _srvOfferingJoinDao.createSearchCriteria();
|
||||
if (!accountMgr.isRootAdmin(caller.getId()) && isSystem) {
|
||||
@ -3432,6 +3449,8 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
sc.addAnd("vmType", SearchCriteria.Op.EQ, vmTypeStr);
|
||||
}
|
||||
|
||||
useStorageType(sc, storageType);
|
||||
|
||||
if (zoneId != null) {
|
||||
SearchBuilder<ServiceOfferingJoinVO> sb = _srvOfferingJoinDao.createSearchBuilder();
|
||||
sb.and("zoneId", sb.entity().getZoneId(), Op.FIND_IN_SET);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user