return [pif]
def datapath_deconfigure_physical(netdev):
- # The use of [!0-9] keeps an interface of 'eth0' from matching
- # VLANs attached to eth0 (such as 'eth0.123'), which are distinct
- # interfaces.
- return ['--del-match=bridge.*.port=%s' % netdev,
- '--del-match=port.%s.[!0-9]*' % netdev,
- '--del-match=bonding.*.slave=%s' % netdev,
- '--del-match=iface.%s.[!0-9]*' % netdev]
+ return ['--', '--if-exists', 'del-port', netdev]
def datapath_configure_bond(pif,slaves):
+ bridge = pif_bridge_name(pif)
pifrec = db.get_pif_record(pif)
interface = pif_netdev_name(pif)
- argv = ['--del-match=bonding.%s.[!0-9]*' % interface]
- argv += ["--add=bonding.%s.slave=%s" % (interface, pif_netdev_name(slave))
- for slave in slaves]
- argv += ['--add=bonding.%s.fake-iface=true' % interface]
+ argv = ['--', 'add-bond', bridge, interface] + slaves
- if pifrec['MAC'] != "":
- argv += ['--add=port.%s.mac=%s' % (interface, pifrec['MAC'])]
+ # XXX need ovs-vsctl support
+ #if pifrec['MAC'] != "":
+ # argv += ['--add=port.%s.mac=%s' % (interface, pifrec['MAC'])]
# Bonding options.
bond_options = {
overrides = map(lambda (key,val): (key[5:], val), overrides)
bond_options.update(overrides)
for (name,val) in bond_options.items():
- argv += ["--add=bonding.%s.%s=%s" % (interface, name, val)]
+ # XXX need ovs-vsctl support for bond options
+ #argv += ["--add=bonding.%s.%s=%s" % (interface, name, val)]
+ pass
return argv
def datapath_deconfigure_bond(netdev):
- # The use of [!0-9] keeps an interface of 'eth0' from matching
- # VLANs attached to eth0 (such as 'eth0.123'), which are distinct
- # interfaces.
- return ['--del-match=bonding.%s.[!0-9]*' % netdev,
- '--del-match=port.%s.[!0-9]*' % netdev]
+ return ['--', '--if-exists', 'del-port', netdev]
def datapath_deconfigure_ipdev(interface):
- # The use of [!0-9] keeps an interface of 'eth0' from matching
- # VLANs attached to eth0 (such as 'eth0.123'), which are distinct
- # interfaces.
- return ['--del-match=bridge.*.port=%s' % interface,
- '--del-match=port.%s.[!0-9]*' % interface,
- '--del-match=iface.%s.[!0-9]*' % interface,
- '--del-match=vlan.%s.trunks=*' % interface,
- '--del-match=vlan.%s.tag=*' % interface]
+ return ['--', '--if-exists', 'del-port', interface]
def datapath_modify_config(commands):
if debug_mode():
for c in commands:
log(" %s" % c)
- rc = run_command(['/usr/bin/ovs-cfg-mod', '-vANY:console:emer',
- '-F', '/etc/ovs-vswitchd.conf']
- + [c for c in commands if c[0] != '#'] + ['-c'])
+ rc = run_command(['/usr/bin/ovs-vsctl']
+ + [c for c in commands if not c.startswith('#')])
if not rc:
raise Error("Failed to modify vswitch configuration")
- run_command(['/sbin/service', 'vswitch', 'reload'])
+ run_command(['/bin/sleep', '5']) # XXX
return True
#
b = pif_bridge_name(brpif)
ifdown(b)
cfgmod_argv += ['# remove bridge %s' % b]
- cfgmod_argv += ['--del-match=bridge.%s.*' % b]
+ cfgmod_argv += ['--', '--if-exists', 'del-br', b]
for n in extra_down_ports:
dev = pif_netdev_name(n)
if len(offload):
run_command(['/sbin/ethtool', '-K', dev] + offload)
+ if pif_is_vlan(pif):
+ datapath = pif_datapath(pif)
+ vlan = db.get_pif_record(pif)['VLAN']
+ cfgmod_argv += ['--', 'add-br', bridge, datapath, vlan]
+ else:
+ cfgmod_argv += ['--', 'add-br', bridge]
+
if len(physical_devices) > 1:
cfgmod_argv += ['# deconfigure bond %s' % pif_netdev_name(pif)]
cfgmod_argv += datapath_deconfigure_bond(pif_netdev_name(pif))
- cfgmod_argv += ['--del-entry=bridge.%s.port=%s' % (bridge,pif_netdev_name(pif))]
cfgmod_argv += ['# configure bond %s' % pif_netdev_name(pif)]
cfgmod_argv += datapath_configure_bond(pif, physical_devices)
- cfgmod_argv += ['--add=bridge.%s.port=%s' % (bridge,pif_netdev_name(pif)) ]
extra_up_ports += [pif_netdev_name(pif)]
else:
iface = pif_netdev_name(physical_devices[0])
cfgmod_argv += ['# add physical device %s' % iface]
- cfgmod_argv += ['--add=bridge.%s.port=%s' % (bridge,iface) ]
+ cfgmod_argv += ['--', 'add-port', bridge, iface]
return cfgmod_argv,extra_up_ports
cfgmod_argv += datapath_deconfigure_bond(pif_netdev_name(pif))
cfgmod_argv += ['# deconfigure bridge %s' % bridge]
- cfgmod_argv += ['--del-match=bridge.%s.*' % bridge]
+ cfgmod_argv += ['--', '--if-exists', 'del-br', bridge]
return cfgmod_argv
cfgmod_argv += c
extra_ports += e
- cfgmod_argv += ['# configure xs-network-uuids']
- cfgmod_argv += ['--del-match=bridge.%s.xs-network-uuids=*' % bridge]
-
+ xs_network_uuids = []
for nwpif in db.get_pifs_by_device(db.get_pif_record(pif)['device']):
rec = db.get_pif_record(nwpif)
# log("Network PIF %s not currently attached (%s)" % (rec['uuid'],pifrec['uuid']))
# continue
nwrec = db.get_network_record(rec['network'])
- cfgmod_argv += ['--add=bridge.%s.xs-network-uuids=%s' % (bridge, nwrec['uuid'])]
+ xs_network_uuids += [nwrec['uuid']]
+ cfgmod_argv += ['# configure xs-network-uuids']
+ cfgmod_argv += ['--', 'br-set-external-id', bridge,
+ 'xs-network-uuids', ' '.join(xs_network_uuids)]
- cfgmod_argv += ["# deconfigure ipdev %s" % ipdev]
- cfgmod_argv += datapath_deconfigure_ipdev(ipdev)
- cfgmod_argv += ["# reconfigure ipdev %s" % ipdev]
- cfgmod_argv += ['--add=bridge.%s.port=%s' % (bridge, ipdev)]
+ if ipdev != bridge:
+ cfgmod_argv += ["# deconfigure ipdev %s" % ipdev]
+ cfgmod_argv += datapath_deconfigure_ipdev(ipdev)
+ cfgmod_argv += ["# reconfigure ipdev %s" % ipdev]
+ cfgmod_argv += ['--', 'add-port', bridge, ipdev]
f = ipdev_configure_network(pif)
f.close()
- # /etc/xensource/scripts/vif needs to know where to add VIFs.
- if pif_is_vlan(pif):
- if not bridge:
- raise Error("Unbridged VLAN devices not implemented yet")
- cfgmod_argv += ['--add=vlan.%s.tag=%s' % (ipdev, pifrec['VLAN'])]
- cfgmod_argv += ['--add=iface.%s.internal=true' % (ipdev)]
- cfgmod_argv += ['--add=iface.%s.fake-bridge=true' % (ipdev)]
-
# Apply updated configuration.
try:
f.apply()
if dp:
nw = db.get_pif_record(pif)['network']
nwrec = db.get_network_record(nw)
- cfgmod_argv += ['# deconfigure xs-network-uuids']
- cfgmod_argv += ['--del-entry=bridge.%s.xs-network-uuids=%s' % (bridge,nwrec['uuid'])]
log("deconfigure ipdev %s on %s" % (ipdev,bridge))
cfgmod_argv += ["# deconfigure ipdev %s" % ipdev]