Change in vdsm[master]: models, configurators: replace the internal 'async' flag wit...
osvoboda at redhat.com
osvoboda at redhat.com
Thu Apr 30 19:22:55 UTC 2015
Ondřej Svoboda has uploaded a new change for review.
Change subject: models, configurators: replace the internal 'async' flag with blockingdhcp
......................................................................
models, configurators: replace the internal 'async' flag with blockingdhcp
DHCP is queried asynchronously in usual situations so it is better to use
a flag that signals some exceptional flow (network restoration, for example).
blockingdhcp is also a part of the API so now there is direct correspondence
between network configurators' code and the API.
Change-Id: I0e60040320d65ddbc4146a31c02c388ddad13ea9
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
---
M vdsm/network/configurators/__init__.py
M vdsm/network/configurators/dhclient.py
M vdsm/network/configurators/ifcfg.py
M vdsm/network/models.py
4 files changed, 14 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/40456/1
diff --git a/vdsm/network/configurators/__init__.py b/vdsm/network/configurators/__init__.py
index 0df5731..39679c5 100644
--- a/vdsm/network/configurators/__init__.py
+++ b/vdsm/network/configurators/__init__.py
@@ -177,7 +177,7 @@
def runDhclient(iface, family=4):
dhclient = DhcpClient(iface.name, family)
- rc = dhclient.start(iface.asynchronous_dhcp)
- if not iface.asynchronous_dhcp and rc:
+ rc = dhclient.start(iface.blockingdhcp)
+ if iface.blockingdhcp and rc:
raise ConfigNetworkError(ERR_FAILED_IFUP, 'dhclient%s failed',
family)
diff --git a/vdsm/network/configurators/dhclient.py b/vdsm/network/configurators/dhclient.py
index f6db491..8b78cc7 100644
--- a/vdsm/network/configurators/dhclient.py
+++ b/vdsm/network/configurators/dhclient.py
@@ -55,15 +55,15 @@
'-lf', self.leaseFile, self.iface])
return rc, out, err
- def start(self, async):
- if async:
+ def start(self, blocking):
+ if blocking:
+ rc, _, _ = self._dhclient()
+ return rc
+ else:
t = threading.Thread(target=self._dhclient, name='vdsm-dhclient-%s'
% self.iface)
t.daemon = True
t.start()
- else:
- rc, _, _ = self._dhclient()
- return rc
def shutdown(self):
try:
diff --git a/vdsm/network/configurators/ifcfg.py b/vdsm/network/configurators/ifcfg.py
index 6d35c0a..2a5faba 100644
--- a/vdsm/network/configurators/ifcfg.py
+++ b/vdsm/network/configurators/ifcfg.py
@@ -90,13 +90,13 @@
if bridge.port:
bridge.port.configure(**opts)
self._addSourceRoute(bridge)
- ifup(bridge.name, bridge.asynchronous_dhcp)
+ ifup(bridge.name)
def configureVlan(self, vlan, **opts):
self.configApplier.addVlan(vlan, **opts)
vlan.device.configure(**opts)
self._addSourceRoute(vlan)
- ifup(vlan.name, vlan.asynchronous_dhcp)
+ ifup(vlan.name)
def configureBond(self, bond, **opts):
self.configApplier.addBonding(bond, **opts)
@@ -106,7 +106,7 @@
for slave in bond.slaves:
slave.configure(**opts)
self._addSourceRoute(bond)
- ifup(bond.name, bond.asynchronous_dhcp)
+ ifup(bond.name)
if self.unifiedPersistence:
self.runningConfig.setBonding(
bond.name, {'options': bond.options,
@@ -159,7 +159,7 @@
if nic.bond is None:
if not netinfo.isVlanned(nic.name):
ifdown(nic.name)
- ifup(nic.name, nic.asynchronous_dhcp)
+ ifup(nic.name)
def removeBridge(self, bridge):
DynamicSourceRoute.addInterfaceTracking(bridge)
@@ -764,7 +764,7 @@
return rc
-def ifup(iface, async=False):
+def ifup(iface):
"Bring up an interface"
def _ifup(netIf):
rc, out, err = utils.execCmd([constants.EXT_IFUP, netIf], raw=False)
@@ -775,7 +775,8 @@
raise ConfigNetworkError(ERR_FAILED_IFUP, out[-1] if out else '')
return rc, out, err
- if async:
+ if not iface.blockingdhcp and (iface.ipv4.bootproto == 'dhcp' or
+ iface.ipv6.dhcpv6):
# wait for dhcp in another thread,
# so vdsm won't get stuck (BZ#498940)
t = threading.Thread(target=_ifup, name='ifup-waiting-on-dhcp',
diff --git a/vdsm/network/models.py b/vdsm/network/models.py
index 708bad8..5365797 100644
--- a/vdsm/network/models.py
+++ b/vdsm/network/models.py
@@ -80,11 +80,6 @@
def backing_device(self):
return False
- @property
- def asynchronous_dhcp(self):
- return ((self.ipv4.bootproto == 'dhcp' or self.ipv6.dhcpv6) and
- not self.blockingdhcp)
-
class Nic(NetDevice):
def __init__(self, name, configurator, ipv4=None, ipv6=None,
--
To view, visit https://gerrit.ovirt.org/40456
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e60040320d65ddbc4146a31c02c388ddad13ea9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>
More information about the vdsm-patches
mailing list