mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
VirtualNetworkInterface: Drop all XML __init__ params
This commit is contained in:
@@ -161,7 +161,9 @@ class Cloner(object):
|
||||
def set_clone_macs(self, mac):
|
||||
maclist = util.listify(mac)
|
||||
for m in maclist:
|
||||
VirtualNetworkInterface(self.conn, m)
|
||||
msg = VirtualNetworkInterface.is_conflict_net(self.conn, m)[1]
|
||||
if msg:
|
||||
raise RuntimeError(msg)
|
||||
|
||||
self._clone_macs = maclist
|
||||
def get_clone_macs(self):
|
||||
|
||||
@@ -134,12 +134,7 @@ class VirtualNetworkInterface(VirtualDevice):
|
||||
return (False, None)
|
||||
|
||||
|
||||
def __init__(self, conn, macaddr=None, type=TYPE_BRIDGE, bridge=None,
|
||||
network=None, model=None,
|
||||
parsexml=None, parsexmlnode=None):
|
||||
# pylint: disable=W0622
|
||||
# Redefining built-in 'type', but it matches the XML so keep it
|
||||
|
||||
def __init__(self, conn, parsexml=None, parsexmlnode=None):
|
||||
VirtualDevice.__init__(self, conn, parsexml, parsexmlnode)
|
||||
|
||||
self.virtualport = VirtualPort(conn, parsexml, parsexmlnode)
|
||||
@@ -148,19 +143,6 @@ class VirtualNetworkInterface(VirtualDevice):
|
||||
self._random_mac = None
|
||||
self._default_bridge = None
|
||||
|
||||
if self._is_parse():
|
||||
return
|
||||
|
||||
self.type = type
|
||||
if macaddr:
|
||||
self.macaddr = macaddr
|
||||
if bridge:
|
||||
self.bridge = bridge
|
||||
if network:
|
||||
self.network = network
|
||||
if model:
|
||||
self.model = model
|
||||
|
||||
|
||||
def _generate_default_bridge(self):
|
||||
ret = self._default_bridge
|
||||
@@ -218,7 +200,8 @@ class VirtualNetworkInterface(VirtualDevice):
|
||||
|
||||
_XML_ELEMENT_ORDER = ["source", "mac", "target", "model"]
|
||||
|
||||
type = XMLProperty(xpath="./@type")
|
||||
type = XMLProperty(xpath="./@type",
|
||||
default_cb=lambda s: s.TYPE_BRIDGE)
|
||||
|
||||
def _get_default_mac(self):
|
||||
if self._is_parse():
|
||||
|
||||
@@ -1547,12 +1547,8 @@ def parse_network(guest, optstring, dev=None, mac=None):
|
||||
elif "bridge" in opts:
|
||||
net_type = VirtualNetworkInterface.TYPE_BRIDGE
|
||||
|
||||
# Build initial device
|
||||
if not dev:
|
||||
dev = VirtualNetworkInterface(conn=guest.conn,
|
||||
type=net_type,
|
||||
network=opts.get("network"),
|
||||
bridge=opts.get("bridge"))
|
||||
dev = VirtualNetworkInterface(conn=guest.conn)
|
||||
|
||||
if mac and not "mac" in opts:
|
||||
opts["mac"] = mac
|
||||
|
||||
Reference in New Issue
Block a user