Examples of SnapshotInfo


Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

    @DB
    public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationException {
        CreateSnapshotPayload payload = (CreateSnapshotPayload)volume.getpayload();
        Long snapshotId = payload.getSnapshotId();
        Account snapshotOwner = payload.getAccount();
        SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotId, volume.getDataStore());
        boolean processed = false;

        try {
            for (SnapshotStrategy strategy : snapshotStrategies) {
                if (strategy.canHandle(snapshot)) {
                    processed = true;
                    snapshot = strategy.takeSnapshot(snapshot);
                    break;
                }
            }
            if (!processed) {
                throw new CloudRuntimeException("Can't find snapshot strategy to deal with snapshot:" + snapshotId);
            }

            try {
                postCreateSnapshot(volume.getId(), snapshotId, payload.getSnapshotPolicyId());

                UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_CREATE, snapshot.getAccountId(),
                        snapshot.getDataCenterId(), snapshotId, snapshot.getName(), null, null,
                        volume.getSize(), snapshot.getClass().getName(), snapshot.getUuid());
                _resourceLimitMgr.incrementResourceCount(snapshotOwner.getId(), ResourceType.snapshot);
            } catch (Exception e) {
                s_logger.debug("post process snapshot failed", e);
            }
        } catch(Exception e) {
View Full Code Here

Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

    @Test
    public void createVolumeFromSnapshot() throws InterruptedException, ExecutionException {
        VolumeInfo vol = createCopyBaseImage();
        SnapshotVO snapshotVO = createSnapshotInDb(vol);
        SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
        boolean result = false;
        for (SnapshotStrategy strategy : this.snapshotStrategies) {
            if (strategy.canHandle(snapshot)) {
                snapshot = strategy.takeSnapshot(snapshot);
                result = true;
View Full Code Here

Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

    @Test
    public void deleteSnapshot() throws InterruptedException, ExecutionException {
        VolumeInfo vol = createCopyBaseImage();
        SnapshotVO snapshotVO = createSnapshotInDb(vol);
        SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
        SnapshotInfo newSnapshot = null;
        for (SnapshotStrategy strategy : this.snapshotStrategies) {
            if (strategy.canHandle(snapshot)) {
                newSnapshot = strategy.takeSnapshot(snapshot);
            }
        }
        AssertJUnit.assertNotNull(newSnapshot);

        // create another snapshot
        for (SnapshotStrategy strategy : this.snapshotStrategies) {
            if (strategy.canHandle(snapshot)) {
                strategy.deleteSnapshot(newSnapshot.getId());
            }
        }

    }
View Full Code Here

Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

    @Test
    public void createTemplateFromSnapshot() throws InterruptedException, ExecutionException {
        VolumeInfo vol = createCopyBaseImage();
        SnapshotVO snapshotVO = createSnapshotInDb(vol);
        SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
        boolean result = false;
        for (SnapshotStrategy strategy : this.snapshotStrategies) {
            if (strategy.canHandle(snapshot)) {
                snapshot = strategy.takeSnapshot(snapshot);
                result = true;
View Full Code Here

Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

   
    @Test
    public void createSnapshot() throws InterruptedException, ExecutionException {
        VolumeInfo vol = createCopyBaseImage();
        SnapshotVO snapshotVO = createSnapshotInDb(vol);
        SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
        SnapshotInfo newSnapshot = null;
        for (SnapshotStrategy strategy : this.snapshotStrategies) {
            if (strategy.canHandle(snapshot)) {
                newSnapshot = strategy.takeSnapshot(snapshot);
            }
        }
        AssertJUnit.assertNotNull(newSnapshot);

        LocalHostEndpoint ep = new MockLocalHostEndPoint();
        ep.setResource(new MockLocalNfsSecondaryStorageResource());
        Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);

        try {
            for (SnapshotStrategy strategy : this.snapshotStrategies) {
                if (strategy.canHandle(snapshot)) {
                    boolean res = strategy.deleteSnapshot(newSnapshot.getId());
                    Assert.assertTrue(res);
                }
            }
        } finally {
            Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(remoteEp);
View Full Code Here

Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

            CopyCommandResult result = new CopyCommandResult(null, null);
            result.setResult("Failed");
            callback.complete(result);
        }
        if (destData.getType() == DataObjectType.SNAPSHOT) {
            SnapshotInfo srcSnapshot = (SnapshotInfo)srcData;

            SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
            newSnapshot.setPath(UUID.randomUUID().toString());
            if (srcSnapshot.getParent() != null) {
                newSnapshot.setParentSnapshotPath(srcSnapshot.getParent().getPath());
            }
            data = newSnapshot;
        } else if (destData.getType() == DataObjectType.TEMPLATE) {
            TemplateObjectTO newTemplate = new TemplateObjectTO();
            newTemplate.setPath(UUID.randomUUID().toString());
View Full Code Here

Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

            snapshot = snapshot.getParent();
        }
    }

    protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) {
        SnapshotInfo snapshot = (SnapshotInfo) snapObj;
        StoragePool pool = (StoragePool) volObj.getDataStore();

        String basicErrMsg = "Failed to create volume from " + snapshot.getName() + " on pool " + pool;
        DataStore store = snapObj.getDataStore();
        DataStoreTO storTO = store.getTO();
        DataObject srcData = snapObj;
        try {
            if (!(storTO instanceof NfsTO)) {
View Full Code Here

Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

        String value = configDao.getValue(Config.CreatePrivateTemplateFromSnapshotWait.toString());
        int _createprivatetemplatefromsnapshotwait = NumbersUtil.parseInt(value,
                Integer.parseInt(Config.CreatePrivateTemplateFromSnapshotWait.getDefaultValue()));

        if (needCacheStorage(srcData, destData)) {
            SnapshotInfo snapshot = (SnapshotInfo) srcData;
            srcData = cacheSnapshotChain(snapshot);
        }

        CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _createprivatetemplatefromsnapshotwait, _mgmtServer.getExecuteInSequence());
        EndPoint ep = selector.select(srcData, destData);
View Full Code Here

Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

    //@Test
    public void testTakeSnapshot() throws URISyntaxException {
        SnapshotVO snapshotVO = createSnapshotInDb();
        DataStore store = createDataStore();
        try {
            SnapshotInfo snapshotInfo = snapshotDataFactory.getSnapshot(snapshotVO.getId(), store);
            SnapshotResult result = snapshotService.takeSnapshot(snapshotInfo);
            Assert.assertTrue(result.isSuccess());
            SnapshotDataStoreVO storeRef = snapshotDataStoreDao.findByStoreSnapshot(store.getRole(), store.getId(), snapshotVO.getId());
            Assert.assertTrue(storeRef != null);
            Assert.assertTrue(storeRef.getState() == ObjectInDataStoreStateMachine.State.Ready);
View Full Code Here

Examples of org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo

        DataStore store = null;
        try {
            store = createDataStore();
            FakePrimaryDataStoreDriver dataStoreDriver = (FakePrimaryDataStoreDriver)store.getDriver();
            dataStoreDriver.makeTakeSnapshotSucceed(false);
            SnapshotInfo snapshotInfo = snapshotDataFactory.getSnapshot(snapshotVO.getId(), store);
            SnapshotResult result = snapshotService.takeSnapshot(snapshotInfo);
            Assert.assertFalse(result.isSuccess());
            SnapshotDataStoreVO storeRef = snapshotDataStoreDao.findByStoreSnapshot(store.getRole(), store.getId(), snapshotVO.getId());
            Assert.assertTrue(storeRef == null);
        } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.