mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
List volumes by service offering id (#9211)
* Allow listing of volumes by service offering id * Address comments
This commit is contained in:
parent
4de975ff25
commit
c756e4370a
@ -31,6 +31,7 @@ import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
|||||||
import org.apache.cloudstack.api.response.HostResponse;
|
import org.apache.cloudstack.api.response.HostResponse;
|
||||||
import org.apache.cloudstack.api.response.ListResponse;
|
import org.apache.cloudstack.api.response.ListResponse;
|
||||||
import org.apache.cloudstack.api.response.PodResponse;
|
import org.apache.cloudstack.api.response.PodResponse;
|
||||||
|
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
||||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||||
@ -82,6 +83,12 @@ public class ListVolumesCmd extends BaseListRetrieveOnlyResourceCountCmd impleme
|
|||||||
RoleType.Admin})
|
RoleType.Admin})
|
||||||
private String storageId;
|
private String storageId;
|
||||||
|
|
||||||
|
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID,
|
||||||
|
entityType = ServiceOfferingResponse.class,
|
||||||
|
description = "list volumes by disk offering of a service offering. If both service offering and " +
|
||||||
|
"disk offering are passed, service offering is ignored", since = "4.19.1")
|
||||||
|
private Long serviceOfferingId;
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.DISK_OFFERING_ID, type = CommandType.UUID, entityType = DiskOfferingResponse.class, description = "list volumes by disk offering", since = "4.4")
|
@Parameter(name = ApiConstants.DISK_OFFERING_ID, type = CommandType.UUID, entityType = DiskOfferingResponse.class, description = "list volumes by disk offering", since = "4.4")
|
||||||
private Long diskOfferingId;
|
private Long diskOfferingId;
|
||||||
|
|
||||||
@ -123,6 +130,10 @@ public class ListVolumesCmd extends BaseListRetrieveOnlyResourceCountCmd impleme
|
|||||||
return podId;
|
return podId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getServiceOfferingId() {
|
||||||
|
return serviceOfferingId;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getDiskOfferingId() {
|
public Long getDiskOfferingId() {
|
||||||
return diskOfferingId;
|
return diskOfferingId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2406,7 +2406,8 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||||||
Map<String, String> tags = cmd.getTags();
|
Map<String, String> tags = cmd.getTags();
|
||||||
String storageId = cmd.getStorageId();
|
String storageId = cmd.getStorageId();
|
||||||
Long clusterId = cmd.getClusterId();
|
Long clusterId = cmd.getClusterId();
|
||||||
Long diskOffId = cmd.getDiskOfferingId();
|
Long serviceOfferingId = cmd.getServiceOfferingId();
|
||||||
|
Long diskOfferingId = cmd.getDiskOfferingId();
|
||||||
Boolean display = cmd.getDisplay();
|
Boolean display = cmd.getDisplay();
|
||||||
String state = cmd.getState();
|
String state = cmd.getState();
|
||||||
boolean shouldListSystemVms = shouldListSystemVms(cmd, caller.getId());
|
boolean shouldListSystemVms = shouldListSystemVms(cmd, caller.getId());
|
||||||
@ -2416,6 +2417,13 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||||||
|
|
||||||
List<Long> ids = getIdsListFromCmd(cmd.getId(), cmd.getIds());
|
List<Long> ids = getIdsListFromCmd(cmd.getId(), cmd.getIds());
|
||||||
|
|
||||||
|
if (diskOfferingId == null && serviceOfferingId != null) {
|
||||||
|
ServiceOfferingVO serviceOffering = _srvOfferingDao.findById(serviceOfferingId);
|
||||||
|
if (serviceOffering != null) {
|
||||||
|
diskOfferingId = serviceOffering.getDiskOfferingId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
|
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
|
||||||
accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
|
accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
|
||||||
Long domainId = domainIdRecursiveListProject.first();
|
Long domainId = domainIdRecursiveListProject.first();
|
||||||
@ -2546,8 +2554,8 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diskOffId != null) {
|
if (diskOfferingId != null) {
|
||||||
sc.setParameters("diskOfferingId", diskOffId);
|
sc.setParameters("diskOfferingId", diskOfferingId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
|
|||||||
@ -285,7 +285,7 @@ export default {
|
|||||||
}
|
}
|
||||||
if (['zoneid', 'domainid', 'imagestoreid', 'storageid', 'state', 'account', 'hypervisor', 'level',
|
if (['zoneid', 'domainid', 'imagestoreid', 'storageid', 'state', 'account', 'hypervisor', 'level',
|
||||||
'clusterid', 'podid', 'groupid', 'entitytype', 'accounttype', 'systemvmtype', 'scope', 'provider',
|
'clusterid', 'podid', 'groupid', 'entitytype', 'accounttype', 'systemvmtype', 'scope', 'provider',
|
||||||
'type'].includes(item)
|
'type', 'serviceofferingid', 'diskofferingid'].includes(item)
|
||||||
) {
|
) {
|
||||||
type = 'list'
|
type = 'list'
|
||||||
} else if (item === 'tags') {
|
} else if (item === 'tags') {
|
||||||
@ -397,6 +397,8 @@ export default {
|
|||||||
let podIndex = -1
|
let podIndex = -1
|
||||||
let clusterIndex = -1
|
let clusterIndex = -1
|
||||||
let groupIndex = -1
|
let groupIndex = -1
|
||||||
|
let serviceOfferingIndex = -1
|
||||||
|
let diskOfferingIndex = -1
|
||||||
|
|
||||||
if (arrayField.includes('type')) {
|
if (arrayField.includes('type')) {
|
||||||
if (this.$route.path === '/alert') {
|
if (this.$route.path === '/alert') {
|
||||||
@ -464,6 +466,18 @@ export default {
|
|||||||
promises.push(await this.fetchInstanceGroups(searchKeyword))
|
promises.push(await this.fetchInstanceGroups(searchKeyword))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arrayField.includes('serviceofferingid')) {
|
||||||
|
serviceOfferingIndex = this.fields.findIndex(item => item.name === 'serviceofferingid')
|
||||||
|
this.fields[serviceOfferingIndex].loading = true
|
||||||
|
promises.push(await this.fetchServiceOfferings(searchKeyword))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arrayField.includes('diskofferingid')) {
|
||||||
|
diskOfferingIndex = this.fields.findIndex(item => item.name === 'diskofferingid')
|
||||||
|
this.fields[diskOfferingIndex].loading = true
|
||||||
|
promises.push(await this.fetchDiskOfferings(searchKeyword))
|
||||||
|
}
|
||||||
|
|
||||||
Promise.all(promises).then(response => {
|
Promise.all(promises).then(response => {
|
||||||
if (typeIndex > -1) {
|
if (typeIndex > -1) {
|
||||||
const types = response.filter(item => item.type === 'type')
|
const types = response.filter(item => item.type === 'type')
|
||||||
@ -525,6 +539,20 @@ export default {
|
|||||||
this.fields[groupIndex].opts = this.sortArray(groups[0].data)
|
this.fields[groupIndex].opts = this.sortArray(groups[0].data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serviceOfferingIndex > -1) {
|
||||||
|
const serviceOfferings = response.filter(item => item.type === 'serviceofferingid')
|
||||||
|
if (serviceOfferings && serviceOfferings.length > 0) {
|
||||||
|
this.fields[serviceOfferingIndex].opts = this.sortArray(serviceOfferings[0].data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diskOfferingIndex > -1) {
|
||||||
|
const diskOfferings = response.filter(item => item.type === 'diskofferingid')
|
||||||
|
if (diskOfferings && diskOfferings.length > 0) {
|
||||||
|
this.fields[diskOfferingIndex].opts = this.sortArray(diskOfferings[0].data)
|
||||||
|
}
|
||||||
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
if (typeIndex > -1) {
|
if (typeIndex > -1) {
|
||||||
this.fields[typeIndex].loading = false
|
this.fields[typeIndex].loading = false
|
||||||
@ -550,6 +578,12 @@ export default {
|
|||||||
if (groupIndex > -1) {
|
if (groupIndex > -1) {
|
||||||
this.fields[groupIndex].loading = false
|
this.fields[groupIndex].loading = false
|
||||||
}
|
}
|
||||||
|
if (serviceOfferingIndex > -1) {
|
||||||
|
this.fields[serviceOfferingIndex].loading = false
|
||||||
|
}
|
||||||
|
if (diskOfferingIndex > -1) {
|
||||||
|
this.fields[diskOfferingIndex].loading = false
|
||||||
|
}
|
||||||
this.fillFormFieldValues()
|
this.fillFormFieldValues()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -699,6 +733,32 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
fetchServiceOfferings (searchKeyword) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
api('listServiceOfferings', { listAll: true, keyword: searchKeyword }).then(json => {
|
||||||
|
const serviceOfferings = json.listserviceofferingsresponse.serviceoffering
|
||||||
|
resolve({
|
||||||
|
type: 'serviceofferingid',
|
||||||
|
data: serviceOfferings
|
||||||
|
})
|
||||||
|
}).catch(error => {
|
||||||
|
reject(error.response.headers['x-description'])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fetchDiskOfferings (searchKeyword) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
api('listDiskOfferings', { listAll: true, keyword: searchKeyword }).then(json => {
|
||||||
|
const diskOfferings = json.listdiskofferingsresponse.diskoffering
|
||||||
|
resolve({
|
||||||
|
type: 'diskofferingid',
|
||||||
|
data: diskOfferings
|
||||||
|
})
|
||||||
|
}).catch(error => {
|
||||||
|
reject(error.response.headers['x-description'])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
fetchAlertTypes () {
|
fetchAlertTypes () {
|
||||||
if (this.alertTypes.length > 0) {
|
if (this.alertTypes.length > 0) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|||||||
@ -91,7 +91,7 @@ export default {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
searchFilters: () => {
|
searchFilters: () => {
|
||||||
var filters = ['name', 'zoneid', 'domainid', 'account', 'state', 'tags']
|
var filters = ['name', 'zoneid', 'domainid', 'account', 'state', 'tags', 'serviceofferingid', 'diskofferingid']
|
||||||
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
|
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
|
||||||
filters.push('storageid')
|
filters.push('storageid')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user