@Override public void beforeStartVmOnKvm(KVMHostInventory host, VmInstanceSpec spec, StartVmCmd cmd) { VolumeInventory root = spec.getDestRootVolume(); if (!root.getInstallPath().startsWith(VolumeTO.FUSIONSTOR)) { return; } cmd.getAddons().put("qemuPath", QEMUPATH); cmd.setRootVolume(convertVolumeToFusionstorIfNeeded(root, cmd.getRootVolume())); List<VolumeTO> dtos = new ArrayList<VolumeTO>(); for (VolumeTO to : cmd.getDataVolumes()) { VolumeInventory dvol = null; for (VolumeInventory vol : spec.getDestDataVolumes()) { if (vol.getUuid().equals(to.getVolumeUuid())) { dvol = vol; break; } } dtos.add(convertVolumeToFusionstorIfNeeded(dvol, to)); } cmd.setDataVolumes(dtos); List<CdRomTO> cdRomTOS = CollectionUtils.transformToList(cmd.getCdRoms(), new Function<CdRomTO, CdRomTO>() { @Override public CdRomTO call(CdRomTO arg) { return convertCdRomToFusionstorIfNeeded(arg); } }); cmd.setCdRoms(cdRomTOS); }
VolumeTO rootVolume = new VolumeTO(); rootVolume.setInstallPath(spec.getDestRootVolume().getInstallPath()); rootVolume.setDeviceId(spec.getDestRootVolume().getDeviceId()); rootVolume.setDeviceType(getVolumeTOType(spec.getDestRootVolume())); rootVolume.setVolumeUuid(spec.getDestRootVolume().getUuid()); rootVolume.setUseVirtio(virtio); rootVolume.setUseVirtioSCSI(KVMSystemTags.VOLUME_VIRTIO_SCSI.hasTag(spec.getDestRootVolume().getUuid())); rootVolume.setWwn(setVolumeWwn(spec.getDestRootVolume().getUuid())); rootVolume.setCacheMode(KVMGlobalConfig.LIBVIRT_CACHE_MODE.value()); VolumeTO v = new VolumeTO(); v.setInstallPath(data.getInstallPath()); v.setDeviceId(data.getDeviceId()); v.setDeviceType(getVolumeTOType(data)); v.setVolumeUuid(data.getUuid()); v.setUseVirtio(true); v.setUseVirtioSCSI(KVMSystemTags.VOLUME_VIRTIO_SCSI.hasTag(data.getUuid())); v.setWwn(setVolumeWwn(data.getUuid())); v.setShareable(data.isShareable()); v.setCacheMode(KVMGlobalConfig.LIBVIRT_CACHE_MODE.value()); dataVolumes.add(v);
private void detachVolume(final DetachVolumeFromVmOnHypervisorMsg msg, final NoErrorCompletion completion) { checkStateAndStatus(); VolumeTO to = new VolumeTO(); final VolumeInventory vol = msg.getInventory(); final VmInstanceInventory vm = msg.getVmInventory(); to.setInstallPath(vol.getInstallPath()); if (vol.getDeviceId() != null) { to.setDeviceId(vol.getDeviceId()); to.setDeviceType(getVolumeTOType(vol)); to.setVolumeUuid(vol.getUuid()); to.setUseVirtio(ImagePlatform.Windows.toString().equals(vm.getPlatform()) || ImagePlatform.valueOf(vm.getPlatform()).isParaVirtualization()); to.setUseVirtioSCSI(KVMSystemTags.VOLUME_VIRTIO_SCSI.hasTag(vol.getUuid())); to.setWwn(setVolumeWwn(vol.getUuid())); to.setShareable(vol.isShareable());
private void attachVolume(final AttachVolumeToVmOnHypervisorMsg msg, final NoErrorCompletion completion) { checkStateAndStatus(); VolumeTO to = new VolumeTO(); final VolumeInventory vol = msg.getInventory(); final VmInstanceInventory vm = msg.getVmInventory(); to.setInstallPath(vol.getInstallPath()); to.setDeviceId(vol.getDeviceId()); to.setDeviceType(getVolumeTOType(vol)); to.setVolumeUuid(vol.getUuid()); to.setUseVirtio(ImagePlatform.Windows.toString().equals(vm.getPlatform()) || ImagePlatform.valueOf(vm.getPlatform()).isParaVirtualization()); to.setUseVirtioSCSI(KVMSystemTags.VOLUME_VIRTIO_SCSI.hasTag(vol.getUuid())); to.setWwn(setVolumeWwn(vol.getUuid())); to.setShareable(vol.isShareable()); to.setCacheMode(KVMGlobalConfig.LIBVIRT_CACHE_MODE.value());
@Override public void beforeStartVmOnKvm(KVMHostInventory host, VmInstanceSpec spec, StartVmCmd cmd) { cmd.setRootVolume(convertVolumeToCephIfNeeded(spec.getDestRootVolume(), cmd.getRootVolume())); List<VolumeTO> dtos = new ArrayList<VolumeTO>(); for (VolumeTO to : cmd.getDataVolumes()) { VolumeInventory dvol = null; for (VolumeInventory vol : spec.getDestDataVolumes()) { if (vol.getUuid().equals(to.getVolumeUuid())) { dvol = vol; break; } } dtos.add(convertVolumeToCephIfNeeded(dvol, to)); } cmd.setDataVolumes(dtos); List<CdRomTO> cdRomTOS = CollectionUtils.transformToList(cmd.getCdRoms(), new Function<CdRomTO, CdRomTO>() { @Override public CdRomTO call(CdRomTO arg) { return convertCdRomToCephIfNeeded(arg); } }); cmd.setCdRoms(cdRomTOS); CephPrimaryStorageVO cephPrimaryStorageVO = dbf.findByUuid(spec.getDestRootVolume().getPrimaryStorageUuid(), CephPrimaryStorageVO.class); if (cephPrimaryStorageVO != null && !CephSystemTags.NO_CEPHX.hasTag(cephPrimaryStorageVO.getUuid())) { cmd.getAddons().put(CephConstants.CEPH_SCECRET_KEY, cephPrimaryStorageVO.getUserKey()); cmd.getAddons().put(CephConstants.CEPH_SECRECT_UUID, CephSystemTags.KVM_SECRET_UUID.getTokenByResourceUuid(cephPrimaryStorageVO.getUuid(), CephSystemTags.KVM_SECRET_UUID_TOKEN)); } }