Skip to content

Commit

Permalink
Detach 4.3 SD and attach it to 4.4 env fails with error 'Error parsin…
Browse files Browse the repository at this point in the history
…g OVF due to OVF error: ol8-clone: cannot read 'rasd:InstanceId' with value: null'. Ref bug change https://bugzilla.redhat.com/show_bug.cgi?id=1850103
  • Loading branch information
shubhaOracle committed Nov 18, 2022
1 parent 9f6d043 commit cf26412
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ private XmlNode getNode(XmlNodeList nodeList, String attributeName, String attri
return null;
}

protected String getInstanceIdValue(XmlNode node) {
XmlNode candidateNode = selectSingleNode(node, "rasd:InstanceID", _xmlNS);
//Also there is a defect that has key InstanceID as InstanceId in old oVirt releases
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 +271,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 +339,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

0 comments on commit cf26412

Please sign in to comment.