use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList in project ovirt-engine by oVirt.
the class OvfOvirtReader method buildNicReference.
protected void buildNicReference() {
XmlNodeList list = selectNodes(_document, "//*/Nic", _xmlNS);
for (XmlNode node : list) {
VmNetworkInterface iface = new VmNetworkInterface();
iface.setId(new Guid(node.attributes.get("ovf:id").getValue()));
interfaces.add(iface);
}
if (!list.iterator().hasNext()) {
String pattern = "//*/Item[" + VMD_RESOURCE_TYPE + "=" + OvfHardware.Network + "]";
list = selectNodes(_document, pattern, _xmlNS);
int nicIdx = 0;
for (XmlNode node : list) {
VmNetworkInterface iface = new VmNetworkInterface();
iface.setId(Guid.newGuid());
updateSingleNic(node, iface, ++nicIdx);
interfaces.add(iface);
}
}
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList in project ovirt-engine by oVirt.
the class OvfOvirtReader method buildVirtualSystem.
@Override
public void buildVirtualSystem() {
XmlNode virtualSystem = selectSingleNode(_document, "//*/Content");
consumeReadProperty(virtualSystem, NAME, val -> fullEntityOvfData.getVmBase().setName(val));
// set ovf version to the ovf object
fullEntityOvfData.getVmBase().setOvfVersion(getVersion());
XmlNodeList list = selectNodes(virtualSystem, "Section");
if (list != null) {
// The Os need to be read before the hardware
XmlNode node = getNode(list, "xsi:type", "ovf:OperatingSystemSection_Type");
if (node != null) {
readOsSection(node);
if (!osRepository.isLinux(fullEntityOvfData.getVmBase().getOsId()) || fullEntityOvfData.getVmBase().getDefaultDisplayType() != DisplayType.qxl) {
fullEntityOvfData.getVmBase().setSingleQxlPci(false);
}
}
node = getNode(list, "xsi:type", "ovf:VirtualHardwareSection_Type");
if (node != null) {
readHardwareSection(node);
}
node = getNode(list, "xsi:type", "ovf:SnapshotsSection_Type");
if (node != null) {
readSnapshotsSection(node);
}
node = getNode(list, "xsi:type", "ovf:AffinityGroupsSection_Type");
if (node != null) {
readAffinityGroupsSection(node);
}
node = getNode(list, "xsi:type", "ovf:AffinityLabelsSection_Type");
if (node != null) {
readAffinityLabelsSection(node);
}
node = getNode(list, "xsi:type", "ovf:UserDomainsSection_Type");
if (node != null) {
readUserDomainsSection(node);
}
}
readGeneralData(virtualSystem);
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList in project ovirt-engine by oVirt.
the class OvfReader method readDedicatedHostsList.
private void readDedicatedHostsList() {
// initialize to empty list
vmBase.setDedicatedVmForVdsList(new LinkedList<>());
// search all dedicated hosts with xPath
XmlNodeList hostsList = selectNodes(_document, "//*/Content/" + DEDICATED_VM_FOR_VDS);
for (XmlNode hostNode : hostsList) {
if (hostNode != null && StringUtils.isNotEmpty(hostNode.innerText)) {
vmBase.getDedicatedVmForVdsList().add(Guid.createGuidFromString(hostNode.innerText));
}
}
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList 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.XmlNodeList 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);
}
Aggregations