Change in vdsm[master]: mom: add mom balloon functional tests for running vms
by gvallare@redhat.com
Giuseppe Vallarelli has posted comments on this change.
Change subject: mom: add mom balloon functional tests for running vms
......................................................................
Patch Set 6: I would prefer that you didn't submit this
--
To view, visit http://gerrit.ovirt.org/13156
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I922568233dc769d83e2fdffe1c24439d13d03d7e
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mei Liu <liumbj(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Doron Fediuck <dfediuck(a)redhat.com>
Gerrit-Reviewer: Giuseppe Vallarelli <gvallare(a)redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Martin Sivák <msivak(a)redhat.com>
Gerrit-Reviewer: Mei Liu <liumbj(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
10 years, 12 months
Change in vdsm[master]: mom: add mom balloon functional tests for running vms
by gvallare@redhat.com
Giuseppe Vallarelli has posted comments on this change.
Change subject: mom: add mom balloon functional tests for running vms
......................................................................
Patch Set 6: (3 inline comments)
-1 Some questions need answers.
....................................................
File tests/functional/momTests.py
Line 41:
Line 42: def setUp(self):
Line 43: self.s = vdscli.connect()
Line 44:
Line 45: def assertOK(self, result):
Hi Mei I've been working on a first patch for functional tests networking side (http://gerrit.ovirt.org/#/c/14840/19), perhaps you may find useful the VdsProxy class that I defined in the utils module. If you look at it you will find that vdsm verbs have been abstracted to save some boilerplate, you coded assertOK exactly for the same reason, to save yourself from unpacking verb result and message.
I wonder if it make sense for us to code little utilities, slightly different for every functional test module instead of having a uniform way to implement vdsm functional tests.
Line 46: # code == 0 means OK
Line 47: self.assertEquals(
Line 48: result['status']['code'], 0, str(result))
Line 49:
Line 154: raise SkipTest('No VM can be candidate of ballooning operation.')
Line 155:
Line 156: self._setPolicy(operation)
Line 157: # Wait for the policy taking effect
Line 158: time.sleep(35)
Mei is there a reason for having in testKSM a sleep for 10 secs and here 35 ? You can consider the slowtest decoration within testValidation module for these kind of tests.
Line 159:
Line 160: self._checkResult(operation, vmsOldStats)
Line 161:
Line 162: @testValidation.ValidateRunningAsRoot
Line 162: @testValidation.ValidateRunningAsRoot
Line 163: def testBalloonShrink(self):
Line 164: self._basicBalloon("Shrink")
Line 165:
Line 166: @testValidation.ValidateRunningAsRoot
I'm not a big fan of this style of testing. I can understand that this behaviour is complex but that's not a good reason to not identify the 3 stages of test: Arrange (you prepare all necessary preconditions and inputs), Act (you exercise the code under test), Assert (you verify the expected result) - you did in testKSM; also every function in this module contains some assertion, do all assertions have the same value for the behaviour under test ? I wonder if the needed code to test the balloon should be somewhere else because there's enough logic to create a test for the test (not your fault).
Line 167: def testBalloonGrow(self):
--
To view, visit http://gerrit.ovirt.org/13156
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I922568233dc769d83e2fdffe1c24439d13d03d7e
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mei Liu <liumbj(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Doron Fediuck <dfediuck(a)redhat.com>
Gerrit-Reviewer: Giuseppe Vallarelli <gvallare(a)redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Martin Sivák <msivak(a)redhat.com>
Gerrit-Reviewer: Mei Liu <liumbj(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
10 years, 12 months
Change in vdsm[master]: Simplify setNewMtu()
by wudxw@linux.vnet.ibm.com
Mark Wu has uploaded a new change for review.
Change subject: Simplify setNewMtu()
......................................................................
Simplify setNewMtu()
It will update the interface's MTU only if its user being removed has
the maximum MTU.
Change-Id: I32e8e0d45b7887af8fd1b003fd4c358826b77289
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
---
M vdsm/configNetwork.py
M vdsm/netconf/ifcfg.py
2 files changed, 32 insertions(+), 57 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/55/15355/1
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 6809e98..525996c 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -303,7 +303,6 @@
if not utils.tobool(force):
_validateDelNetwork(network, vlan, bonding, nics, bridged, _netinfo)
- configWriter.setNewMtu(network=network, bridged=bridged, _netinfo=_netinfo)
configurator.removeLibvirtNetwork(network)
# We need to gather NetInfo again to refresh networks info from libvirt.
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index e023e99..02ee20e 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -36,7 +36,7 @@
from vdsm import libvirtconnection
from vdsm import netinfo
from vdsm import utils
-from netmodels import Bridge
+from netmodels import Bond, Vlan, Bridge
import neterrors as ne
@@ -167,6 +167,7 @@
bridge.port.remove()
def removeVlan(self, vlan):
+ vlan.mtu = netinfo.getMtu(vlan.name)
ifdown(vlan.name)
self.configWriter.removeVlan(vlan.name)
vlan.device.remove()
@@ -177,8 +178,10 @@
ifdown(iface.name)
multiple_usage = _netinfo.ifaceHasMultiUsers(iface.name)
yield not multiple_usage
- if multiple_usage and iface.master is None:
- self.configWriter.removeIpConfig(iface.name)
+ if multiple_usage:
+ self._setNewMtu(iface, _netinfo=_netinfo)
+ if iface.master is None:
+ self.configWriter.removeIpConfig(iface.name)
if not hasattr(iface, 'destroy'):
ifup(iface.name)
@@ -196,6 +199,32 @@
with self.removeIface(nic) as to_be_removed:
if to_be_removed:
self.configWriter.removeNic(nic.name)
+
+ def _setNewMtu(self, iface, _netinfo=None):
+ """
+ Update an interface's MTU when one of its users is removed.
+
+ :param iface: interface object (bond or nic device)
+ :type iface: NetDevice instance
+
+ """
+ ifaceMtu = netinfo.getMtu(iface.name)
+ if isinstance(iface.master, Vlan):
+ if iface.master.mtu < ifaceMtu:
+ return
+
+ vlans = _netinfo.getVlansForIface(iface.name)
+ try:
+ maxMtu = max(int(netinfo.getMtu(iface.name + '.' + vlan))
+ for vlan in vlans)
+ except ValueError:
+ maxMtu = None
+
+ if maxMtu and maxMtu < ifaceMtu:
+ if isinstance(iface, Bond):
+ self.configWriter.setBondingMtu(iface.name, maxMtu)
+ else:
+ self.configWriter.setIfaceMtu(iface.name, maxMtu)
class ConfigWriter(object):
@@ -704,59 +733,6 @@
slaves = netinfo.slaves(bonding)
for slave in slaves:
self.setIfaceMtu(slave, newmtu)
-
- def setNewMtu(self, network, bridged, _netinfo=None):
- """
- Set new MTU value to network and its interfaces
-
- :param network: network name
- :type network: string
- :param bridged: network type (bridged or bridgeless)
- :type bridged: bool
-
- Update MTU to devices (vlans, bonds and nics)
- or added a new value
- """
- if _netinfo is None:
- _netinfo = netinfo.NetInfo()
- currmtu = None
- if bridged:
- try:
- currmtu = int(netinfo.getMtu(network))
- except IOError as e:
- if e.errno != os.errno.ENOENT:
- raise
-
- nics, delvlan, bonding = \
- _netinfo.getNicsVlanAndBondingForNetwork(network)
- if delvlan is None:
- return
-
- iface = bonding if bonding else nics[0]
- vlans = _netinfo.getVlansForIface(iface)
-
- newmtu = None
- for vlan in vlans:
- cf = netinfo.NET_CONF_PREF + iface + '.' + vlan
- mtu = self._getConfigValue(cf, 'MTU')
- if mtu:
- mtu = int(mtu)
-
- if vlan == delvlan:
- # For VLANed bridgeless networks use MTU of delvlan
- # as current MTU
- if not bridged and mtu:
- currmtu = mtu
- continue
-
- newmtu = max(newmtu, mtu)
-
- # Optimization: if network hasn't custom MTU (currmtu), do nothing
- if currmtu and newmtu != currmtu:
- if bonding:
- self.setBondingMtu(bonding, newmtu)
- else:
- self.setIfaceMtu(nics[0], newmtu)
def ifdown(iface):
--
To view, visit http://gerrit.ovirt.org/15355
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I32e8e0d45b7887af8fd1b003fd4c358826b77289
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mark Wu <wudxw(a)linux.vnet.ibm.com>
10 years, 12 months
Change in vdsm[master]: gluster: fix remove disabled hook exception handling error
by tjeyasin@redhat.com
Hello Ayal Baron, Bala.FA, Saggi Mizrahi, Dan Kenigsberg,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/15506
to review the following change.
Change subject: gluster: fix remove disabled hook exception handling error
......................................................................
gluster: fix remove disabled hook exception handling error
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=971775
Change-Id: Ie37e27f2a42e663c74fa2f8a3f43f31b28a72840
Signed-off-by: Timothy Asir <tjeyasin(a)redhat.com>
---
M vdsm/gluster/hooks.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/06/15506/1
diff --git a/vdsm/gluster/hooks.py b/vdsm/gluster/hooks.py
index bc8ab65..3c441d5 100644
--- a/vdsm/gluster/hooks.py
+++ b/vdsm/gluster/hooks.py
@@ -263,7 +263,7 @@
raise ge.GlusterHookRemoveFailedException(err=[errMsg])
try:
os.remove(disabledFile)
- except OSError:
+ except OSError, e:
if errno.ENOENT != e.errno:
errMsg = "[Errno %s] %s: '%s'" % (e.errno, e.strerror, e.filename)
raise ge.GlusterHookRemoveFailedException(err=[errMsg])
--
To view, visit http://gerrit.ovirt.org/15506
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie37e27f2a42e663c74fa2f8a3f43f31b28a72840
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Timothy Asir <tjeyasin(a)redhat.com>
Gerrit-Reviewer: Ayal Baron <abaron(a)redhat.com>
Gerrit-Reviewer: Bala.FA <barumuga(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi(a)redhat.com>
11 years
Change in vdsm[master]: Move removing libvirt network to configurator
by wudxw@linux.vnet.ibm.com
Mark Wu has uploaded a new change for review.
Change subject: Move removing libvirt network to configurator
......................................................................
Move removing libvirt network to configurator
This patch adds a wrapper for the configWriter.removeLibvirtNetwork()
in configurator and call it in delNetwork because we should try to
avoid using ConfigWriter directly in configNetwork.py
Change-Id: Id254a05bb428fde0b5321e33a31d79dddc1ce1ba
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
---
M vdsm/configNetwork.py
M vdsm/netconf/ifcfg.py
2 files changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/17/15417/1
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index fee985a..b76d1e4 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -310,7 +310,7 @@
assertBridgeClean(network, vlan, bonding, nics)
configWriter.setNewMtu(network=network, bridged=bridged, _netinfo=_netinfo)
- configWriter.removeLibvirtNetwork(network)
+ configurator.removeLibvirtNetwork(network)
# We need to gather NetInfo again to refresh networks info from libvirt.
# The deleted bridge should never be up at this stage.
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index 70c89ad..fe51b25 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -146,6 +146,9 @@
self.configureBonding(bond, bondAttrs['nics'], bridge, mtu,
bondAttrs.get('options', None))
+ def removeLibvirtNetwork(self, network):
+ self.configWriter.removeLibvirtNetwork(network)
+
def removeBonding(self, bond, nics):
ifdown(bond)
self.configWriter.removeBonding(bond)
--
To view, visit http://gerrit.ovirt.org/15417
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id254a05bb428fde0b5321e33a31d79dddc1ce1ba
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mark Wu <wudxw(a)linux.vnet.ibm.com>
11 years
Change in vdsm[master]: vdsm: vmChannels: Do not use epoll unregister
by Vinzenz Feenstra
Vinzenz Feenstra has uploaded a new change for review.
Change subject: vdsm: vmChannels: Do not use epoll unregister
......................................................................
vdsm: vmChannels: Do not use epoll unregister
We don't use epoll.unregister for the deregistration from epoll anymore.
According to the epoll documentation, epoll will remove the fd when the
fd was closed.
Since we're always closing the sockets where this is used and we
otherwise might run into race conditions we're no longer calling
epoll.unregister to avoid attempts to unregister fds which might no
longer belong to us.
Change-Id: Iacb8dee05e179405d7946bef7329ca406223744a
Signed-off-by: Vinzenz Feenstra <vfeenstr(a)redhat.com>
---
M vdsm/vmChannels.py
1 file changed, 8 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/15393/1
diff --git a/vdsm/vmChannels.py b/vdsm/vmChannels.py
index 5a097f6..f5f786e 100644
--- a/vdsm/vmChannels.py
+++ b/vdsm/vmChannels.py
@@ -22,7 +22,6 @@
import time
import select
import logging
-import errno
from storage.misc import NoIntrPoll
# How many times a reconnect should be performed before a cooldown will be
@@ -51,8 +50,12 @@
""" Handle an epoll event occurred on a specific file descriptor. """
reconnect = False
if (event & (select.EPOLLHUP | select.EPOLLERR)):
- self.log.error("Received EPOLLHUP on fileno %d", fileno)
- reconnect = True
+ self.log.error("Received EPOLLHUP|EPOLLERR on fileno %d", fileno)
+ if fileno in self._channels:
+ reconnect = True
+ else:
+ self.log.debug("Received EPOLLHUP|EPOLLERR on fd not handled "
+ "by this class anymore.")
elif (event & select.EPOLLIN):
obj = self._channels[fileno]
obj['reconnects'] = 0
@@ -68,7 +71,6 @@
self._prepare_reconnect(fileno)
def _prepare_reconnect(self, fileno):
- self._epoll.unregister(fileno)
obj = self._channels.pop(fileno)
try:
fileno = obj['create_cb'](obj['opaque'])
@@ -104,13 +106,8 @@
def _do_del_channels(self):
""" Remove requested channels from listener. """
for fileno in self._del_channels:
- try:
- self._epoll.unregister(fileno)
- except IOError as err:
- if err.errno == errno.ENOENT:
- self.log.debug("%s (unregister was called twice?)" % err)
- else:
- raise
+ self.log.debug("Attempting unregisterationof %d from listener",
+ fileno)
self._add_channels.pop(fileno, None)
self._unconnected.pop(fileno, None)
self._channels.pop(fileno, None)
--
To view, visit http://gerrit.ovirt.org/15393
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iacb8dee05e179405d7946bef7329ca406223744a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
11 years
Change in vdsm[master]: mom: add mom balloon functional tests for running vms
by dfediuck@redhat.com
Doron Fediuck has posted comments on this change.
Change subject: mom: add mom balloon functional tests for running vms
......................................................................
Patch Set 6: (2 inline comments)
....................................................
File tests/functional/momTests.py
Line 67: self.assertEqual(bool(run), hostStats['ksmState'])
Line 68: self.assertEqual(pages_to_scan, hostStats['ksmPages'])
Line 69:
Line 70: def _statsOK(self, stats):
Line 71: try:
True ;)
Line 72: if stats['status'] == 'Running' and stats['balloonInfo'] \
Line 73: and stats['memoryStats']:
Line 74: return True
Line 75: else:
Line 81: # Filter all vms' statistics to get balloon operation candidates.
Line 82: candidateStats = []
Line 83: for stats in vmsStats:
Line 84: if self._statsOK(stats):
Line 85: candidateStats.append(stats)
Once you learn filter, it looks more readable than the alternative.
However, people should be aware of filter to appreciate it...
Line 86:
Line 87: # Set the balloon target to initial value before shrink
Line 88: # or grow operation.
Line 89: # The initial value is max for shrink operation and
--
To view, visit http://gerrit.ovirt.org/13156
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I922568233dc769d83e2fdffe1c24439d13d03d7e
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mei Liu <liumbj(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Doron Fediuck <dfediuck(a)redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Martin Sivák <msivak(a)redhat.com>
Gerrit-Reviewer: Mei Liu <liumbj(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
11 years
Change in vdsm[master]: NetReload: netmodels for delNetwork
by wudxw@linux.vnet.ibm.com
Mark Wu has uploaded a new change for review.
Change subject: NetReload: netmodels for delNetwork
......................................................................
NetReload: netmodels for delNetwork
This patch re-implements the delNetwork logic using the network
entities defined in netmodels.
Change-Id: I9e11fd923a4f5d07d069193278f3eadc94f327ec
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
---
M vdsm/configNetwork.py
M vdsm/netconf/ifcfg.py
M vdsm/netmodels.py
3 files changed, 100 insertions(+), 75 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/73/14873/1
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index ef6c66f..816cd27 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -30,7 +30,6 @@
from neterrors import ConfigNetworkError
from vdsm import define
from vdsm import netinfo
-from vdsm.netinfo import DEFAULT_MTU
from netconf.ifcfg import ifup
from netconf.ifcfg import ifdown
from netconf.ifcfg import ConfigWriter
@@ -51,7 +50,8 @@
def objectivizeNetwork(net, bridged=None, vlan=None, bonding=None,
bondingOptions=None, nics=None, mtu=None, ipaddr=None,
netmask=None, gateway=None, bootproto=None,
- _netinfo=None, configurator=None, **opts):
+ _netinfo=None, configurator=None, onRemove=False,
+ destroyBonding=None, **opts):
if configurator is None:
configurator = Ifcfg()
if _netinfo is None:
@@ -62,7 +62,9 @@
topObj = None
if bonding: # With explicit or implicit(from the bond) nics
topObj = objectivizeBond(bonding, bondingOptions, nics, mtu, _netinfo,
- configurator)
+ configurator, onRemove)
+ if destroyBonding:
+ topObj.destoryOnRemove = True
elif nics:
topObj = objectivizeNic(bonding, nics, mtu, _netinfo, configurator)
@@ -78,12 +80,13 @@
def objectivizeBond(bonding, bondingOptions, nics, mtu, _netinfo,
- configurator):
+ configurator, onRemove=False):
if bonding and nics:
slaves = []
bondMtu = netinfo.getMaxMtu(nics, mtu)
for nic in nics:
- _validateNicUnused(nic, _netinfo)
+ if not onRemove:
+ _validateNicUnused(nic, _netinfo)
slaves.append(Nic(nic, configurator, mtu=bondMtu))
elif bonding in _netinfo.bondings: # Implicit bonding.
nics = [nic for nic in _netinfo.getNicsForBonding(bonding)]
@@ -290,6 +293,31 @@
implicitBonding=False, _netinfo=_netinfo)
+def validateDelNetwork(network, vlan, bonding, nics, bridged, _netinfo):
+ if bonding:
+ Bond.validateName(bonding)
+ if set(nics) != set(_netinfo.bondings[bonding]["slaves"]):
+ raise ConfigNetworkError(ne.ERR_BAD_NIC, 'delNetwork: %s are '
+ 'not all nics enslaved to %s' %
+ (nics, bonding))
+ if vlan:
+ Vlan.validateTag(vlan)
+ if bridged:
+ assertBridgeClean(network, vlan, bonding, nics)
+
+
+def _delNonVdsmNetwork(network, vlan, bonding, nics, configWriter):
+ if network in netinfo.bridges():
+ configWriter.removeBridge(network)
+ else:
+ raise ConfigNetworkError(ne.ERR_BAD_BRIDGE, "Cannot delete network"
+ " %r: It doesn't exist in the system" %
+ network)
+ if vlan:
+ configWriter.removeVlan(vlan, bonding or nics[0])
+ return
+
+
def delNetwork(network, vlan=None, bonding=None, nics=None, force=False,
configWriter=None, implicitBonding=True, _netinfo=None,
**options):
@@ -298,20 +326,11 @@
if configWriter is None:
configWriter = ConfigWriter()
+ configurator = Ifcfg(configWriter)
if network not in _netinfo.networks:
logging.info("Network %r: doesn't exist in libvirt database", network)
- if network in netinfo.bridges():
- configWriter.removeBridge(network)
- else:
- raise ConfigNetworkError(ne.ERR_BAD_BRIDGE, "Cannot delete network"
- " %r: It doesn't exist in the system" %
- network)
-
- if vlan:
- configWriter.removeVlan(vlan, bonding or nics[0])
-
- return
+ _delNonVdsmNetwork(network, vlan, bonding, nics)
nics, vlan, bonding = _netinfo.getNicsVlanAndBondingForNetwork(network)
bridged = _netinfo.networks[network]['bridged']
@@ -320,16 +339,7 @@
"options=%s" % (network, vlan, bonding, nics, options))
if not utils.tobool(force):
- if bonding:
- Bond.validateName(bonding)
- if set(nics) != set(_netinfo.bondings[bonding]["slaves"]):
- raise ConfigNetworkError(ne.ERR_BAD_NIC, 'delNetwork: %s are '
- 'not all nics enslaved to %s' %
- (nics, bonding))
- if vlan:
- Vlan.validateTag(vlan)
- if bridged:
- assertBridgeClean(network, vlan, bonding, nics)
+ validateDelNetwork(network, vlan, bonding, nics, bridged, _netinfo)
configWriter.setNewMtu(network=network, bridged=bridged, _netinfo=_netinfo)
configWriter.removeLibvirtNetwork(network)
@@ -341,44 +351,11 @@
raise ConfigNetworkError(ne.ERR_USED_BRIDGE, 'delNetwork: bridge %s '
'still exists' % network)
- if network and bridged:
- configWriter.removeBridge(network)
-
- nic = nics[0] if nics else None
- iface = bonding if bonding else nic
- if iface:
- ifdown(iface)
- if vlan:
- configWriter.removeVlan(vlan, iface)
- else:
- cf = netinfo.NET_CONF_PREF + iface
- if not bridged:
- # When removing bridgeless non-VLANed network
- # we need to remove IP/NETMASK from the cfg file
- for key in ('IPADDR', 'NETMASK', 'GATEWAY', 'BOOTPROTO'):
- configWriter._updateConfigValue(cf, key, '', True)
- else:
- # When removing bridged non-VLANed network
- # we need to remove BRIDGE from the cfg file
- configWriter._updateConfigValue(cf, 'BRIDGE', '', True)
-
- # Now we can restart changed interface
- ifup(iface)
-
- # The (relatively) new setupNetwork verb allows to remove a network
- # defined on top of an bonding device without break the bond itself.
- if implicitBonding:
- if bonding and not _netinfo.ifaceHasMultiUsers(bonding):
- ifdown(bonding)
- configWriter.removeBonding(bonding)
-
- _removeUnusedNics(nics, configWriter)
- elif not bonding:
- _removeUnusedNics(nics, configWriter)
- elif not _netinfo.ifaceHasMultiUsers(bonding):
- ifdown(bonding)
- configWriter.setBondingMtu(bonding, DEFAULT_MTU)
- ifup(bonding)
+ netEnt = objectivizeNetwork(net=network, bridged=bridged, vlan=vlan,
+ bonding=bonding, nics=nics, _netinfo=_netinfo,
+ configurator=configurator, onRemove=True,
+ destroyBonding=implicitBonding)
+ netEnt.remove()
def clientSeen(timeout):
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index faf8108..84444b0 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -30,6 +30,7 @@
import threading
from neterrors import ConfigNetworkError
+from netmodels import Bond, Vlan
from storage.misc import execCmd
from vdsm import constants
from vdsm import libvirtconnection
@@ -144,6 +145,46 @@
if network:
self.configWriter.createLibvirtNetwork(network, False, nic.name)
self._libvirtAdded.add(network)
+
+ def removeBridge(self, bridge):
+ ifdown(bridge.name)
+ execCmd([constants.EXT_BRCTL, 'delbr', bridge.name])
+ self.configWriter.removeBridge(bridge.name)
+ for port in bridge.ports:
+ port.remove()
+
+ def removeVlan(self, vlan):
+ ifdown(vlan.name)
+ self.configWriter.removeVlan(vlan.name)
+ vlan.device.remove()
+
+ def _removeBond(self, bonding):
+ if hasattr(bonding, 'destroyOnRemove'):
+ self.configWriter.removeBonding(bonding.name)
+ for slave in bonding.slaves:
+ slave.remove()
+ else:
+ self.configWriter.restoreBareBonding(bonding.name)
+
+ def removeIface(self, iface):
+ _netinfo = netinfo.NetInfo()
+ ifdown(iface.name)
+ if not _netinfo.ifaceHasMultiUsers(iface.name):
+ if isinstance(iface, Bond):
+ self._removeBond(iface)
+ else:
+ self.configWriter.removeNic(iface.name)
+ else:
+ if iface.master is None:
+ self.configWriter.removeIpConfig(iface.name)
+ if not hasattr(iface, 'destroyOnRemove'):
+ ifup(iface.name)
+
+ def removeBond(self, bonding):
+ self.removeIface(bonding)
+
+ def removeNic(self, nic):
+ self.removeIface(nic)
class ConfigWriter(object):
@@ -563,22 +604,29 @@
except IOError:
pass
- def removeVlan(self, vlan, iface):
- vlandev = iface + '.' + vlan
- ifdown(vlandev)
- self._backup(netinfo.NET_CONF_PREF + vlandev)
- self._removeFile(netinfo.NET_CONF_PREF + vlandev)
+ def removeVlan(self, vlan):
+ self._backup(netinfo.NET_CONF_PREF + vlan)
+ self._removeFile(netinfo.NET_CONF_PREF + vlan)
def removeBonding(self, bonding):
self._backup(netinfo.NET_CONF_PREF + bonding)
self._removeFile(netinfo.NET_CONF_PREF + bonding)
+ def restoreBareBonding(self, bonding):
+ cf = netinfo.NET_CONF_PREF + bonding
+ self._updateConfigValue(cf, 'BRIDGE', '', True)
+ self.setBondingMtu(bonding, netinfo.DEFAULT_MTU)
+ self.removeIpConfig(bonding)
+
def removeBridge(self, bridge):
- ifdown(bridge)
- execCmd([constants.EXT_BRCTL, 'delbr', bridge])
self._backup(netinfo.NET_CONF_PREF + bridge)
self._removeFile(netinfo.NET_CONF_PREF + bridge)
+ def removeIpConfig(self, iface):
+ cf = netinfo.NET_CONF_PREF + iface
+ for key in ('IPADDR', 'NETMASK', 'GATEWAY', 'BOOTPROTO'):
+ self._updateConfigValue(cf, key, '', True)
+
def _getConfigValue(self, conffile, entry):
"""
Get value from network configuration file
diff --git a/vdsm/netmodels.py b/vdsm/netmodels.py
index 4efd08b..4e34a22 100644
--- a/vdsm/netmodels.py
+++ b/vdsm/netmodels.py
@@ -47,8 +47,8 @@
self.configurator.configureNic(self, network=network, bridge=bridge,
bonding=bonding, vlan=vlan, **opts)
- def remove(self, network=None, bond=None):
- self.configurator.removeNic(self, network=network, bond=bond)
+ def remove(self):
+ self.configurator.removeNic(self)
def __str__(self):
return self.name
@@ -89,7 +89,7 @@
**opts)
def remove(self, force=False):
- self.configurator.removeVlan(self.name)
+ self.configurator.removeVlan(self)
@classmethod
def validateTag(cls, tag):
@@ -181,7 +181,7 @@
def remove(self, force=False):
logging.debug('Removing bond %r with nics = %s', self.name,
self.slaves)
- self.configurator.removeBond(self.name, self.slaves)
+ self.configurator.removeBond(self)
@staticmethod
def validateName(name):
--
To view, visit http://gerrit.ovirt.org/14873
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9e11fd923a4f5d07d069193278f3eadc94f327ec
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mark Wu <wudxw(a)linux.vnet.ibm.com>
11 years
Change in vdsm[master]: iscsi: report hba sessions as fiber channel
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: iscsi: report hba sessions as fiber channel
......................................................................
iscsi: report hba sessions as fiber channel
At the moment the engine doesn't support static (unmanaged) iscsi
connections therefore it's safer to maintain the old behavior and
report the HBA iscsi sessions as if they were fiber channel devices.
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=967605
Change-Id: I9b87aafc89a502c872ceec6a55b49d9e49d1ee9f
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/iscsi.py
1 file changed, 41 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/15161/1
diff --git a/vdsm/storage/iscsi.py b/vdsm/storage/iscsi.py
index 2139e78..5749dde 100644
--- a/vdsm/storage/iscsi.py
+++ b/vdsm/storage/iscsi.py
@@ -52,6 +52,14 @@
log = logging.getLogger('Storage.ISCSI')
+def getDevIscsiSessionId(dev):
+ device = os.path.realpath(os.path.join("/sys", "block", dev, "device"))
+ if not os.path.exists(device):
+ return None
+ session = os.path.realpath(os.path.join(device, "../.."))
+ return int(os.path.basename(session)[7:])
+
+
def getDevIscsiInfo(dev):
"""
Reports the iSCSI parameters of the given device 'dev'
@@ -62,11 +70,8 @@
"""
- device = os.path.realpath(os.path.join("/sys/block", dev, "device"))
- if os.path.exists(device) and devIsiSCSI(dev):
- sessiondir = os.path.realpath(os.path.join(device, "../.."))
- sessionID = int(os.path.basename(sessiondir)[7:])
- return getSessionInfo(sessionID)
+ if devIsiSCSI(dev):
+ return getSessionInfo(getDevIscsiSessionId(dev))
#FIXME: raise exception instead of returning an empty object
return IscsiSession(0, IscsiInterface(""),
@@ -77,11 +82,20 @@
return supervdsm.getProxy().readSessionInfo(sessionID)
+def getIscsiSessionPath(sessionId):
+ return os.path.join("/sys", "class", "iscsi_session",
+ "session%d" % sessionId)
+
+
+def getIscsiConnectionPath(sessionId):
+ return os.path.join("/sys", "class", "iscsi_connection",
+ "connection%d:0" % sessionId)
+
+
def readSessionInfo(sessionID):
- sessionName = "session%d" % sessionID
- connectionName = "connection%d:0" % sessionID
- iscsi_session = "/sys/class/iscsi_session/%s/" % sessionName
- iscsi_connection = "/sys/class/iscsi_connection/%s/" % connectionName
+ iscsi_session = getIscsiSessionPath(sessionID)
+ iscsi_connection = getIscsiConnectionPath(sessionID)
+
if not os.path.isdir(iscsi_session) or not os.path.isdir(iscsi_connection):
raise OSError(errno.ENOENT, "No such session")
@@ -431,7 +445,24 @@
iscsi_host = os.path.join(hostdir, "iscsi_host/", host)
scsi_host = os.path.join(hostdir, "scsi_host/", host)
proc_name = os.path.join(scsi_host, "proc_name")
- return (os.path.exists(iscsi_host) and os.path.exists(proc_name))
+
+ if not os.path.exists(iscsi_host) or not os.path.exists(proc_name):
+ return False
+
+ # This second part of the validation is to make sure that if the
+ # iscsi connection is handled by an HBS (e.g. qlogic in bz967605)
+ # the device is reported as fiber channel to avoid unmanageable
+ # commands (dis/connectStorageServer).
+ session_id = getDevIscsiSessionId(dev)
+
+ if session_id is None:
+ return False
+
+ iscsi_connection = getIscsiConnectionPath(session_id)
+ pers_addr = os.path.join(iscsi_connection, "persistent_address")
+ pers_port = os.path.join(iscsi_connection, "persistent_port")
+
+ return os.path.exists(pers_addr) and os.path.exists(pers_port)
def getiScsiTarget(dev):
--
To view, visit http://gerrit.ovirt.org/15161
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b87aafc89a502c872ceec6a55b49d9e49d1ee9f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
11 years