use of com.cloud.api.query.vo.TemplateJoinVO in project cosmic by MissionCriticalCloud.
the class QueryManagerImpl method listTemplates.
@Override
public ListResponse<TemplateResponse> listTemplates(final ListTemplatesCmd cmd) {
final Pair<List<TemplateJoinVO>, Integer> result = searchForTemplatesInternal(cmd);
final ListResponse<TemplateResponse> response = new ListResponse<>();
ResponseView respView = ResponseView.Restricted;
if (cmd instanceof ListTemplatesCmdByAdmin) {
respView = ResponseView.Full;
}
final List<TemplateResponse> templateResponses = ViewResponseHelper.createTemplateResponse(respView, result.first().toArray(new TemplateJoinVO[result.first().size()]));
response.setResponses(templateResponses, result.second());
return response;
}
use of com.cloud.api.query.vo.TemplateJoinVO in project cosmic by MissionCriticalCloud.
the class ViewResponseHelper method createIsoResponse.
public static List<TemplateResponse> createIsoResponse(final ResponseView view, final TemplateJoinVO... templates) {
final Hashtable<String, TemplateResponse> vrDataList = new Hashtable<>();
for (final TemplateJoinVO vr : templates) {
TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
if (vrData == null) {
// first time encountering this volume
vrData = ApiDBUtils.newIsoResponse(vr);
} else {
// update tags
vrData = ApiDBUtils.fillTemplateDetails(view, vrData, vr);
}
vrDataList.put(vr.getTempZonePair(), vrData);
}
return new ArrayList<>(vrDataList.values());
}
use of com.cloud.api.query.vo.TemplateJoinVO in project cosmic by MissionCriticalCloud.
the class StorageManagerImpl method deleteImageStore.
@Override
public boolean deleteImageStore(final DeleteImageStoreCmd cmd) {
final long storeId = cmd.getId();
// Verify that image store exists
final ImageStoreVO store = _imageStoreDao.findById(storeId);
if (store == null) {
throw new InvalidParameterValueException("Image store with id " + storeId + " doesn't exist");
}
_accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), store.getDataCenterId());
// Verify that there are no live snapshot, template, volume on the image
// store to be deleted
final List<SnapshotDataStoreVO> snapshots = _snapshotStoreDao.listByStoreId(storeId, DataStoreRole.Image);
if (snapshots != null && snapshots.size() > 0) {
throw new InvalidParameterValueException("Cannot delete image store with active snapshots backup!");
}
final List<VolumeDataStoreVO> volumes = _volumeStoreDao.listByStoreId(storeId);
if (volumes != null && volumes.size() > 0) {
throw new InvalidParameterValueException("Cannot delete image store with active volumes backup!");
}
// search if there are user templates stored on this image store, excluding system, builtin templates
final List<TemplateJoinVO> templates = _templateViewDao.listActiveTemplates(storeId);
if (templates != null && templates.size() > 0) {
throw new InvalidParameterValueException("Cannot delete image store with active templates backup!");
}
// ready to delete
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(final TransactionStatus status) {
// first delete from image_store_details table, we need to do that since
// we are not actually deleting record from main
// image_data_store table, so delete cascade will not work
_imageStoreDetailsDao.deleteDetails(storeId);
_snapshotStoreDao.deletePrimaryRecordsForStore(storeId, DataStoreRole.Image);
_volumeStoreDao.deletePrimaryRecordsForStore(storeId);
_templateStoreDao.deletePrimaryRecordsForStore(storeId);
_imageStoreDao.remove(storeId);
}
});
return true;
}
use of com.cloud.api.query.vo.TemplateJoinVO in project cloudstack by apache.
the class ViewResponseHelper method createTemplateResponse.
public static List<TemplateResponse> createTemplateResponse(ResponseView view, TemplateJoinVO... templates) {
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<String, TemplateResponse>();
for (TemplateJoinVO vr : templates) {
TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
if (vrData == null) {
// first time encountering this volume
vrData = ApiDBUtils.newTemplateResponse(view, vr);
} else {
// update tags
vrData = ApiDBUtils.fillTemplateDetails(view, vrData, vr);
}
vrDataList.put(vr.getTempZonePair(), vrData);
}
return new ArrayList<TemplateResponse>(vrDataList.values());
}
use of com.cloud.api.query.vo.TemplateJoinVO in project cosmic by MissionCriticalCloud.
the class ViewResponseHelper method createTemplateUpdateResponse.
public static List<TemplateResponse> createTemplateUpdateResponse(final ResponseView view, final TemplateJoinVO... templates) {
final Hashtable<Long, TemplateResponse> vrDataList = new Hashtable<>();
for (final TemplateJoinVO vr : templates) {
TemplateResponse vrData = vrDataList.get(vr.getId());
if (vrData == null) {
// first time encountering this volume
vrData = ApiDBUtils.newTemplateUpdateResponse(vr);
} else {
// update tags
vrData = ApiDBUtils.fillTemplateDetails(view, vrData, vr);
}
vrDataList.put(vr.getId(), vrData);
}
return new ArrayList<>(vrDataList.values());
}
Aggregations