@Override public Long getDeviceId() { return volumeVO.getDeviceId(); }
if (vol.getDeviceId().equals(deviceId)) { throw new RuntimeException("deviceId " + deviceId + " is used by vm " + vm.getId()); devIds.remove(vol.getDeviceId().toString().trim());
attachVolumeToVM(cmd.getVirtualMachineId(), volume.getId(), volume.getDeviceId()); } catch (Exception ex) { StringBuilder message = new StringBuilder("Volume: ");
@Override public void prepareForMigration(VirtualMachineProfile vm, DeployDestination dest) { List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId()); if (s_logger.isDebugEnabled()) { s_logger.debug("Preparing " + vols.size() + " volumes for " + vm); } for (VolumeVO vol : vols) { VolumeInfo volumeInfo = volFactory.getVolume(vol.getId()); DataTO volTO = volumeInfo.getTO(); DiskTO disk = storageMgr.getDiskWithThrottling(volTO, vol.getVolumeType(), vol.getDeviceId(), vol.getPath(), vm.getServiceOfferingId(), vol.getDiskOfferingId()); DataStore dataStore = dataStoreMgr.getDataStore(vol.getPoolId(), DataStoreRole.Primary); disk.setDetails(getDetails(volumeInfo, dataStore)); vm.addDisk(disk); } //if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat() == ImageFormat.ISO) { if (vm.getType() == VirtualMachine.Type.User) { _tmpltMgr.prepareIsoForVmProfile(vm, dest); //DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image, vm.getVirtualMachine().getDataCenterId()).getTO(); //DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO); //vm.addDisk(iso); } }
@Override public List<Command> finalizeExpungeVolumes(VirtualMachine vm) { List<Command> commands = new ArrayList<Command>(); List<VolumeVO> volumes = volumeDao.findByInstance(vm.getId()); // it's OK in this case to send a detach command to the host for a root volume as this // will simply lead to the SR that supports the root volume being removed if (volumes != null) { for (VolumeVO volume : volumes) { StoragePoolVO storagePool = storagePoolDao.findById(volume.getPoolId()); // storagePool should be null if we are expunging a volume that was never // attached to a VM that was started (the "trick" for storagePool to be null // is that none of the VMs this volume may have been attached to were ever started, // so the volume was never assigned to a storage pool) if (storagePool != null && storagePool.isManaged()) { DataTO volTO = volFactory.getVolume(volume.getId()).getTO(); DiskTO disk = new DiskTO(volTO, volume.getDeviceId(), volume.getPath(), volume.getVolumeType()); DettachCommand cmd = new DettachCommand(disk, vm.getInstanceName()); cmd.setManaged(true); cmd.setStorageHost(storagePool.getHostAddress()); cmd.setStoragePort(storagePool.getPort()); cmd.set_iScsiName(volume.get_iScsiName()); commands.add(cmd); } } } return commands; }
DiskTO disk = new DiskTO(volumeInfo.getTO(), root.getDeviceId(), root.getPath(), root.getVolumeType());
AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodId(), Op.EQ); AllFieldsSearch.and("instanceId", AllFieldsSearch.entity().getInstanceId(), Op.EQ); AllFieldsSearch.and("deviceId", AllFieldsSearch.entity().getDeviceId(), Op.EQ); AllFieldsSearch.and("poolId", AllFieldsSearch.entity().getPoolId(), Op.EQ); AllFieldsSearch.and("vType", AllFieldsSearch.entity().getVolumeType(), Op.EQ);