#!/usr/bin/python
-# Copyright (c) 2013, 2014 Nicira, Inc.
+# Copyright (c) 2013, 2014, 2015 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
ROOT = HOME + "/root"
BUILD_GCC = OVS_SRC + "/_build-gcc"
BUILD_CLANG = OVS_SRC + "/_build-clang"
-PATH = "%(ovs)s/utilities:%(ovs)s/ovsdb:%(ovs)s/vswitchd" % {"ovs": BUILD_GCC}
-
-ENV["PATH"] = PATH + ":" + ENV["PATH"]
options = None
parser = None
commands = []
+def set_path(build):
+ PATH = "%(ovs)s/utilities:%(ovs)s/ovsdb:%(ovs)s/vswitchd" % {"ovs": build}
+
+ ENV["PATH"] = PATH + ":" + ENV["PATH"]
def _sh(*args, **kwargs):
print "------> " + " ".join(args)
if options.optimize is None:
options.optimize = 0
- cflags += " -O%d" % options.optimize
+ cflags += " -O%s" % str(options.optimize)
ENV["CFLAGS"] = cflags
_sh("ovsdb-tool", "create", ROOT + "/conf.db",
OVS_SRC + "/vswitchd/vswitch.ovsschema")
- opts = ["--pidfile", "--log-file", "--enable-dummy"]
+ opts = ["--pidfile", "--log-file"]
_sh(*(["ovsdb-server",
"--remote=punix:%s/run/db.sock" % ROOT,
_sh("ovs-vsctl --no-wait set Open_vSwitch %s ovs_version=%s"
% (root_uuid, version))
- cmd = [BUILD_GCC + "/vswitchd/ovs-vswitchd"]
+ build = BUILD_CLANG if options.clang else BUILD_GCC
+ cmd = [build + "/vswitchd/ovs-vswitchd"]
if options.dpdk:
cmd.append("--dpdk")
"--suppressions=%s/tests/openssl.supp" % OVS_SRC] + cmd
else:
cmd = ["sudo"] + cmd
- opts = opts + ["-vconsole:off", "--detach"]
+ opts = opts + ["-vconsole:off", "--detach", "--enable-dummy"]
_sh(*(cmd + opts))
commands.append(run)
pass # Module isn't loaded
try:
- _sh("rm /lib/modules/%s/extra/openvswitch.ko" % uname())
+ _sh("rm -f /lib/modules/%s/extra/openvswitch.ko" % uname())
+ _sh("rm -f /lib/modules/%s/extra/vport-*.ko" % uname())
except subprocess.CalledProcessError, e:
pass # Module isn't installed
_sh("modprobe", "openvswitch")
_sh("dmesg | grep openvswitch | tail -1")
+ _sh("find /lib/modules/%s/ -iname vport-*.ko -exec insmod '{}' \;" % uname())
commands.append(modinst)
# Install the kernel module
sudo insmod %(ovs)s/datapath/linux/openvswitch.ko
+ # If needed, manually load all required vport modules:
+ sudo insmod %(ovs)s/datapath/linux/vport-vxlan.ko
+ sudo insmod %(ovs)s/datapath/linux/vport-geneve.ko
+ [...]
+
# Run the switch.
%(v)s run
help="configure the man documentation install directory")
group.add_option("--with-dpdk", dest="with_dpdk", metavar="DPDK_BUILD",
help="built with dpdk libraries located at DPDK_BUILD");
+ parser.add_option_group(group)
- for i in range(4):
- group.add_option("--O%d" % i, dest="optimize", action="store_const",
- const=i, help="compile with -O%d" % i)
+ group = optparse.OptionGroup(parser, "Optimization Flags")
+ for i in ["s", "g"] + range(4) + ["fast"]:
+ group.add_option("--O%s" % str(i), dest="optimize",
+ action="store_const", const=i,
+ help="compile with -O%s" % str(i))
parser.add_option_group(group)
group = optparse.OptionGroup(parser, "check")
group.add_option("--dpdk", dest="dpdk", action="callback",
callback=parse_subargs,
help="run ovs-vswitchd with dpdk subopts (ended by --)")
+ group.add_option("--clang", dest="clang", action="store_true",
+ help="Use binaries built by clang")
+
parser.add_option_group(group)
options, args = parser.parse_args()
print "Unknown argument " + arg
doc()
+ if options.clang:
+ set_path(BUILD_CLANG)
+ else:
+ set_path(BUILD_GCC)
+
try:
os.chdir(OVS_SRC)
except OSError: