use of org.ovirt.engine.core.utils.ovf.xml.XmlNode in project ovirt-engine by oVirt.
the class OvfVmReader method readAffinityLabelsSection.
@Override
protected void readAffinityLabelsSection(XmlNode section) {
XmlNodeList list = selectNodes(section, OvfProperties.AFFINITY_LABEL);
List<Label> affinityLabels = new ArrayList<>();
for (XmlNode node : list) {
String affinityLabelName = node.attributes.get("ovf:name").innerText;
LabelBuilder builder = new LabelBuilder();
Label label = builder.name(affinityLabelName).build();
affinityLabels.add(label);
}
fullEntityOvfData.setAffinityLabels(affinityLabels);
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNode in project ovirt-engine by oVirt.
the class OvfVmReader method readAffinityGroupsSection.
@Override
protected void readAffinityGroupsSection(XmlNode section) {
XmlNodeList list = selectNodes(section, OvfProperties.AFFINITY_GROUP);
List<AffinityGroup> affinityGroups = new ArrayList<>();
for (XmlNode node : list) {
String affinityGroupName = node.attributes.get("ovf:name").innerText;
AffinityGroup affinityGroup = new AffinityGroup();
affinityGroup.setName(affinityGroupName);
affinityGroups.add(affinityGroup);
}
fullEntityOvfData.setAffinityGroups(affinityGroups);
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNode 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.utils.ovf.xml.XmlNode in project ovirt-engine by oVirt.
the class OvfUtils method fetchVmDisks.
public Set<Guid> fetchVmDisks(XmlDocument xmlDocument) {
Set<Guid> disksIds = new HashSet<>();
XmlNode references = xmlDocument.selectSingleNode("//*/References");
// we assume that all files in OVFs that are generated by oVirt are disks
for (XmlNode file : references.selectNodes("File")) {
disksIds.add(Guid.createGuidFromString(file.attributes.get("ovf:href").getValue().substring(0, GUID_LENGTH)));
}
disksIds.addAll(fetchMemoryDisks(xmlDocument));
return disksIds;
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNode in project ovirt-engine by oVirt.
the class OvfUtils method fetchMemoryDisks.
public Set<Guid> fetchMemoryDisks(XmlDocument xmlDocument) {
Set<Guid> memoryDiskIds = new HashSet<>();
xmlDocument.selectNodes("ovf:SnapshotsSection_Type");
XmlNode content = xmlDocument.selectSingleNode("//*/Content");
XmlNodeList nodeList = content.selectNodes("Section");
if (nodeList != null) {
for (XmlNode section : nodeList) {
String value = section.attributes.get("xsi:type").getValue();
if (value.equals("ovf:SnapshotsSection_Type")) {
Iterator<XmlNode> snapshotIter = section.selectNodes("Snapshot").iterator();
while (snapshotIter.hasNext()) {
XmlNode memorySnapshot = snapshotIter.next().selectSingleNode("Memory");
if (memorySnapshot != null) {
List<Guid> guids = Guid.createGuidListFromString(memorySnapshot.innerText);
memoryDiskIds.add(guids.get(2));
memoryDiskIds.add(guids.get(4));
}
}
}
}
}
return memoryDiskIds;
}
Aggregations