mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 12:16:49 +00:00
fix(interfaces): a new interface never replaces one the host defines
- The create form refuses a name the host already defines. Defining it again replaced that interface's configuration, for example the host's own uplink when a bridge was named after it. - An interface that does not start is undefined again, so the name is free for another try; the name check above makes this safe.
This commit is contained in:
parent
09d7b0c08a
commit
484c544762
4 changed files with 35 additions and 11 deletions
|
|
@ -8,7 +8,7 @@ from vrtManager.connection import wvmConnect
|
|||
|
||||
class wvmInterfaces(wvmConnect):
|
||||
def define_iface(self, xml, flag=0):
|
||||
self.wvm.interfaceDefineXML(xml, flag)
|
||||
return self.wvm.interfaceDefineXML(xml, flag)
|
||||
|
||||
def bridge_member_xml(self, netdev):
|
||||
"""netdev as a bridge member: as the host defines it (a bond keeps its
|
||||
|
|
@ -69,9 +69,13 @@ class wvmInterfaces(wvmConnect):
|
|||
{self.bridge_member_xml(netdev)}
|
||||
</bridge>"""
|
||||
xml += """</interface>"""
|
||||
self.define_iface(xml)
|
||||
iface = self.get_iface(name)
|
||||
iface.create()
|
||||
# the form refuses a name the host defines, so nothing is replaced
|
||||
iface = self.define_iface(xml)
|
||||
try:
|
||||
iface.create()
|
||||
except libvirtError: # the name stays free for another try
|
||||
iface.undefine()
|
||||
raise
|
||||
|
||||
|
||||
class wvmInterface(wvmConnect):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue