private void verifySnapshotType(SnapshotInfo snapshotInfo) { if (snapshotInfo.getHypervisorType() == HypervisorType.KVM && snapshotInfo.getDataStore().getRole() != DataStoreRole.Primary) { throw new CloudRuntimeException("For the KVM hypervisor type, you can only revert a volume to a snapshot state if the snapshot " + "resides on primary storage. For other snapshot types, create a volume from the snapshot to recover its data."); } }
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; }
@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); }
if (HypervisorType.XenServer.equals(snapshotInfo.getHypervisorType())) { computeClusterSupportsVolumeClone = clusterDao.getSupportsResigning(hostVO.getClusterId()); else if (HypervisorType.VMware.equals(snapshotInfo.getHypervisorType()) || HypervisorType.KVM.equals(snapshotInfo.getHypervisorType())) { computeClusterSupportsVolumeClone = true; createVolumeFromSnapshot(snapshotInfo); if (HypervisorType.XenServer.equals(snapshotInfo.getHypervisorType()) || HypervisorType.VMware.equals(snapshotInfo.getHypervisorType())) { keepGrantedAccess = HypervisorType.XenServer.equals(snapshotInfo.getHypervisorType()); if (HypervisorType.VMware.equals(snapshotInfo.getHypervisorType())) { extraDetails = new HashMap<>(); if (HypervisorType.VMware.equals(snapshotInfo.getHypervisorType())) { String iqn = getSnapshotProperty(snapshotInfo.getId(), DiskTO.IQN); if (HypervisorType.VMware.equals(snapshotInfo.getHypervisorType())) { String iqn = getSnapshotProperty(snapshotInfo.getId(), DiskTO.IQN);
private HostVO getHost(SnapshotInfo snapshotInfo) { HypervisorType hypervisorType = snapshotInfo.getHypervisorType(); if (HypervisorType.XenServer.equals(hypervisorType)) { HostVO hostVO = getHost(snapshotInfo.getDataCenterId(), hypervisorType, true); if (hostVO == null) { hostVO = getHost(snapshotInfo.getDataCenterId(), hypervisorType, false); if (hostVO == null) { throw new CloudRuntimeException("Unable to locate an applicable host in data center with ID = " + snapshotInfo.getDataCenterId()); } } return hostVO; } if (HypervisorType.VMware.equals(hypervisorType) || HypervisorType.KVM.equals(hypervisorType)) { return getHost(snapshotInfo.getDataCenterId(), hypervisorType, false); } throw new CloudRuntimeException("Unsupported hypervisor type"); }
boolean computeClusterSupportsVolumeClone = true; if (HypervisorType.XenServer.equals(snapshotInfo.getHypervisorType())) { computeClusterSupportsVolumeClone = clusterDao.getSupportsResigning(hostVO.getClusterId()); volumeInfo = _volumeDataFactory.getVolume(volumeInfo.getId(), volumeInfo.getDataStore()); if (HypervisorType.XenServer.equals(snapshotInfo.getHypervisorType()) || HypervisorType.VMware.equals(snapshotInfo.getHypervisorType())) { if (useCloning) { Map<String, String> extraDetails = null; if (HypervisorType.VMware.equals(snapshotInfo.getHypervisorType())) { extraDetails = new HashMap<>(); if (HypervisorType.VMware.equals(snapshotInfo.getHypervisorType())) { disconnectHostFromVolume(hostVO, volumeInfo.getPoolId(), volumeInfo.get_iScsiName()); hostVO = getHost(snapshotInfo.getDataCenterId(), snapshotInfo.getHypervisorType(), false); else if (HypervisorType.KVM.equals(snapshotInfo.getHypervisorType())) { VolumeObjectTO newVolume = new VolumeObjectTO();
hostVO = getHost(snapshotInfo.getDataCenterId(), snapshotInfo.getHypervisorType(), false); if (HypervisorType.XenServer.equals(snapshotInfo.getHypervisorType())) { copyCmdAnswer = performCopyOfVdi(volumeInfo, snapshotInfo, hostVO);
private void handleCreateNonManagedVolumeFromManagedSnapshot(SnapshotInfo snapshotInfo, VolumeInfo volumeInfo, AsyncCompletionCallback<CopyCommandResult> callback) { if (!HypervisorType.XenServer.equals(snapshotInfo.getHypervisorType())) { String errMsg = "Creating a volume on non-managed storage from a snapshot on managed storage is currently only supported with XenServer.";
if (action == StorageAction.TAKESNAPSHOT) { SnapshotInfo snapshotInfo = (SnapshotInfo)object; if (snapshotInfo.getHypervisorType() == Hypervisor.HypervisorType.KVM) { VolumeInfo volumeInfo = snapshotInfo.getBaseVolume(); VirtualMachine vm = volumeInfo.getAttachedVM();