Product SiteDocumentation Site

7.4.2. Undefining an interface configuration

The undefine method completely and permanently removes the configuration for the given interface from the host's configuration files. If you want to recreate this configuration again in the future, you should invoke the XMLDesc method and save the string prior to the undefine.

Example 7.13. Undefining br0 interface after saving its XML data

#!/usr/bin/env python3
import sys
import libvirt

conn = None
    conn ="qemu:///system")
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)

iface = conn.interfaceLookupByName('br0')

# get the xml prior to undefining the interface
xml = iface.XMLDesc(0)
# now undefine the interface
# the interface is now undefined and the iface variable is no longer be usable