Change in vdsm[master]: net: rename destroyOnMasterRemoval
phoracek at redhat.com
phoracek at redhat.com
Fri Feb 26 15:07:16 UTC 2016
Petr Horáček has uploaded a new change for review.
Change subject: net: rename destroyOnMasterRemoval
......................................................................
net: rename destroyOnMasterRemoval
destroyOnMasterRemoval parameter was needed to say whether bonding
should be removed together with network (implicit bonding) or just
detached. Now when we drop implicit bonding, we can change it's logic
to something more understandable.
With this patch, destroyOnMasterRemoval was renamed to
on_removal_just_detach_from_network. It's extremely long, but verbosity
is needed here.
Default functionality of bond.remove() is evidently removal, so
this new parameter is False by default.
When a bonding is objectivized as a part of a network, we need it
to be just detached from master, set it default MTU etc, so it
will be a standalone bonding again. When we objectivize it as a
part of bonding query, then by bond.remove() we really mean the
removal.
Change-Id: I0ca4ba568c3f24b20a5e9ee70b3f6935bbc22eab
Signed-off-by: Petr Horáček <phoracek at redhat.com>
---
M lib/vdsm/network/api.py
M lib/vdsm/network/configurators/ifcfg.py
M lib/vdsm/network/configurators/iproute2.py
M lib/vdsm/network/models.py
4 files changed, 27 insertions(+), 29 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/54082/1
diff --git a/lib/vdsm/network/api.py b/lib/vdsm/network/api.py
index 6605306..03834e5 100644
--- a/lib/vdsm/network/api.py
+++ b/lib/vdsm/network/api.py
@@ -94,7 +94,7 @@
ipv6addr=None, ipv6gateway=None, ipv6autoconf=None,
dhcpv6=None, defaultRoute=None, _netinfo=None,
configurator=None, blockingdhcp=None,
- implicitBonding=None, opts=None):
+ opts=None):
"""
Constructs an object hierarchy that describes the network configuration
that is passed in the parameters.
@@ -116,8 +116,6 @@
:param _netinfo: network information snapshot.
:param configurator: instance to use to apply the network configuration.
:param blockingdhcp: whether to acquire dhcp IP config in a synced manner.
- :param implicitBonding: whether the bond's existance is tied to it's
- master's.
:param defaultRoute: Should this network's gateway be set in the main
routing table?
:param opts: misc options received by the callee, e.g., {'stp': True}. this
@@ -138,7 +136,7 @@
if bonding:
topNetDev = Bond.objectivize(bonding, configurator, options=None,
nics=None, mtu=mtu, _netinfo=_netinfo,
- destroyOnMasterRemoval=implicitBonding)
+ on_removal_just_detach_from_network=True)
elif nic:
bond = _netinfo.getBondingForNic(nic)
if bond:
@@ -316,7 +314,7 @@
configurator.runningConfig.removeNetwork(network)
return
_delNetwork(network, configurator, bypassValidation=True,
- implicitBonding=False, _netinfo=_netinfo)
+ _netinfo=_netinfo)
def _validateDelNetwork(network, vlan, bonding, nics, bridge_should_be_clean,
@@ -337,7 +335,6 @@
@_alterRunningConfig
def _delNetwork(network, configurator, vlan=None, bonding=None,
bypassValidation=False,
- implicitBonding=True,
_netinfo=None, keep_bridge=False, **options):
if _netinfo is None:
_netinfo = CachingNetInfo()
@@ -359,8 +356,7 @@
nic=nics[0] if nics and not bonding
else None,
_netinfo=_netinfo,
- configurator=configurator,
- implicitBonding=implicitBonding)
+ configurator=configurator)
net_ent.ipv4.bootproto = (
'dhcp' if _netinfo.networks[network]['dhcpv4'] else 'none')
@@ -554,7 +550,7 @@
if _is_bond_valid_for_removal(name, _netinfo, in_rollback, logger):
bond = Bond.objectivize(
name, configurator, options=None, nics=None, mtu=None,
- _netinfo=_netinfo, destroyOnMasterRemoval=True)
+ _netinfo=_netinfo)
logger.debug('Removing bond %r', bond)
bond.remove()
_netinfo.del_bonding(name)
@@ -597,7 +593,7 @@
for name, attrs in six.iteritems(bonds):
bond = Bond.objectivize(
name, configurator, attrs.get('options'), attrs.get('nics'),
- mtu=None, _netinfo=_netinfo, destroyOnMasterRemoval=False)
+ mtu=None, _netinfo=_netinfo)
logger.debug('Editing bond %r with options %s', bond, bond.options)
configurator.editBonding(bond, _netinfo)
@@ -612,7 +608,7 @@
for name, attrs in six.iteritems(bonds):
bond = Bond.objectivize(
name, configurator, attrs.get('options'), attrs.get('nics'),
- mtu=None, _netinfo=_netinfo, destroyOnMasterRemoval=False)
+ mtu=None, _netinfo=_netinfo)
logger.debug('Creating bond %r with options %s', bond, bond.options)
configurator.configureBond(bond)
@@ -635,8 +631,7 @@
if networkAttrs['bonding'] in _netinfo.bondings:
topNetDev = Bond.objectivize(networkAttrs['bonding'], configurator,
options=None, nics=None, mtu=None,
- _netinfo=_netinfo,
- destroyOnMasterRemoval=True)
+ _netinfo=_netinfo)
elif 'nic' in networkAttrs:
if networkAttrs['nic'] in _netinfo.nics:
topNetDev = Nic(networkAttrs['nic'], configurator,
@@ -677,7 +672,7 @@
logger.debug("Adding network %r", network)
try:
_addNetwork(network, configurator,
- implicitBonding=True, _netinfo=_netinfo, **attrs)
+ _netinfo=_netinfo, **attrs)
except ConfigNetworkError as cne:
if cne.errCode == ne.ERR_FAILED_IFUP:
logger.debug("Adding network %r failed. Running "
@@ -820,7 +815,7 @@
)
_delNetwork(network, configurator,
- implicitBonding=False, _netinfo=_netinfo,
+ _netinfo=_netinfo,
keep_bridge=keep_bridge)
_netinfo.del_network(network)
_netinfo.updateDevices()
diff --git a/lib/vdsm/network/configurators/ifcfg.py b/lib/vdsm/network/configurators/ifcfg.py
index 5d05251..395dd31 100644
--- a/lib/vdsm/network/configurators/ifcfg.py
+++ b/lib/vdsm/network/configurators/ifcfg.py
@@ -215,16 +215,17 @@
to_be_removed = self._ifaceDownAndCleanup(bonding)
if to_be_removed:
self.configApplier.removeBonding(bonding.name)
- if bonding.destroyOnMasterRemoval:
- for slave in bonding.slaves:
- slave.remove()
- if self.unifiedPersistence:
- self.runningConfig.removeBonding(bonding.name)
- else: # Recreate the bond with ip and master info cleared
+ if bonding.on_removal_just_detach_from_network:
+ # Recreate the bond with ip and master info cleared
bonding.ipv4 = IPv4()
bonding.ipv6 = IPv6()
bonding.master = None
bonding.configure()
+ else:
+ for slave in bonding.slaves:
+ slave.remove()
+ if self.unifiedPersistence:
+ self.runningConfig.removeBonding(bonding.name)
else:
set_mtu = self._setNewMtu(bonding,
vlans.vlan_devs_for_iface(bonding.name))
diff --git a/lib/vdsm/network/configurators/iproute2.py b/lib/vdsm/network/configurators/iproute2.py
index bec8ea2..dbe5a23 100644
--- a/lib/vdsm/network/configurators/iproute2.py
+++ b/lib/vdsm/network/configurators/iproute2.py
@@ -183,12 +183,12 @@
DynamicSourceRoute.addInterfaceTracking(bonding)
self._removeSourceRoute(bonding, DynamicSourceRoute)
- if bonding.destroyOnMasterRemoval:
- self._destroyBond(bonding)
- self.runningConfig.removeBonding(bonding.name)
- else:
+ if bonding.on_removal_just_detach_from_network:
self.configApplier.setIfaceMtu(bonding.name, mtus.DEFAULT_MTU)
self.configApplier.ifdown(bonding)
+ else:
+ self._destroyBond(bonding)
+ self.runningConfig.removeBonding(bonding.name)
else:
self._setNewMtu(bonding, vlans.vlan_devs_for_iface(bonding.name))
diff --git a/lib/vdsm/network/models.py b/lib/vdsm/network/models.py
index 9f5564b..839b484 100644
--- a/lib/vdsm/network/models.py
+++ b/lib/vdsm/network/models.py
@@ -201,7 +201,7 @@
class Bond(NetDevice):
def __init__(self, name, configurator, ipv4=None, ipv6=None,
blockingdhcp=False, mtu=None, slaves=(), options=None,
- destroyOnMasterRemoval=None):
+ on_removal_just_detach_from_network=False):
self.validateName(name)
for slave in slaves:
slave.master = self
@@ -209,7 +209,8 @@
options = options or ''
self.validateOptions(options)
self.options = self._reorderOptions(options)
- self.destroyOnMasterRemoval = destroyOnMasterRemoval
+ self.on_removal_just_detach_from_network = \
+ on_removal_just_detach_from_network
super(Bond, self).__init__(name, configurator, ipv4, ipv6,
blockingdhcp, mtu)
@@ -274,7 +275,7 @@
@classmethod
def objectivize(cls, name, configurator, options, nics, mtu, _netinfo,
- destroyOnMasterRemoval=None):
+ on_removal_just_detach_from_network=False):
if nics: # New bonding or edit bonding.
slaves = cls._objectivizeSlaves(name, configurator, _nicSort(nics),
@@ -298,8 +299,9 @@
'Missing required nics on a bonding %s '
'that is unknown to Vdsm ' % name)
+ detach = on_removal_just_detach_from_network # argument is too long
return cls(name, configurator, slaves=slaves, options=options, mtu=mtu,
- destroyOnMasterRemoval=destroyOnMasterRemoval)
+ on_removal_just_detach_from_network=detach)
@staticmethod
def validateName(name):
--
To view, visit https://gerrit.ovirt.org/54082
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ca4ba568c3f24b20a5e9ee70b3f6935bbc22eab
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>
More information about the vdsm-patches
mailing list