Search in sources :

Example 6 with SnapshotDataStoreVO

use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.

the class SnapshotObject method decRefCount.

@Override
public void decRefCount() {
    if (store == null) {
        return;
    }
    if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) {
        SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(), getId());
        store.decrRefCnt();
        store.setLastUpdated(new Date());
        snapshotStoreDao.update(store.getId(), store);
    }
}
Also used : SnapshotDataStoreVO(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO) Date(java.util.Date)

Example 7 with SnapshotDataStoreVO

use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.

the class SnapshotObject method getChild.

@Override
public SnapshotInfo getChild() {
    QueryBuilder<SnapshotDataStoreVO> sc = QueryBuilder.create(SnapshotDataStoreVO.class);
    sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId());
    sc.and(sc.entity().getRole(), Op.EQ, store.getRole());
    sc.and(sc.entity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error);
    sc.and(sc.entity().getParentSnapshotId(), Op.EQ, getId());
    SnapshotDataStoreVO vo = sc.find();
    if (vo == null) {
        return null;
    }
    return snapshotFactory.getSnapshot(vo.getId(), store);
}
Also used : SnapshotDataStoreVO(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO)

Example 8 with SnapshotDataStoreVO

use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.

the class SnapshotObject method getPhysicalSize.

@Override
public long getPhysicalSize() {
    long physicalSize = 0;
    SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image);
    if (snapshotStore != null) {
        physicalSize = snapshotStore.getPhysicalSize();
    }
    return physicalSize;
}
Also used : SnapshotDataStoreVO(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO)

Example 9 with SnapshotDataStoreVO

use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.

the class SnapshotServiceImpl method findSnapshotImageStore.

// if a snapshot has parent snapshot, the new snapshot should be stored in
// the same store as its parent since
// we are taking delta snapshot
private DataStore findSnapshotImageStore(SnapshotInfo snapshot) {
    Boolean fullSnapshot = true;
    Object payload = snapshot.getPayload();
    if (payload != null) {
        fullSnapshot = (Boolean) payload;
    }
    if (fullSnapshot) {
        return dataStoreMgr.getImageStore(snapshot.getDataCenterId());
    } else {
        SnapshotInfo parentSnapshot = snapshot.getParent();
        // Note that DataStore information in parentSnapshot is for primary
        // data store here, we need to
        // find the image store where the parent snapshot backup is located
        SnapshotDataStoreVO parentSnapshotOnBackupStore = null;
        if (parentSnapshot != null) {
            parentSnapshotOnBackupStore = _snapshotStoreDao.findBySnapshot(parentSnapshot.getId(), DataStoreRole.Image);
        }
        if (parentSnapshotOnBackupStore == null) {
            return dataStoreMgr.getImageStore(snapshot.getDataCenterId());
        }
        return dataStoreMgr.getDataStore(parentSnapshotOnBackupStore.getDataStoreId(), parentSnapshotOnBackupStore.getRole());
    }
}
Also used : SnapshotInfo(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo) SnapshotDataStoreVO(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO)

Example 10 with SnapshotDataStoreVO

use of org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO in project cloudstack by apache.

the class SnapshotDataFactoryImpl method listSnapshotOnCache.

@Override
public List<SnapshotInfo> listSnapshotOnCache(long snapshotId) {
    List<SnapshotDataStoreVO> cacheSnapshots = snapshotStoreDao.listOnCache(snapshotId);
    List<SnapshotInfo> snapObjs = new ArrayList<SnapshotInfo>();
    for (SnapshotDataStoreVO cacheSnap : cacheSnapshots) {
        long storeId = cacheSnap.getDataStoreId();
        DataStore store = storeMgr.getDataStore(storeId, DataStoreRole.ImageCache);
        SnapshotInfo tmplObj = getSnapshot(snapshotId, store);
        snapObjs.add(tmplObj);
    }
    return snapObjs;
}
Also used : SnapshotInfo(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) SnapshotDataStoreVO(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO) ArrayList(java.util.ArrayList)

Aggregations

SnapshotDataStoreVO (org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO)38 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)15 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)11 SnapshotVO (com.cloud.storage.SnapshotVO)10 SnapshotInfo (org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo)10 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)9 VolumeDataStoreVO (org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO)8 TemplateDataStoreVO (org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO)6 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)5 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)5 VolumeVO (com.cloud.storage.VolumeVO)5 Date (java.util.Date)5 ConfigurationException (javax.naming.ConfigurationException)5 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)4 DB (com.cloud.utils.db.DB)4 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)3 Account (com.cloud.user.Account)3 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)3 VMSnapshotVO (com.cloud.vm.snapshot.VMSnapshotVO)3 SnapshotResult (org.apache.cloudstack.engine.subsystem.api.storage.SnapshotResult)3