2
# Copyright (c) 2013, 2014 Nicira, Inc.
2
# Copyright (c) 2013, 2014, 2015 Nicira, Inc.
4
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
5
# you may not use this file except in compliance with the License.
26
26
ROOT = HOME + "/root"
27
27
BUILD_GCC = OVS_SRC + "/_build-gcc"
28
28
BUILD_CLANG = OVS_SRC + "/_build-clang"
29
PATH = "%(ovs)s/utilities:%(ovs)s/ovsdb:%(ovs)s/vswitchd" % {"ovs": BUILD_GCC}
31
ENV["PATH"] = PATH + ":" + ENV["PATH"]
35
PATH = "%(ovs)s/utilities:%(ovs)s/ovsdb:%(ovs)s/vswitchd" % {"ovs": build}
37
ENV["PATH"] = PATH + ":" + ENV["PATH"]
38
39
def _sh(*args, **kwargs):
39
40
print "------> " + " ".join(args)
132
133
mf.write(make_str % BUILD_CLANG)
133
134
mf.write("\t$(MAKE) -C %s %s $@\n" % (BUILD_GCC, c1))
135
mf.write("\ncheck-valgrind:\n")
134
136
mf.write("\ncheck:\n")
135
137
mf.write(make_str % BUILD_GCC)
203
217
_sh("ovsdb-tool", "create", ROOT + "/conf.db",
204
218
OVS_SRC + "/vswitchd/vswitch.ovsschema")
206
opts = ["--pidfile", "--log-file", "--enable-dummy"]
220
opts = ["--pidfile", "--log-file"]
208
222
_sh(*(["ovsdb-server",
209
223
"--remote=punix:%s/run/db.sock" % ROOT,
223
237
_sh("ovs-vsctl --no-wait set Open_vSwitch %s ovs_version=%s"
224
238
% (root_uuid, version))
226
cmd = [BUILD_GCC + "/vswitchd/ovs-vswitchd"]
240
build = BUILD_CLANG if options.clang else BUILD_GCC
241
cmd = [build + "/vswitchd/ovs-vswitchd"]
245
cmd.extend(options.dpdk)
228
249
cmd = ["gdb", "--args"] + cmd
229
250
elif options.valgrind:
232
253
"--suppressions=%s/tests/openssl.supp" % OVS_SRC] + cmd
234
255
cmd = ["sudo"] + cmd
235
opts = opts + ["-vconsole:off", "--detach"]
256
opts = opts + ["-vconsole:off", "--detach", "--enable-dummy"]
236
257
_sh(*(cmd + opts))
237
258
commands.append(run)
248
269
pass # Module isn't loaded
251
_sh("rm /lib/modules/%s/extra/openvswitch.ko" % uname())
272
_sh("rm -f /lib/modules/%s/extra/openvswitch.ko" % uname())
273
_sh("rm -f /lib/modules/%s/extra/vport-*.ko" % uname())
252
274
except subprocess.CalledProcessError, e:
253
275
pass # Module isn't installed
294
317
# Install the kernel module
295
318
sudo insmod %(ovs)s/datapath/linux/openvswitch.ko
320
# If needed, manually load all required vport modules:
321
sudo insmod %(ovs)s/datapath/linux/vport-vxlan.ko
322
sudo insmod %(ovs)s/datapath/linux/vport-geneve.ko
297
325
# Run the switch.
313
341
commands.append(doc)
343
def parse_subargs(option, opt_str, value, parser):
347
dpdkarg = parser.rargs.pop(0)
350
subopts.append(dpdkarg)
352
setattr(parser.values, option.dest, subopts)
333
371
help="configure the man documentation install directory")
334
372
group.add_option("--with-dpdk", dest="with_dpdk", metavar="DPDK_BUILD",
335
373
help="built with dpdk libraries located at DPDK_BUILD");
338
group.add_option("--O%d" % i, dest="optimize", action="store_const",
339
const=i, help="compile with -O%d" % i)
374
parser.add_option_group(group)
376
group = optparse.OptionGroup(parser, "Optimization Flags")
377
for i in ["s", "g"] + range(4) + ["fast"]:
378
group.add_option("--O%s" % str(i), dest="optimize",
379
action="store_const", const=i,
380
help="compile with -O%s" % str(i))
381
parser.add_option_group(group)
383
group = optparse.OptionGroup(parser, "check")
384
group.add_option("-j", "--jobs", dest="jobs", metavar="N", type="int",
385
help="Run N tests in parallel")
386
group.add_option("--tests", dest="tests", metavar="FILTER",
387
help="""run specific tests and/or a test category
388
eg, --tests=\"1-10 megaflow\"""")
340
389
parser.add_option_group(group)
342
391
group = optparse.OptionGroup(parser, "run")
344
393
help="run ovs-vswitchd under gdb")
345
394
group.add_option("--valgrind", dest="valgrind", action="store_true",
346
395
help="run ovs-vswitchd under valgrind")
396
group.add_option("--dpdk", dest="dpdk", action="callback",
397
callback=parse_subargs,
398
help="run ovs-vswitchd with dpdk subopts (ended by --)")
399
group.add_option("--clang", dest="clang", action="store_true",
400
help="Use binaries built by clang")
347
402
parser.add_option_group(group)
349
404
options, args = parser.parse_args()