Petr Horáček has uploaded a new change for review. Change subject: hooks: ovs: skip non-vNic device's XML ......................................................................
hooks: ovs: skip non-vNic device's XML If other than a vNic device is passed to OVS hook's before_device_create, we end with an IndexError, because of XML does not contain all required tags. If such error occurs, return unchanged XML, Change-Id: I457d43847f07cccbd56b562fbc7c111a0bb0e1a3 Signed-off-by: Petr Horáček <[email protected]> --- M vdsm_hooks/ovs/ovs_before_device_create.py 1 file changed, 17 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/83/49183/1 diff --git a/vdsm_hooks/ovs/ovs_before_device_create.py b/vdsm_hooks/ovs/ovs_before_device_create.py index 531001a..7153315 100755 --- a/vdsm_hooks/ovs/ovs_before_device_create.py +++ b/vdsm_hooks/ovs/ovs_before_device_create.py @@ -31,11 +31,15 @@ """ Modify interface XML in Libvirt to proper OVS configuration if OVS network is set as a source. """ - running_config = RunningConfig() + try: + iface = domxml.getElementsByTagName('interface')[0] + source = iface.getElementsByTagName('source')[0] + source_bridge = source.getAttribute('bridge') + except IndexError: + # This is not a vNic device + return - iface = domxml.getElementsByTagName('interface')[0] - source = iface.getElementsByTagName('source')[0] - source_bridge = source.getAttribute('bridge') + running_config = RunningConfig() network = running_config.networks.get(source_bridge) if network is None: @@ -118,6 +122,15 @@ </interface>""" assert updated_device == expected_device + # Other than vNic devices are ignored + iface = minidom.parseString("""<?xml version="1.0" encoding="utf-8"?> +<foodevice foo="bar" \>""") + ovs_device(iface) + updated_device = pretty_xml(iface) + expected_device = """<?xml version="1.0" encoding="utf-8"?> +<foodevice foo="bar" \>""" + assert updated_device == expected_device + print("OK") -- To view, visit https://gerrit.ovirt.org/49183 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I457d43847f07cccbd56b562fbc7c111a0bb0e1a3 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr Horáček <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
