- Added a new "CLI" mode
If you specify the new '--cli' option, ovs-ctl will drop into an
interactive shell after initializing OVS.
The purpose of the interactive shell is to allow easy execution of the
correct OVS binaries for the running configuration, especially if
non-standard DB file locations are used.
In CLI mode, you will receive the following prompt:
[config_name] ovs-ctl>
Where [config_name] is the name of the running OVS configuration you
specified.
The following commands are available from the command line:
# Execute ovs-vsctl with arguments:
> vsctl show
# Execute ovs-ofctl with arguments:
> ofctl show ofbr0
Arguments are passed as-is directly to the correct binaries.
Additional commands:
# exit ovs-ctl
> exit || quit
# exit ovs-ctl, and kill the currently running OVS instance
> kill
If you specify "ovs-ctl --cli --teardown", then the OVS instance
will be killed after exit, even with the "exit" or "quit" commands.
diff --git a/tools/ovs-ctl/ovs-ctl.py b/tools/ovs-ctl/ovs-ctl.py
index 5df57d9..8450aef 100755
--- a/tools/ovs-ctl/ovs-ctl.py
+++ b/tools/ovs-ctl/ovs-ctl.py
@@ -179,6 +179,13 @@
action='store_true', default=False)
+gParser.add_argument("--cli",
+ help="Run the ovs-ctl cli after initialization",
+ action='store_true', default=False)
+
+gParser.add_argument("--teardown",
+ help="Kill OVS instance after CLI exits",
+ action='store_true', default=False)
#
# Reset defaults based on config files and override
@@ -374,22 +381,26 @@
print gServerPid
vsctl(["del-br", gArgs.bridge])
-# Kill existing DB/vswitchd
-killp(gSwitchPid)
-killp(gServerPid)
-killp(gLogPid)
-# Remove old logpid file, since this does not happen automagically
-if os.path.exists(gLogPid):
- os.remove(gLogPid)
+def killall():
+ # Kill existing DB/vswitchd
+ killp(gSwitchPid)
+ killp(gServerPid)
+ killp(gLogPid)
-if gArgs.keep_veths == False:
- lcall(['/sbin/rmmod', 'veth'])
- lcall(['/sbin/modprobe', 'veth'])
+ # Remove old logpid file, since this does not happen automagically
+ if os.path.exists(gLogPid):
+ os.remove(gLogPid)
-# Remove kmod
-lcall(['/sbin/rmmod', gArgs.ovs_kmod])
+ if gArgs.keep_veths == False:
+ lcall(['/sbin/rmmod', 'veth'])
+ lcall(['/sbin/modprobe', 'veth'])
+ # Remove kmod
+ lcall(['/sbin/rmmod', gArgs.ovs_kmod])
+
+
+killall()
if gArgs.kill == True:
# Don't do anything else
sys.exit()
@@ -463,3 +474,28 @@
ofctl(["show", gArgs.bridge])
+if gArgs.cli:
+ while True:
+ cmd = raw_input("[%s] ovs-ctl> " % gConfigSection)
+ if cmd and cmd != "":
+ args = cmd.split(" ")
+ if args[0] == "vsctl" or args[0] == "ovs-vsctl":
+ vsctl(args[1:])
+ if args[0] == "ofctl" or args[0] == "ovs-ofctl":
+ ofctl(args[1:])
+ if args[0] == "exit" or args[0] == "quit":
+ break;
+ if args[0] == "kill":
+ gArgs.teardown = True
+ break
+
+
+if gArgs.teardown:
+ print "Killing OVS"
+ killall()
+
+
+
+
+
+