From 24d9a00f471f6c879c7197306748cab1bf310ab7 Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Tue, 14 Jun 2016 17:55:55 +0100 Subject: [PATCH] Add check-datapath to weaveutil The utility is used to check whether a datapath can be created. --- prog/weaveutil/datapath.go | 13 +++++++++++++ prog/weaveutil/main.go | 1 + weave | 3 +-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/prog/weaveutil/datapath.go b/prog/weaveutil/datapath.go index f4494967..52e320f8 100644 --- a/prog/weaveutil/datapath.go +++ b/prog/weaveutil/datapath.go @@ -31,6 +31,19 @@ func deleteDatapath(args []string) error { return odp.DeleteDatapath(args[0]) } +// Checks whether a datapath can be created by actually creating and destroying it +func checkDatapath(args []string) error { + if len(args) != 1 { + cmdUsage("check-datapath", "") + } + + if err := createDatapath(args); err != nil { + return err + } + + return odp.DeleteDatapath(args[0]) +} + func addDatapathInterface(args []string) error { if len(args) != 2 { cmdUsage("add-datapath-interface", " ") diff --git a/prog/weaveutil/main.go b/prog/weaveutil/main.go index 182b5d3d..2550d56d 100644 --- a/prog/weaveutil/main.go +++ b/prog/weaveutil/main.go @@ -15,6 +15,7 @@ func init() { "docker-tls-args": dockerTLSArgs, "create-datapath": createDatapath, "delete-datapath": deleteDatapath, + "check-datapath": checkDatapath, "add-datapath-interface": addDatapathInterface, "create-plugin-network": createPluginNetwork, "remove-plugin-network": removePluginNetwork, diff --git a/weave b/weave index 6d20cc1a..3acd6c96 100755 --- a/weave +++ b/weave @@ -639,8 +639,7 @@ create_bridge() { else if [ -n "$LAUNCHING_ROUTER" ] ; then if [ "$BRIDGE_TYPE" = bridge -a -z "$WEAVE_NO_FASTDP" ] && - util_op create-datapath $DATAPATH 2>/dev/null && - util_op delete-datapath $DATAPATH 2>/dev/null ; then + util_op check-datapath $DATAPATH 2>/dev/null ; then cat <&2 WEAVE_NO_FASTDP is not set, but there is already a bridge present of the wrong type for fast datapath. Please do 'weave reset' to remove