Change in vdsm[master]: Separate adding libvirt network from configuring host networ...
wudxw at linux.vnet.ibm.com
wudxw at linux.vnet.ibm.com
Mon Apr 29 06:26:34 UTC 2013
Mark Wu has uploaded a new change for review.
Change subject: Separate adding libvirt network from configuring host network.
......................................................................
Separate adding libvirt network from configuring host network.
It makes it simpler to test the network configure functions, and
also make the code a little bit cleaner.
Change-Id: Ie974e17538ed92cbf8d3d23d8c23f276cf3b3bc3
Signed-off-by: Mark Wu <wudxw at linux.vnet.ibm.com>
---
M vdsm/configNetwork.py
M vdsm/netconf/ifcfg.py
2 files changed, 54 insertions(+), 58 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/14305/1
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index b5cca25..e358b95 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -302,20 +302,22 @@
ifdown(nic)
if bridged:
- configurator.configureBridge(network, vlan, bonding, nics, ipaddr,
- netmask, mtu, gateway, bondingOptions,
- async, **options)
+ iface = configurator.configureBridge(network, vlan, bonding, nics,
+ ipaddr, netmask, mtu, gateway,
+ bondingOptions, async, **options)
elif vlan:
- configurator.configureVlan(network, vlan, None, bonding, nics,
- ipaddr, netmask, mtu, gateway,
- bondingOptions, async, **options)
+ iface = configurator.configureVlan(vlan, None, bonding, nics, ipaddr,
+ netmask, mtu, gateway,
+ bondingOptions, async, **options)
elif bonding:
- configurator.configureBond(network, bonding, nics, ipaddr, netmask,
- mtu, gateway, None, bondingOptions, async,
- **options)
+ iface = configurator.configureBond(network, bonding, nics, ipaddr,
+ netmask, mtu, gateway, None,
+ bondingOptions, async, **options)
elif nics:
- configurator.configureNic(network, nics[0], None, bonding, ipaddr,
- netmask, mtu, gateway, async, **options)
+ iface = configurator.configureNic(network, nics[0], None, bonding,
+ ipaddr, netmask, mtu, gateway, async,
+ **options)
+ configurator.configureNetwork(network, bridged, iface)
def assertBridgeClean(bridge, vlan, bonding, nics):
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index ff5b66f..ef8478c 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -65,60 +65,58 @@
self.configWriter = None
self._libvirtAdded = set()
- def configureBridge(self, network, vlan=None, bonding=None, nics=None,
+ def configureNetwork(self, network, bridged, iface):
+ self.configWriter.createLibvirtNetwork(network, True, iface)
+
+ def configureBridge(self, bridge, vlan=None, bonding=None, nics=None,
ipaddr=None, netmask=None, mtu=None, gateway=None,
bondingOptions=None, async=False, bootproto=None,
**options):
- self.configWriter.addBridge(network, ipaddr=ipaddr, netmask=netmask,
+ self.configWriter.addBridge(bridge, ipaddr=ipaddr, netmask=netmask,
mtu=mtu, gateway=gateway,
bootproto=bootproto, **options)
- ifdown(network)
+ ifdown(bridge)
bootproto = None
if vlan:
- iface = self.configureVlan(None, vlan, bridge=network,
- bonding=bonding, nics=nics, mtu=mtu,
- bondingOptions=bondingOptions,
- bootproto=bootproto, **options)
+ self.configureVlan(vlan, bridge=bridge, bonding=bonding,
+ nics=nics, mtu=mtu,
+ bondingOptions=bondingOptions,
+ bootproto=bootproto, **options)
elif bonding:
- iface = self.configureBond(None, bonding, nics, bridge=network,
- bondingOptions=bondingOptions, mtu=mtu,
- bootproto=bootproto, **options)
- elif nics:
- mtu = self.configWriter.getMaxMtu(nics, mtu)
- for nic in nics:
- iface = self.configureNic(None, nic, bridge=network, mtu=mtu,
- bootproto=bootproto, **options)
- else:
- iface = None
- ifup(network, async)
- self.configWriter.createLibvirtNetwork(network, True, iface)
-
- def configureVlan(self, network, vlan, bridge=None, bonding=None,
- nics=None, ipaddr=None, netmask=None, mtu=None,
- gateway=None, bondingOptions=None, async=False,
- bootproto=None, **options):
- iface = (bonding or nics[0])
- self.configWriter.addVlan(vlan, iface, network=bridge, mtu=mtu,
- bridged=bridge is not None, ipaddr=ipaddr,
- netmask=netmask, gateway=gateway,
- bootproto=bootproto, **options)
- iface += '.' + vlan
- bootproto = None
- if bonding:
- self.configureBond(None, bonding, nics, bridge=None,
+ self.configureBond(bonding, nics, bridge=bridge,
bondingOptions=bondingOptions, mtu=mtu,
bootproto=bootproto, **options)
elif nics:
mtu = self.configWriter.getMaxMtu(nics, mtu)
for nic in nics:
- self.configureNic(None, nic, bridge=None, mtu=mtu,
+ self.configureNic(nic, bridge=bridge, mtu=mtu,
+ bootproto=bootproto, **options)
+ ifup(bridge, async)
+
+ def configureVlan(self, vlan, bridge=None, bonding=None,
+ nics=None, ipaddr=None, netmask=None, mtu=None,
+ gateway=None, bondingOptions=None, async=False,
+ bootproto=None, **options):
+ iface = (bonding or nics[0])
+ self.configWriter.addVlan(vlan, iface, bridge=bridge, mtu=mtu,
+ ipaddr=ipaddr, netmask=netmask,
+ gateway=gateway, bootproto=bootproto,
+ **options)
+ iface += '.' + vlan
+ bootproto = None
+ if bonding:
+ self.configureBond(bonding, nics, bridge=None,
+ bondingOptions=bondingOptions, mtu=mtu,
+ bootproto=bootproto, **options)
+ elif nics:
+ mtu = self.configWriter.getMaxMtu(nics, mtu)
+ for nic in nics:
+ self.configureNic(nic, bridge=None, mtu=mtu,
bootproto=bootproto, **options)
ifup(iface, async)
- if network:
- self.configWriter.createLibvirtNetwork(network, False, iface)
return iface
- def configureBond(self, network, bonding, nics, ipaddr=None,
+ def configureBond(self, bonding, nics, ipaddr=None,
netmask=None, mtu=None, gateway=None, bridge=None,
bondingOptions=None, async=False, bootproto=None,
**options):
@@ -129,15 +127,13 @@
netmask=netmask, gateway=gateway,
bootproto=bootproto, **options)
for nic in nics:
- self.configureNic(None, nic, bonding=bonding, mtu=mtu,
+ self.configureNic(nic, bonding=bonding, mtu=mtu,
bootproto=None, **options)
ifup(bonding, async)
- if network:
- self.configWriter.createLibvirtNetwork(network, False, bonding)
return bonding
- def configureNic(self, network, nic, bridge=None, bonding=None,
+ def configureNic(self, nic, bridge=None, bonding=None,
ipaddr=None, netmask=None, mtu=None, gateway=None,
async=False, bootproto=None, **options):
self.configWriter.addNic(nic, bonding=bonding, bridge=bridge, mtu=mtu,
@@ -147,8 +143,6 @@
if not bonding:
ifup(nic, async)
- if network:
- self.configWriter.createLibvirtNetwork(network, False, nic)
return nic
def configureBonding(self, bond, nics, bridge=None, mtu=None,
@@ -608,14 +602,14 @@
self._createConfFile(conf, name, ipaddr, netmask, gateway,
bootproto, mtu, onboot, **kwargs)
- def addVlan(self, vlanId, iface, network, mtu=None, bridged=True,
- ipaddr=None, netmask=None, gateway=None, bootproto=None,
+ def addVlan(self, vlanId, iface, bridge=None, mtu=None, ipaddr=None,
+ netmask=None, gateway=None, bootproto=None,
onboot='yes', **kwargs):
""" Create ifcfg-* file with proper fields for VLAN """
name = '%s.%s' % (pipes.quote(iface), vlanId)
conf = 'VLAN=yes\n'
- if bridged:
- conf += 'BRIDGE=%s\n' % pipes.quote(network)
+ if bridge:
+ conf += 'BRIDGE=%s\n' % pipes.quote(bridge)
self._createConfFile(conf, name, ipaddr, netmask, gateway,
bootproto, mtu, onboot, **kwargs)
--
To view, visit http://gerrit.ovirt.org/14305
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie974e17538ed92cbf8d3d23d8c23f276cf3b3bc3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mark Wu <wudxw at linux.vnet.ibm.com>
More information about the vdsm-patches
mailing list