use of org.ovirt.engine.core.utils.ovf.xml.XmlDocument in project ovirt-engine by oVirt.
the class OvfManager method importVm.
public void importVm(String ovfstring, VM vm, FullEntityOvfData fullEntityOvfData) throws OvfReaderException {
OvfReader ovf = null;
try {
ovf = new OvfVmReader(new XmlDocument(ovfstring), vm, fullEntityOvfData, osRepository);
ovf.build();
initIcons(vm.getStaticData());
} catch (Exception ex) {
String message = generateOvfReaderErrorMessage(ovf, ex);
logOvfLoadError(message, ovfstring);
throw new OvfReaderException(message);
}
Guid id = vm.getStaticData().getId();
fullEntityOvfData.getInterfaces().forEach(iface -> iface.setVmId(id));
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlDocument in project ovirt-engine by oVirt.
the class ScanStorageForUnregisteredDisksCommand method setVmsForUnregisteredDisks.
protected void setVmsForUnregisteredDisks(List<OvfEntityData> allEntities) {
for (OvfEntityData ovfEntity : allEntities) {
try {
XmlDocument xmlDocument = new XmlDocument(ovfEntity.getOvfData());
ovfUtils.updateUnregisteredDisksWithVMs(unregisteredDisks, ovfEntity.getEntityId(), ovfEntity.getEntityName(), xmlDocument);
} catch (Exception e) {
log.warn("Could not parse OVF data of VM");
continue;
}
}
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlDocument in project ovirt-engine by oVirt.
the class OvfUtils method analyzeOvfFile.
private void analyzeOvfFile(List<UnregisteredDisk> unregisteredDisks, Guid storageDomainId, List<OvfEntityData> ovfEntityDataFromTar, Entry<String, ByteBuffer> fileEntry) {
String ovfData = new String(fileEntry.getValue().array());
VmEntityType vmType = getVmEntityType(ovfData);
ArchitectureType archType = null;
Guid entityId = getEntityId(fileEntry.getKey());
String vmName = getEntityName(ovfData);
try {
XmlDocument xmlDocument = new XmlDocument(ovfData);
archType = getOsSection(xmlDocument);
if (isExternalVM(xmlDocument)) {
log.warn("Retrieve an external OVF Entity from storage domain ID '{}' for entity ID '{}'," + " entity name '{}' and VM Type of '{}'." + " This OVF will be ignored since external VMs should not be restored.", storageDomainId, getEntityId(fileEntry.getKey()), getEntityName(ovfData), vmType.name());
return;
}
updateUnregisteredDisksWithVMs(unregisteredDisks, entityId, vmName, xmlDocument);
} catch (Exception e) {
log.error("Could not parse VM's disks or architecture, file name: {}, content size: {}, error: {}", fileEntry.getKey(), ovfData.length(), e.getMessage());
log.debug("Exception", e);
return;
}
// Creates an OVF entity data.
OvfEntityData ovfEntityData = createOvfEntityData(storageDomainId, ovfData, vmType, vmName, archType, entityId);
log.info("Retrieve OVF Entity from storage domain ID '{}' for entity ID '{}', entity name '{}' and VM Type of '{}'", storageDomainId, getEntityId(fileEntry.getKey()), getEntityName(ovfData), vmType.name());
ovfEntityDataFromTar.add(ovfEntityData);
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlDocument in project ovirt-engine by oVirt.
the class OvfUtilsTest method testUpdateUnregisteredDisksWithVMsWithEmptyUnregDisks.
@Test
public void testUpdateUnregisteredDisksWithVMsWithEmptyUnregDisks() throws Exception {
XmlDocument xmlDocument = new XmlDocument(getXmlOvfData());
List<UnregisteredDisk> unregDisks = new ArrayList<>();
ovfUtils.updateUnregisteredDisksWithVMs(unregDisks, Guid.newGuid(), "TestVM", xmlDocument);
assertTrue("The list of disks should not be empty", unregDisks.isEmpty());
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlDocument in project ovirt-engine by oVirt.
the class OvfUtilsTest method testMemoryDisks.
@Test
public void testMemoryDisks() throws Exception {
XmlDocument xmlDocument = new XmlDocument(getXmlOvfData());
Set<Guid> memoryDisks = ovfUtils.fetchMemoryDisks(xmlDocument);
assertFalse("The list of memory disks for snapshot should not be empty", memoryDisks.isEmpty());
}
Aggregations