Antoni Segura Puimedon has uploaded a new change for review.
Change subject: arbitrary_vlan_name: Fix network deletion
......................................................................
arbitrary_vlan_name: Fix network deletion
Up until now, when the network deletion operations were not being
forced, the assertion that the bridge was clean, i.e., that it did
not have other ports (vnics most likely) would fail because it
expected
bondname.vlanid
or
nic.vlanid
when the name could be any string. This patch addresses the issue
by making netinfo give us the exact vlan name.
Change-Id: I715806db38ce621098fe5f364e16e874a5ed01ed
Bug-Url:
http://bugzilla.redhat.com/1119182
Signed-off-by: Antoni S. Puimedon <asegurap(a)redhat.com>
---
M lib/vdsm/netinfo.py
M vdsm/network/api.py
M vdsm/network/models.py
3 files changed, 28 insertions(+), 17 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/30013/1
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index 95c3860..d7e7b6c 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -929,6 +929,7 @@
def getNicsVlanAndBondingForNetwork(self, network):
vlan = None
+ vlanid = None
bonding = None
lnics = []
@@ -943,7 +944,8 @@
if port in self.vlans:
assert vlan is None
nic = getVlanDevice(port)
- vlan = getVlanID(port)
+ vlanid = getVlanID(port)
+ vlan = port # vlan devices can have an arbitrary name
assert self.vlans[port]['iface'] == nic
port = nic
if port in self.bondings:
@@ -953,7 +955,7 @@
elif port in self.nics:
lnics.append(port)
- return lnics, vlan, bonding
+ return lnics, vlan, vlanid, bonding
def ifaceUsers(self, iface):
"Returns a list of entities using the interface"
diff --git a/vdsm/network/api.py b/vdsm/network/api.py
index ba99f3e..32e26c1 100755
--- a/vdsm/network/api.py
+++ b/vdsm/network/api.py
@@ -66,7 +66,7 @@
persistence = _getPersistenceModule()
-def objectivizeNetwork(bridge=None, vlan=None, bonding=None,
+def objectivizeNetwork(bridge=None, vlan=None, vlan_id=None, bonding=None,
bondingOptions=None, nics=None, mtu=None, ipaddr=None,
netmask=None, gateway=None, bootproto=None,
ipv6addr=None, ipv6gateway=None, ipv6autoconf=None,
@@ -78,7 +78,8 @@
that is passed in the parameters.
:param bridge: name of the bridge.
- :param vlan: vlan tag id.
+ :param vlan: vlan device name.
+ :param vlan_id: vlan tag id.
:param bonding: name of the bond.
:param bondingOptions: bonding options separated by spaces.
:param nics: list of nic names.
@@ -129,7 +130,10 @@
'enslaved to %s' % (nic, bond))
topNetDev = Nic(nic, configurator, mtu=mtu, _netinfo=_netinfo)
if vlan is not None:
- topNetDev = Vlan(topNetDev, vlan, configurator, mtu=mtu)
+ tag = netinfo.getVlanID(vlan) if vlan_id is None else vlan_id
+ topNetDev = Vlan(topNetDev, tag, configurator, mtu=mtu, name=vlan)
+ elif vlan_id is not None:
+ topNetDev = Vlan(topNetDev, vlan_id, configurator, mtu=mtu)
if bridge is not None:
stp = None
if 'stp' in opts:
@@ -315,7 +319,7 @@
bootproto = options.pop('bootproto', None)
netEnt = objectivizeNetwork(
- bridge=network if bridged else None, vlan=vlan, bonding=bonding,
+ bridge=network if bridged else None, vlan_id=vlan, bonding=bonding,
bondingOptions=bondingOptions, nics=nics, mtu=mtu, ipaddr=ipaddr,
netmask=netmask, gateway=gateway, bootproto=bootproto,
blockingdhcp=blockingdhcp, ipv6addr=ipv6addr, ipv6gateway=ipv6gateway,
@@ -332,7 +336,7 @@
ports = set(netinfo.ports(bridge))
ifaces = set(nics)
if vlan is not None:
- ifaces.add('%s.%s' % ((bonding or nics[0]), vlan))
+ ifaces.add(vlan)
else:
ifaces.add(bonding)
@@ -352,7 +356,8 @@
bridged = _netinfo.networks[network]['bridged']
print "Network %s(Bridged: %s):" % (network, bridged)
- nics, vlan, bonding = _netinfo.getNicsVlanAndBondingForNetwork(network)
+ nics, vlan, vlan_id, bonding = _netinfo.getNicsVlanAndBondingForNetwork(
+ network)
if bridged:
ipaddr = _netinfo.networks[network]['addr']
@@ -365,7 +370,7 @@
netmask = _netinfo.nics[iface]['netmask']
print "ipaddr=%s, netmask=%s" % (ipaddr, netmask)
- print "vlan=%s, bonding=%s, nics=%s" % (vlan, bonding, nics)
+ print "vlan=%s, bonding=%s, nics=%s" % (vlan_id, bonding, nics)
def listNetworks():
@@ -408,8 +413,9 @@
def _delNonVdsmNetwork(network, vlan, bonding, nics, _netinfo, configurator):
if network in netinfo.bridges():
- netEnt = objectivizeNetwork(bridge=network, vlan=vlan, bonding=bonding,
- nics=nics, _netinfo=_netinfo,
+ netEnt = objectivizeNetwork(bridge=network, vlan_id=vlan,
+ bonding=bonding, nics=nics,
+ _netinfo=_netinfo,
configurator=configurator,
implicitBonding=False)
netEnt.remove()
@@ -436,7 +442,8 @@
configurator)
return
- nics, vlan, bonding = _netinfo.getNicsVlanAndBondingForNetwork(network)
+ nics, vlan, vlan_id, bonding = _netinfo.getNicsVlanAndBondingForNetwork(
+ network)
bridged = _netinfo.networks[network]['bridged']
logging.info("Removing network %s with vlan=%s, bonding=%s, nics=%s,"
@@ -446,8 +453,8 @@
_validateDelNetwork(network, vlan, bonding, nics, bridged, _netinfo)
netEnt = objectivizeNetwork(bridge=network if bridged else None, vlan=vlan,
- bonding=bonding, nics=nics, _netinfo=_netinfo,
- configurator=configurator,
+ vlan_id=vlan_id, bonding=bonding, nics=nics,
+ _netinfo=_netinfo, configurator=configurator,
implicitBonding=implicitBonding)
netEnt.ip.bootproto = netinfo.getBootProtocol(netEnt.name)
diff --git a/vdsm/network/models.py b/vdsm/network/models.py
index 402a4b5..c3b9409 100644
--- a/vdsm/network/models.py
+++ b/vdsm/network/models.py
@@ -115,7 +115,8 @@
class Vlan(NetDevice):
MAX_ID = 4094
- def __init__(self, device, tag, configurator, ipconfig=None, mtu=None):
+ def __init__(self, device, tag, configurator, ipconfig=None, mtu=None,
+ name=None):
self.validateTag(tag)
if device is None:
raise ConfigNetworkError(ne.ERR_BAD_PARAMS, 'Missing required vlan'
@@ -123,8 +124,9 @@
device.master = self
self.device = device
self.tag = tag
- super(Vlan, self).__init__('%s.%s' % (device.name, tag), configurator,
- ipconfig, mtu)
+ # control for arbitrary vlan names
+ name = '%s.%s' % (device.name, tag) if name is None else name
+ super(Vlan, self).__init__(name, configurator, ipconfig, mtu)
def __repr__(self):
return 'Vlan(%s: %r)' % (self.name, self.device)
--
To view, visit
http://gerrit.ovirt.org/30013
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I715806db38ce621098fe5f364e16e874a5ed01ed
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap(a)redhat.com>