use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class RestoreAllSnapshotsCommandTest method mockSnapshotFromDb.
private void mockSnapshotFromDb() {
mockSnapshot = new Snapshot();
mockSnapshot.setType(SnapshotType.STATELESS);
when(snapshotDao.get(any(Guid.class), any(SnapshotType.class), any(SnapshotStatus.class))).thenReturn(mockSnapshot);
when(snapshotDao.get(any(Guid.class), any(SnapshotType.class))).thenReturn(mockSnapshot);
when(snapshotDao.get(any(Guid.class), any(SnapshotStatus.class))).thenReturn(mockSnapshot);
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class OvfVmReader method readSnapshotsSection.
@Override
protected void readSnapshotsSection(XmlNode section) {
XmlNodeList list = selectNodes(section, "Snapshot");
List<Snapshot> snapshots = new ArrayList<>();
_vm.setSnapshots(snapshots);
for (XmlNode node : list) {
XmlNode vmConfiguration = selectSingleNode(node, "VmConfiguration", _xmlNS);
Snapshot snapshot = new Snapshot(vmConfiguration != null);
snapshot.setId(new Guid(node.attributes.get("ovf:id").getValue()));
snapshot.setVmId(_vm.getId());
snapshot.setType(SnapshotType.valueOf(selectSingleNode(node, "Type", _xmlNS).innerText));
snapshot.setStatus(SnapshotStatus.OK);
snapshot.setDescription(selectSingleNode(node, "Description", _xmlNS).innerText);
XmlNode memory = selectSingleNode(node, "Memory", _xmlNS);
if (memory != null) {
List<Guid> guids = Guid.createGuidListFromString(memory.innerText);
snapshot.setMemoryDiskId(guids.get(2));
snapshot.setMetadataDiskId(guids.get(4));
}
final Date creationDate = OvfParser.utcDateStringToLocalDate(selectSingleNode(node, "CreationDate", _xmlNS).innerText);
if (creationDate != null) {
snapshot.setCreationDate(creationDate);
}
snapshot.setVmConfiguration(vmConfiguration == null ? null : new String(Base64.decodeBase64(vmConfiguration.innerText)));
XmlNode appList = selectSingleNode(node, "ApplicationList", _xmlNS);
if (appList != null) {
snapshot.setAppList(appList.innerText);
}
snapshots.add(snapshot);
}
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class OvfVmWriter method writeSnapshotsSection.
/**
* Write the snapshots of the VM.<br>
* If no snapshots were set to be written, this section will not be written.
*/
private void writeSnapshotsSection() {
List<Snapshot> snapshots = vm.getSnapshots();
if (snapshots == null || snapshots.isEmpty()) {
return;
}
_writer.writeStartElement("Section");
_writer.writeAttributeString(XSI_URI, "type", "ovf:SnapshotsSection_Type");
for (Snapshot snapshot : snapshots) {
_writer.writeStartElement("Snapshot");
_writer.writeAttributeString(getOvfUri(), "id", snapshot.getId().toString());
_writer.writeElement("Type", snapshot.getType().name());
_writer.writeElement("Description", snapshot.getDescription());
_writer.writeElement("CreationDate", OvfParser.localDateToUtcDateString(snapshot.getCreationDate()));
if (snapshot.containsMemory()) {
DiskImage memoryDump = memoryDisks.get(snapshot.getMemoryDiskId());
DiskImage memoryConf = memoryDisks.get(snapshot.getMetadataDiskId());
String memoryVolume = String.format("%1$s,%2$s,%3$s,%4$s,%5$s,%6$s", memoryDump.getStorageIds().get(0), memoryDump.getStoragePoolId(), memoryDump.getId(), memoryDump.getImageId(), memoryConf.getId(), memoryConf.getImageId());
_writer.writeElement("Memory", memoryVolume);
}
if (snapshot.getAppList() != null) {
_writer.writeElement("ApplicationList", snapshot.getAppList());
}
if (snapshot.getVmConfiguration() != null) {
_writer.writeElement("VmConfiguration", Base64.encodeBase64String(snapshot.getVmConfiguration().getBytes()));
}
_writer.writeEndElement();
}
_writer.writeEndElement();
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class RemoveCinderVolumeParentCommand method getSnapshotWithoutCinderVolume.
protected Snapshot getSnapshotWithoutCinderVolume(CinderDisk lastCinderVolume) {
Guid vmSnapshotId = lastCinderVolume.getVmSnapshotId();
Snapshot updated = null;
if (vmSnapshotId != null && !Guid.Empty.equals(vmSnapshotId)) {
Snapshot snapshot = snapshotDao.get(vmSnapshotId);
if (snapshot != null) {
updated = imagesHandler.prepareSnapshotConfigWithoutImageSingleImage(snapshot, lastCinderVolume.getImageId(), ovfManager);
}
}
return updated;
}
use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.
the class ExportVmCommand method endCopyCollapseOperations.
private void endCopyCollapseOperations(VM vm) {
vm.setVmtGuid(VmTemplateHandler.BLANK_VM_TEMPLATE_ID);
vm.setVmtName(null);
Snapshot activeSnapshot = snapshotDao.get(snapshotDao.getId(vm.getId(), SnapshotType.ACTIVE));
vm.setSnapshots(Collections.singletonList(activeSnapshot));
try {
updateCopyVmInSpm(getVm().getStoragePoolId(), vm, getParameters().getStorageDomainId());
} catch (EngineException e) {
log.error("Updating VM OVF in export domain failed.", e);
auditLogDirector.log(this, AuditLogType.IMPORTEXPORT_IMPORT_VM_FAILED_UPDATING_OVF);
}
}
Aggregations