use of org.ovirt.engine.core.utils.ovf.xml.XmlDocument in project ovirt-engine by oVirt.
the class OvfUtilsTest method testUpdateUnregisteredDisksWithVMsWithInitializedUnregDisks.
@Test
public void testUpdateUnregisteredDisksWithVMsWithInitializedUnregDisks() throws Exception {
XmlDocument xmlDocument = new XmlDocument(getXmlOvfData());
List<UnregisteredDisk> unregDisks = new ArrayList<>();
DiskImage diskImage = new DiskImage();
diskImage.setId(Guid.createGuidFromString("8c634412-1e8b-4ef3-bc40-b67a456e9d2f"));
diskImage.setStorageIds(new ArrayList<>(Collections.singletonList(Guid.createGuidFromString("7e2a7eac-3b76-4d45-a7dd-caae8fe0f588"))));
UnregisteredDisk unregDisk = new UnregisteredDisk(diskImage);
unregDisks.add(unregDisk);
ovfUtils.updateUnregisteredDisksWithVMs(unregDisks, Guid.newGuid(), "TestVM", xmlDocument);
assertTrue("The list of disks should not be empty", !unregDisks.isEmpty());
assertTrue("The VMs id is set in the unregisteterd disks", !unregDisks.get(0).getVms().isEmpty());
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlDocument in project ovirt-engine by oVirt.
the class OvfUtilsTest method testIsExternalVM.
@Test
public void testIsExternalVM() throws Exception {
XmlDocument xmlDocument = new XmlDocument(getXmlOvfData());
assertFalse("VM should not be external VM", ovfUtils.isExternalVM(xmlDocument));
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlDocument in project ovirt-engine by oVirt.
the class OvfManager method importVmFromOva.
public void importVmFromOva(String ovfstring, VM vm, FullEntityOvfData fullEntityOvfData) throws OvfReaderException {
OvfReader ovf = null;
try {
ovf = new OvfOvaReader(new XmlDocument(ovfstring), fullEntityOvfData, vm, osRepository);
ovf.build();
} 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 OvfUtils method fetchLeaseDomainId.
public static Guid fetchLeaseDomainId(String ovfData) {
Guid leaseDomainId = null;
try {
XmlDocument xmlDocument = new XmlDocument(ovfData);
XmlNode xmlNode = xmlDocument.selectSingleNode("//*/Content").selectSingleNode("LeaseDomainId");
if (xmlNode != null) {
leaseDomainId = Guid.createGuidFromString(xmlNode.innerText);
}
} catch (Exception e) {
log.debug("failed to parse a given ovf configuration: \n" + ovfData, e);
}
return leaseDomainId;
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlDocument in project ovirt-engine by oVirt.
the class VmDevicesConverterTest method parseVolumeChainNoItem.
@Test
public void parseVolumeChainNoItem() throws Exception {
XmlDocument devices = new XmlDocument(DEVICES_XML);
List<Map<String, Object>> res = converter.parseVolumeChain(devices.selectSingleNode("//*/disk[1]"));
assertEquals(0, res.size());
}
Aggregations