private boolean isCreateFromSnapshot(Vm vm) { return vm.isSetSnapshots() && vm.getSnapshots().getSnapshots() != null && !vm.getSnapshots().getSnapshots().isEmpty(); }
private void validateSnapshotExistence(Vm vm) { // null and emptiness were previously tested Snapshot snapshot = vm.getSnapshots().getSnapshots().get(0); validateParameters(snapshot, "id"); }
private void validateSnapshotExistence(Vm vm) { Snapshot snapshot = vm.getSnapshots().getSnapshots().get(0); validateParameters(snapshot, "id"); }
&& template.getVm()!=null && template.getVm().getSnapshots()!=null && template.getVm().getSnapshots().getSnapshots()!=null && template.getVm().getSnapshots().getSnapshots().size() > 0 && template.getVm().getSnapshots().getSnapshots().get(0).getId()!=null && (( template.getVm()!=null && template.getVm().getId()!=null) || ( template.getVm()!=null && template.getVm().getName()!=null)) ) {
&& (( vm.getCluster()!=null && vm.getCluster().getId()!=null) || ( vm.getCluster()!=null && vm.getCluster().getName()!=null)) && (( vm.getTemplate()!=null && vm.getTemplate().getId()!=null) || ( vm.getTemplate()!=null && vm.getTemplate().getName()!=null)) && vm.getSnapshots()!=null && vm.getSnapshots().getSnapshots()!=null && vm.getSnapshots().getSnapshots().size() > 0 && vm.getSnapshots().getSnapshots().get(0).getId()!=null ) { return VmsResource.class.getMethod("addFromSnapshot", Vm.class);
private Response createVmFromSnapshot(Vm vm) { // If Vm has snapshots collection - this is a clone vm from snapshot operation String snapshotId = getSnapshotId(vm.getSnapshots()); org.ovirt.engine.core.common.businessentities.VM vmConfiguration = getVmConfiguration(snapshotId); getMapper(Vm.class, VmStatic.class).map(vm, vmConfiguration.getStaticData()); updateMaxMemoryIfUnspecified(vm, vmConfiguration.getStaticData()); // If vm passed in the call has disks attached on them, // merge their data with the data of the disks on the configuration // The parameters to AddVmFromSnapshot hold an array list of Disks // and not List of Disks, as this is a GWT serialization limitation, // and this parameter class serves GWT clients as well. Map<Guid, DiskImage> diskImagesByImageId = getDiskImagesByIdMap(vmConfiguration.getDiskMap().values()); if (vm.isSetDiskAttachments()) { prepareImagesForCloneFromSnapshotParams(vm.getDiskAttachments(), diskImagesByImageId); } return cloneVmFromSnapshot(vmConfiguration, vm, snapshotId, diskImagesByImageId); }
@Override public Response addFromVmSnapshot(Template template) { validateIconParameters(template); validateSnapshotExistence(template.getVm()); Guid snapshotId = getSnapshotId(template.getVm().getSnapshots()); org.ovirt.engine.core.common.businessentities.VM vmConfiguration = getVmConfiguration(snapshotId); if (template.getVersion() != null) { validateParameters(template.getVersion(), "baseTemplate"); } VmStatic originalVm = vmConfiguration.getStaticData(); VmStatic staticVm = getMapper(Template.class, VmStatic.class).map(template, originalVm); if (namedCluster(template)) { Guid clusterId = getClusterId(template); staticVm.setClusterId(clusterId); } AddVmTemplateFromSnapshotParameters params = new AddVmTemplateFromSnapshotParameters( staticVm, template.getName(), template.getDescription(), snapshotId); return addTemplate(template, originalVm, vmConfiguration.getDiskMap().keySet(), params, ActionType.AddVmTemplateFromSnapshot); }
to.getSnapshots().getSnapshots().addAll(adaptOut(from.getSnapshots().getSnapshots()));