X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=python%2Fovs%2Funixctl.py;h=0fadaeb6a8861e1eaac64978561d960c5d8a97a7;hb=e0edde6fee279cdbbf3c179f5f50adaf0c7c7f1e;hp=8921ba8c2e579b59bd2b3bcd7db6564b1cbce650;hpb=0a68ffd2347e96447c5b4751c9e5ac65d5100a56;p=sliver-openvswitch.git diff --git a/python/ovs/unixctl.py b/python/ovs/unixctl.py index 8921ba8c2..0fadaeb6a 100644 --- a/python/ovs/unixctl.py +++ b/python/ovs/unixctl.py @@ -1,4 +1,4 @@ -# Copyright (c) 2012 Nicira Networks +# Copyright (c) 2012 Nicira, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -55,11 +55,9 @@ def _unixctl_help(conn, unused_argv, unused_aux): conn.reply(reply) -def _unixctl_version(conn, unused_argv, unused_aux): +def _unixctl_version(conn, unused_argv, version): assert isinstance(conn, UnixctlConnection) - version = "%s (Open vSwitch) %s %s" % (ovs.util.PROGRAM_NAME, - ovs.version.VERSION, - ovs.version.BUILDNR) + version = "%s (Open vSwitch) %s" % (ovs.util.PROGRAM_NAME, version) conn.reply(version) @@ -241,7 +239,12 @@ class UnixctlServer(object): self._listener = None @staticmethod - def create(path): + def create(path, version=None): + """Creates a new UnixctlServer which listens on a unixctl socket + created at 'path'. If 'path' is None, the default path is chosen. + 'version' contains the version of the server as reported by the unixctl + version command. If None, ovs.version.VERSION is used.""" + assert path is None or isinstance(path, strtypes) if path is not None: @@ -250,6 +253,9 @@ class UnixctlServer(object): path = "punix:%s/%s.%d.ctl" % (ovs.dirs.RUNDIR, ovs.util.PROGRAM_NAME, os.getpid()) + if version is None: + version = ovs.version.VERSION + error, listener = ovs.stream.PassiveStream.open(path) if error: ovs.util.ovs_error(error, "could not initialize control socket %s" @@ -257,7 +263,7 @@ class UnixctlServer(object): return error, None command_register("help", "", 0, 0, _unixctl_help, None) - command_register("version", "", 0, 0, _unixctl_version, None) + command_register("version", "", 0, 0, _unixctl_version, version) return 0, UnixctlServer(listener)