private void verifyLocationType(SnapshotInfo snapshotInfo) { VolumeInfo volumeInfo = snapshotInfo.getBaseVolume(); if (snapshotInfo.getLocationType() == Snapshot.LocationType.SECONDARY && volumeInfo.getFormat() != ImageFormat.VHD) { throw new CloudRuntimeException("Only the '" + ImageFormat.VHD + "' image type can be used when 'LocationType' is set to 'SECONDARY'."); } }
private boolean isForVMware(DataObject dataObj) { if (dataObj instanceof VolumeInfo) { return ImageFormat.OVA.equals(((VolumeInfo)dataObj).getFormat()); } if (dataObj instanceof SnapshotInfo) { return ImageFormat.OVA.equals(((SnapshotInfo)dataObj).getBaseVolume().getFormat()); } return dataObj instanceof TemplateInfo && HypervisorType.VMware.equals(((TemplateInfo)dataObj).getHypervisorType()); }
@Override public SnapshotInfo backupSnapshot(SnapshotInfo snapshotInfo) { Preconditions.checkArgument(snapshotInfo != null, "'snapshotInfo' cannot be 'null'."); if (snapshotInfo.getLocationType() != Snapshot.LocationType.SECONDARY) { markAsBackedUp((SnapshotObject)snapshotInfo); return snapshotInfo; } // At this point, the snapshot is either taken as a native // snapshot on the storage or exists as a volume on the storage (clone). // If archive flag is passed in, we should copy this snapshot to secondary // storage and delete it from primary storage. HostVO host = getHost(snapshotInfo.getVolumeId()); boolean canStorageSystemCreateVolumeFromSnapshot = canStorageSystemCreateVolumeFromSnapshot(snapshotInfo.getBaseVolume().getPoolId()); if (!canStorageSystemCreateVolumeFromSnapshot) { String msg = "Cannot archive snapshot: 'canStorageSystemCreateVolumeFromSnapshot' was false."; s_logger.warn(msg); throw new CloudRuntimeException(msg); } boolean computeClusterSupportsResign = clusterDao.getSupportsResigning(host.getClusterId()); if (!computeClusterSupportsResign) { String msg = "Cannot archive snapshot: 'computeClusterSupportsResign' was false."; s_logger.warn(msg); throw new CloudRuntimeException(msg); } return snapshotSvr.backupSnapshot(snapshotInfo); }
public SnapshotObjectTO(SnapshotInfo snapshot) { this.path = snapshot.getPath(); this.setId(snapshot.getId()); VolumeInfo vol = snapshot.getBaseVolume(); if (vol != null) { this.volume = (VolumeObjectTO)vol.getTO(); this.setVmName(vol.getAttachedVmName()); } SnapshotInfo parentSnapshot = snapshot.getParent(); ArrayList<String> parentsArry = new ArrayList<String>(); if (parentSnapshot != null) { this.parentSnapshotPath = parentSnapshot.getPath(); while(parentSnapshot != null) { parentsArry.add(parentSnapshot.getPath()); parentSnapshot = parentSnapshot.getParent(); } parents = parentsArry.toArray(new String[parentsArry.size()]); ArrayUtils.reverse(parents); } this.dataStore = snapshot.getDataStore().getTO(); this.setName(snapshot.getName()); this.hypervisorType = snapshot.getHypervisorType(); this.quiescevm = false; }
CreateSnapshotContext<CommandResult> context = new CreateSnapshotContext<CommandResult>(null, snap.getBaseVolume(), snapshotOnPrimary, future); AsyncCallbackDispatcher<SnapshotServiceImpl, CreateCmdResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().createSnapshotAsyncCallback(null, null)).setContext(context);
@Override public EndPoint select(DataObject srcData, DataObject destData, StorageAction action) { s_logger.error("IR24 select BACKUPSNAPSHOT from primary to secondary " + srcData.getId() + " dest=" + destData.getId()); if (action == StorageAction.BACKUPSNAPSHOT && srcData.getDataStore().getRole() == DataStoreRole.Primary) { SnapshotInfo srcSnapshot = (SnapshotInfo)srcData; VolumeInfo volumeInfo = srcSnapshot.getBaseVolume(); VirtualMachine vm = volumeInfo.getAttachedVM(); if (srcSnapshot.getHypervisorType() == Hypervisor.HypervisorType.KVM) { if (vm != null && vm.getState() == VirtualMachine.State.Running) { return getEndPointFromHostId(vm.getHostId()); } } if (srcSnapshot.getHypervisorType() == Hypervisor.HypervisorType.VMware) { if (vm != null) { Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId(); if (hostId != null) { return getEndPointFromHostId(hostId); } } } } return select(srcData, destData); }
@Override public void revertSnapshot(SnapshotInfo snapshot, SnapshotInfo snapshot2, AsyncCompletionCallback<CommandResult> callback) { VolumeInfo volumeInfo = snapshot.getBaseVolume(); VolumeVO volumeVO = volumeDao.findById(volumeInfo.getId()); if (volumeVO == null || volumeVO.getRemoved() != null) { String errMsg = "The volume that the snapshot belongs to no longer exists."; CommandResult commandResult = new CommandResult(); commandResult.setResult(errMsg); callback.complete(commandResult); return; } SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(volumeVO.getPoolId(), storagePoolDetailsDao); long sfVolumeId = Long.parseLong(volumeInfo.getFolder()); SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(snapshot.getId(), SolidFireUtil.SNAPSHOT_ID); long sfSnapshotId = Long.parseLong(snapshotDetails.getValue()); SolidFireUtil.rollBackVolumeToSnapshot(sfConnection, sfVolumeId, sfSnapshotId); SolidFireUtil.SolidFireVolume sfVolume = SolidFireUtil.getVolume(sfConnection, sfVolumeId); updateVolumeDetails(volumeVO.getId(), sfVolume.getTotalSize(), sfVolume.getScsiNaaDeviceId()); CommandResult commandResult = new CommandResult(); callback.complete(commandResult); }
@Override public boolean revertSnapshot(SnapshotInfo snapshotInfo) { VolumeInfo volumeInfo = snapshotInfo.getBaseVolume();
VolumeInfo volumeInfo = snapshot.getBaseVolume(); StoragePool store = (StoragePool)volumeInfo.getDataStore();
VolumeInfo volumeInfo = snapshot.getBaseVolume(); volumeInfo.stateTransit(Volume.Event.SnapshotRequested); SnapshotResult result = null;
VolumeInfo volumeInfo = snapshotInfo.getBaseVolume(); VolumeVO volumeVO = volumeDao.findById(volumeInfo.getId());
SnapshotInfo snapshotInfo = (SnapshotInfo)object; if (snapshotInfo.getHypervisorType() == Hypervisor.HypervisorType.KVM) { VolumeInfo volumeInfo = snapshotInfo.getBaseVolume(); VirtualMachine vm = volumeInfo.getAttachedVM(); if ((vm != null) && (vm.getState() == VirtualMachine.State.Running)) {
SnapshotDataStoreVO parentSnapshotOnBackupStore = snapshotStoreDao.findLatestSnapshotForVolume(snapshot.getVolumeId(), DataStoreRole.Image); SnapshotDataStoreVO parentSnapshotOnPrimaryStore = snapshotStoreDao.findLatestSnapshotForVolume(snapshot.getVolumeId(), DataStoreRole.Primary); HypervisorType hypervisorType = snapshot.getBaseVolume().getHypervisorType(); if (parentSnapshotOnPrimaryStore != null && parentSnapshotOnBackupStore != null && hypervisorType == Hypervisor.HypervisorType.XenServer) { // CS does incremental backup only for XenServer
@Override @DB public SnapshotInfo takeSnapshot(SnapshotInfo snapshotInfo) { VolumeInfo volumeInfo = snapshotInfo.getBaseVolume();