--may-exist add-br xenbr2
--may-exist add-port xenbr2 eth2
br-set-external-id xenbr2 xs-network-uuids d08c8749-0c8f-9e8d-ce25-fd364661ee99
+ set Interface xenbr2 MAC="00:15:17:a0:29:80"
/sbin/ifup xenbr2
/sbin/update-issue
Committing changes to /etc/sysconfig/network-scripts/route-xenbr2 configuration
--may-exist add-br xenbr3
--may-exist add-port xenbr3 eth3
br-set-external-id xenbr3 xs-network-uuids 2902ae1b-8013-897a-b697-0b200ea3aaa5;db7bdc03-074d-42ae-fc73-9b06de1d57f6
+ set Interface xenbr3 MAC="00:15:17:a0:29:81"
--if-exists del-br xapi3
--may-exist add-br xapi3 xenbr3 123
br-set-external-id xapi3 xs-network-uuids 2902ae1b-8013-897a-b697-0b200ea3aaa5;db7bdc03-074d-42ae-fc73-9b06de1d57f6
+ set Interface xapi3 MAC="00:15:17:a0:29:81"
/sbin/ifup xapi3
/sbin/update-issue
Committing changes to /etc/sysconfig/network-scripts/route-xapi3 configuration
--may-exist add-br xapi1
--with-iface --if-exists del-port bond0
--fake-iface add-bond xapi1 bond0 eth0 eth1
+ set Port bond0 MAC="00:22:19:22:4b:af" bond_downdelay=200 other-config:"bond-miimon"=100 other-config:"bond-use_carrier"=1 other-config:"bond-mode"="balance-slb" bond_updelay=31000
br-set-external-id xapi1 xs-network-uuids 99be2da4-6c33-6f8e-49ea-3bc592fe3c85;45cbbb43-113d-a712-3231-c6463f253cef
+ set Interface xapi1 MAC="00:22:19:22:4b:af"
/sbin/ifup xapi1
action_up: bring up bond0
/sbin/ifconfig bond0 up
--may-exist add-br xapi1
--with-iface --if-exists del-port bond0
--fake-iface add-bond xapi1 bond0 eth0 eth1
+ set Port bond0 MAC="00:22:19:22:4b:af" bond_downdelay=200 other-config:"bond-miimon"=100 other-config:"bond-use_carrier"=1 other-config:"bond-mode"="balance-slb" bond_updelay=31000
br-set-external-id xapi1 xs-network-uuids 99be2da4-6c33-6f8e-49ea-3bc592fe3c85;45cbbb43-113d-a712-3231-c6463f253cef
+ set Interface xapi1 MAC="00:22:19:22:4b:af"
--if-exists del-br xapi2
--may-exist add-br xapi2 xapi1 4
br-set-external-id xapi2 xs-network-uuids 99be2da4-6c33-6f8e-49ea-3bc592fe3c85;45cbbb43-113d-a712-3231-c6463f253cef
+ set Interface xapi2 MAC="00:22:19:22:4b:af"
/sbin/ifup xapi2
action_up: bring up bond0
/sbin/ifconfig bond0 up
# GNU Lesser General Public License for more details.
#
from InterfaceReconfigure import *
+import re
#
# Bare Network Devices -- network devices without IP configuration
def datapath_deconfigure_physical(netdev):
return ['--', '--with-iface', '--if-exists', 'del-port', netdev]
+def vsctl_escape(s):
+ if s.isalnum():
+ return s
+
+ def escape(match):
+ c = match.group(0)
+ if c == '\0':
+ raise Error("strings may not contain null bytes")
+ elif c == '\\':
+ return r'\\'
+ elif c == '\n':
+ return r'\n'
+ elif c == '\r':
+ return r'\r'
+ elif c == '\t':
+ return r'\t'
+ elif c == '\b':
+ return r'\b'
+ elif c == '\a':
+ return r'\a'
+ else:
+ return r'\x%02x' % ord(c)
+ return '"' + re.sub(r'["\\\000-\037]', escape, s) + '"'
+
def datapath_configure_bond(pif,slaves):
bridge = pif_bridge_name(pif)
pifrec = db().get_pif_record(pif)
for slave in slaves:
argv += [pif_netdev_name(slave)]
- # XXX need ovs-vsctl support
- #if pifrec['MAC'] != "":
- # argv += ['--add=port.%s.mac=%s' % (interface, pifrec['MAC'])]
-
# Bonding options.
bond_options = {
"mode": "balance-slb",
key.startswith("bond-"), oc.items())
overrides = map(lambda (key,val): (key[5:], val), overrides)
bond_options.update(overrides)
+
+ argv += ['--', 'set', 'Port', interface]
+ if pifrec['MAC'] != "":
+ argv += ['MAC=%s' % vsctl_escape(pifrec['MAC'])]
for (name,val) in bond_options.items():
- # XXX need ovs-vsctl support for bond options
- #argv += ["--add=bonding.%s.%s=%s" % (interface, name, val)]
- pass
+ if name in ['updelay', 'downdelay']:
+ # updelay and downdelay have dedicated schema columns.
+ # The value must be a nonnegative integer.
+ try:
+ value = int(val)
+ if value < 0:
+ raise ValueError
+
+ argv += ['bond_%s=%d' % (name, value)]
+ except ValueError:
+ log("bridge %s has invalid %s '%s'" % (bridge, name, value))
+ else:
+ # Pass other bond options into other_config.
+ argv += ["other-config:%s=%s" % (vsctl_escape("bond-%s" % name),
+ vsctl_escape(val))]
return argv
def datapath_deconfigure_bond(netdev):
return vsctl_argv
def set_br_external_ids(pif):
+ pifrec = db().get_pif_record(pif)
+ dp = pif_datapath(pif)
+ dprec = db().get_pif_record(dp)
+
xs_network_uuids = []
- for nwpif in db().get_pifs_by_device(db().get_pif_record(pif)['device']):
+ for nwpif in db().get_pifs_by_device(pifrec['device']):
rec = db().get_pif_record(nwpif)
# When state is read from dbcache PIF.currently_attached
vsctl_argv += ['# configure xs-network-uuids']
vsctl_argv += ['--', 'br-set-external-id', pif_bridge_name(pif),
'xs-network-uuids', ';'.join(xs_network_uuids)]
+
+ vsctl_argv += ['# configure MAC']
+ vsctl_argv += ['--', 'set', 'Interface', pif_ipdev_name(pif),
+ 'MAC=%s' % vsctl_escape(dprec['MAC'])]
+
return vsctl_argv
#
vsctl_argv += ["# reconfigure ipdev %s" % ipdev]
vsctl_argv += ['--', 'add-port', bridge, ipdev]
- # XXX Needs support in ovs-vsctl
- #if bridge == ipdev:
- # vsctl_argv += ['--add=bridge.%s.mac=%s' % (bridge, dprec['MAC'])]
- #else:
- # vsctl_argv += ['--add=iface.%s.mac=%s' % (ipdev, dprec['MAC'])]
-
self._vsctl_argv = vsctl_argv
self._extra_ports = extra_ports