Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for InstanceID as well when reading internal OVFs #761

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ private XmlNode getNode(XmlNodeList nodeList, String attributeName, String attri
return null;
}

protected String getInstanceIdValue(XmlNode node) {
XmlNode candidateNode = selectSingleNode(node, "rasd:InstanceId", _xmlNS);
// Some OVFs have InstanceID instead of InstanceId (e.g. generated by Oracle)
// So check for both values in the xml node
if (candidateNode == null) {
candidateNode = selectSingleNode(node, "rasd:InstanceID", _xmlNS);
}

return candidateNode.innerText;
}

protected void readSnapshotsSection(@SuppressWarnings("unused") XmlNode section) {
// The snapshot section only has meaning for VMs, and is overridden in OvfVmReader.
}
Expand Down Expand Up @@ -261,7 +272,7 @@ protected void readDisk(XmlNode node, DiskImage image) {
@Override
protected VmNetworkInterface getNetworkInterface(XmlNode node) {
// prior to 3.0 the instanceId is int , in 3.1 and on this is Guid
String str = selectSingleNode(node, VMD_ID, _xmlNS).innerText;
String str = getInstanceIdValue(node);
if (!StringUtils.isNumeric(str)) { // 3.1 and above OVF format
final Guid guid = new Guid(str);
VmNetworkInterface iface = interfaces.stream().filter(i -> i.getId().equals(guid)).findFirst().orElse(null);
Expand Down Expand Up @@ -329,7 +340,8 @@ protected void readOsSection(XmlNode section) {

@Override
protected void readDiskImageItem(XmlNode node) {
final Guid guid = new Guid(selectSingleNode(node, VMD_ID, _xmlNS).innerText);
String str = getInstanceIdValue(node);
final Guid guid = new Guid(str);
DiskImage image = _images.stream().filter(d -> d.getImageId().equals(guid)).findFirst().orElse(null);
if (image == null) {
return;
Expand Down