[libvirt-users] changeBegin() on python API

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. -- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

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() Michal

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. (To be more descriptive, virInterfaceChangeBegin() makes a copy of all network interface config for all interfaces on the host. You can then modify the network config as you wish (add/remove/modify interface configs), then when you're sure the new config works, call virInterfaceChangeCommit() to throw away the snapshotted copy of config. If the host is rebooted without calling virInterfaceChangeCommit(), an initscript (or whatever they call the equivalent in systemd) called during boot will replace the new network config with whatever it was at the time virInterfaceChangeBegin() was called. You can also force this rollback prior to boot by calling virinterfaceChangeRollback() (note that rollback only affects the config files, *not* the current working state of the network)).

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?
participants (3)
-
Laine Stump
-
Michal Privoznik
-
Ramon Medeiros