On 11/02/2015 09:48 AM, Laine Stump wrote:
On 10/30/2015 07:02 AM, Michal Privoznik wrote:
> On 29.10.2015 15:22, Ramon Medeiros wrote:
>> Hi,
>>
>> is changeBegin() working on python? I was trying to use the following
>> method:
>>
>> if = conn.interfaceLookupByName("name")
>> if.undefine()
>>
>> I saw that changeBegin() does not commit changes, but i can't use it.
>>
> This python API boils down to virInterfaceChangeBegin() but as such it's
> implemented just for netcf backend. So if you're on a distro where udev
> is used instead, the API will return an error.
> Otherwise, this should work:
>
> if = conn.interfaceLookupByName("name")
> if.changeBegin()
> if.undefine()
>
> /* test if the connectivity to the host was not lost */
>
> if.changeCommit()
I haven't ever used the python bindings for the interface APIs, but if
changeBegin is implemented as a method of an interface, that is wrong
- virInterfaceChangeBegin() saves all the config for *all* interfaces
on the host, so it should instead be a method of the connection.
I just tried this out and found that virInterfaceChangeBegin() *is* a
method of the conn rather than the interface, but it is named
"changeBegin" rather than "interfaceChangeBegin", which would have
made
more sense (but since the python names are auto-generated, and the
addition of the new API didn't ring any alarm bells to suggest manual
intervention in generator.py, the clumsy autogenerated name has stood
for 4 1/2 years). I suppose it's much too late to change it now :-/
I wonder what kind of semi-automated process we can put in place to
prevent something like this from happening in the future? A script
that's run as part of make dist in libvirt-python that creates a list of
all new libvirt APIs added since the previous release of libvirt-python,
along with their corresponding names in python?