use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.
the class SystemVmTemplateRegistration method getNfsStoreInZone.
private Pair<String, Long> getNfsStoreInZone(Long zoneId) {
String url = null;
Long storeId = null;
ImageStoreVO storeVO = imageStoreDao.findOneByZoneAndProtocol(zoneId, "nfs");
if (storeVO == null) {
String errMsg = String.format("Failed to fetch NFS store in zone = %s for SystemVM template registration", zoneId);
LOGGER.error(errMsg);
throw new CloudRuntimeException(errMsg);
}
url = storeVO.getUrl();
storeId = storeVO.getId();
return new Pair<>(url, storeId);
}
use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.
the class StorageCacheManagerImpl method getCacheStores.
protected List<DataStore> getCacheStores() {
QueryBuilder<ImageStoreVO> sc = QueryBuilder.create(ImageStoreVO.class);
sc.and(sc.entity().getRole(), SearchCriteria.Op.EQ, DataStoreRole.ImageCache);
List<ImageStoreVO> imageStoreVOs = sc.list();
List<DataStore> stores = new ArrayList<DataStore>();
for (ImageStoreVO vo : imageStoreVOs) {
stores.add(dataStoreManager.getDataStore(vo.getId(), vo.getRole()));
}
return stores;
}
use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.
the class StorageCacheReplacementAlgorithmLRUTest method testSelectObject.
@Test
public void testSelectObject() {
cacheReplacementAlgorithm.setUnusedTimeInterval(1);
try {
VMTemplateVO template = new VMTemplateVO();
template.setTemplateType(Storage.TemplateType.USER);
template.setUrl(UUID.randomUUID().toString());
template.setUniqueName(UUID.randomUUID().toString());
template.setName(UUID.randomUUID().toString());
template.setPublicTemplate(true);
template.setFeatured(true);
template.setRequiresHvm(true);
template.setBits(64);
template.setFormat(Storage.ImageFormat.VHD);
template.setEnablePassword(true);
template.setEnableSshKey(true);
template.setGuestOSId(1);
template.setBootable(true);
template.setPrepopulate(true);
template.setCrossZones(true);
template.setExtractable(true);
template = templateDao.persist(template);
VMTemplateVO template2 = new VMTemplateVO();
template2.setTemplateType(Storage.TemplateType.USER);
template2.setUrl(UUID.randomUUID().toString());
template2.setUniqueName(UUID.randomUUID().toString());
template2.setName(UUID.randomUUID().toString());
template2.setPublicTemplate(true);
template2.setFeatured(true);
template2.setRequiresHvm(true);
template2.setBits(64);
template2.setFormat(Storage.ImageFormat.VHD);
template2.setEnablePassword(true);
template2.setEnableSshKey(true);
template2.setGuestOSId(1);
template2.setBootable(true);
template2.setPrepopulate(true);
template2.setCrossZones(true);
template2.setExtractable(true);
template2 = templateDao.persist(template2);
ImageStoreVO imageStoreVO = new ImageStoreVO();
imageStoreVO.setRole(DataStoreRole.ImageCache);
imageStoreVO.setName(UUID.randomUUID().toString());
imageStoreVO.setProviderName(DataStoreProvider.NFS_IMAGE);
imageStoreVO.setProtocol("nfs");
imageStoreVO.setUrl(UUID.randomUUID().toString());
imageStoreVO = imageStoreDao.persist(imageStoreVO);
Calendar cal = Calendar.getInstance();
cal.setTime(DateUtil.now());
cal.add(Calendar.DAY_OF_MONTH, -2);
Date date = cal.getTime();
TemplateDataStoreVO templateStoreVO1 = new TemplateDataStoreVO();
templateStoreVO1.setLastUpdated(date);
templateStoreVO1.setDataStoreRole(DataStoreRole.ImageCache);
templateStoreVO1.setDataStoreId(imageStoreVO.getId());
templateStoreVO1.setState(ObjectInDataStoreStateMachine.State.Ready);
templateStoreVO1.setCopy(true);
templateStoreVO1.setTemplateId(template.getId());
templateDataStoreDao.persist(templateStoreVO1);
TemplateDataStoreVO templateStoreVO2 = new TemplateDataStoreVO();
templateStoreVO2.setLastUpdated(date);
templateStoreVO2.setDataStoreRole(DataStoreRole.ImageCache);
templateStoreVO2.setDataStoreId(imageStoreVO.getId());
templateStoreVO2.setState(ObjectInDataStoreStateMachine.State.Ready);
templateStoreVO2.setCopy(true);
templateStoreVO2.setTemplateId(template2.getId());
templateDataStoreDao.persist(templateStoreVO2);
DataStore store = dataStoreManager.getDataStore(imageStoreVO.getId(), DataStoreRole.ImageCache);
Assert.assertNotNull(cacheReplacementAlgorithm.chooseOneToBeReplaced(store));
} catch (Exception e) {
Assert.fail();
}
}
use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.
the class ImageStoreProviderManagerImpl method listImageStoreByProvider.
@Override
public List<DataStore> listImageStoreByProvider(String provider) {
List<ImageStoreVO> stores = dataStoreDao.findByProvider(provider);
List<DataStore> imageStores = new ArrayList<DataStore>();
for (ImageStoreVO store : stores) {
imageStores.add(getImageStore(store.getId()));
}
return imageStores;
}
use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.
the class ImageStoreProviderManagerImpl method listImageStores.
@Override
public List<DataStore> listImageStores() {
List<ImageStoreVO> stores = dataStoreDao.listImageStores();
List<DataStore> imageStores = new ArrayList<DataStore>();
for (ImageStoreVO store : stores) {
imageStores.add(getImageStore(store.getId()));
}
return imageStores;
}
Aggregations