Question

I need to be able to export the domain's XML configs to XEN config format under libvirt using libvirt-python. Apparently to make that call, you use the following in C:

virConnectDomainXMLToNative

Reads a domain XML configuration document, and generates a native configuration file describing the domain. The format of the native data is hypervisor dependant.

conn:   a connection object
nativeFormat:   configuration format exporting to
domainXml:  the domain configuration to export
flags:  extra flags; not used yet, so callers should always pass 0
Returns:    a 0 terminated UTF-8 encoded native config datafile, or NULL in case of error. the caller must free() the returned value.

However, there is no equivalent function in Python.

I noticed you can call certain C functions in libvirt-python. I don't see that in the current list of calls, though, when I use help(libvirt). (I am using the libvirt-python package that is available with CentOS 5, BTW).

Is there a way to make that call anyway within Python and convert the domain .xml to xen config?

Était-ce utile?

La solution

According to the Python API bindings page, functions starting with virConnect are mapped to methods of a virConnect object in Python. So you should create a virConnect object and then call its domainXMLToNative method.

If that still doesn't work, you can use the ctypes module to call functions from a shared library.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top