Message ID | 1470159883-4648-4-git-send-email-pboca@cloudbasesolutions.com |
---|---|
State | Changes Requested |
Headers | show |
On 2 August 2016 at 10:45, Paul Boca <pboca@cloudbasesolutions.com> wrote: > On Windows the CTL filename doesn't contain the pid of the process. > > Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> > Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> > --- > V2: No changes > V3: No changes > V4: No changes > V5: No changes > V6: No changes > V7: Fixed flake8 errors. Addressed changes required by review. > V8: Fixed small alignement problem. > V9: No changes > V10: No changes > V11: No changes > --- > python/ovs/unixctl/__init__.py | 11 +++++++++-- > python/ovs/unixctl/server.py | 10 ++++++++-- > 2 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/python/ovs/unixctl/__init__.py > b/python/ovs/unixctl/__init__.py > index d3d3556..e2e5604 100644 > --- a/python/ovs/unixctl/__init__.py > +++ b/python/ovs/unixctl/__init__.py > @@ -13,6 +13,7 @@ > # limitations under the License. > > import six > +import sys > > import ovs.util > > @@ -71,14 +72,20 @@ def command_register(name, usage, min_args, max_args, > callback, aux): > def socket_name_from_target(target): > assert isinstance(target, strtypes) > > - if target.startswith("/"): > + """ On Windows an absolute path contains ':' ( i.e: C:\ ) """ > + if target.startswith('/') or target.find(':') > -1: > return 0, target > > + """ Leave it to read the pid file on Windows also, the tests expect > this > + error in case of failure. """ > The above comment should not be here. We should not write code with information on how it is tested. So I removed it and applied this. > pidfile_name = "%s/%s.pid" % (ovs.dirs.RUNDIR, target) > pid = ovs.daemon.read_pidfile(pidfile_name) > if pid < 0: > return -pid, "cannot read pidfile \"%s\"" % pidfile_name > > - return 0, "%s/%s.%d.ctl" % (ovs.dirs.RUNDIR, target, pid) > + if sys.platform == "win32": > + return 0, "%s/%s.ctl" % (ovs.dirs.RUNDIR, target) > + else: > + return 0, "%s/%s.%d.ctl" % (ovs.dirs.RUNDIR, target, pid) > > command_register("help", "", 0, 0, _unixctl_help, None) > diff --git a/python/ovs/unixctl/server.py b/python/ovs/unixctl/server.py > index cc712bf..8595ed8 100644 > --- a/python/ovs/unixctl/server.py > +++ b/python/ovs/unixctl/server.py > @@ -15,6 +15,7 @@ > import copy > import errno > import os > +import sys > > import six > from six.moves import range > @@ -188,8 +189,13 @@ class UnixctlServer(object): > if path is not None: > path = "punix:%s" % ovs.util.abs_file_name(ovs.dirs.RUNDIR, > path) > else: > - path = "punix:%s/%s.%d.ctl" % (ovs.dirs.RUNDIR, > - ovs.util.PROGRAM_NAME, > os.getpid()) > + if sys.platform == "win32": > + path = "punix:%s/%s.ctl" % (ovs.dirs.RUNDIR, > + ovs.util.PROGRAM_NAME) > + else: > + path = "punix:%s/%s.%d.ctl" % (ovs.dirs.RUNDIR, > + ovs.util.PROGRAM_NAME, > + os.getpid()) > > if version is None: > version = ovs.version.VERSION > -- > 2.7.2.windows.1 > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev >
diff --git a/python/ovs/unixctl/__init__.py b/python/ovs/unixctl/__init__.py index d3d3556..e2e5604 100644 --- a/python/ovs/unixctl/__init__.py +++ b/python/ovs/unixctl/__init__.py @@ -13,6 +13,7 @@ # limitations under the License. import six +import sys import ovs.util @@ -71,14 +72,20 @@ def command_register(name, usage, min_args, max_args, callback, aux): def socket_name_from_target(target): assert isinstance(target, strtypes) - if target.startswith("/"): + """ On Windows an absolute path contains ':' ( i.e: C:\ ) """ + if target.startswith('/') or target.find(':') > -1: return 0, target + """ Leave it to read the pid file on Windows also, the tests expect this + error in case of failure. """ pidfile_name = "%s/%s.pid" % (ovs.dirs.RUNDIR, target) pid = ovs.daemon.read_pidfile(pidfile_name) if pid < 0: return -pid, "cannot read pidfile \"%s\"" % pidfile_name - return 0, "%s/%s.%d.ctl" % (ovs.dirs.RUNDIR, target, pid) + if sys.platform == "win32": + return 0, "%s/%s.ctl" % (ovs.dirs.RUNDIR, target) + else: + return 0, "%s/%s.%d.ctl" % (ovs.dirs.RUNDIR, target, pid) command_register("help", "", 0, 0, _unixctl_help, None) diff --git a/python/ovs/unixctl/server.py b/python/ovs/unixctl/server.py index cc712bf..8595ed8 100644 --- a/python/ovs/unixctl/server.py +++ b/python/ovs/unixctl/server.py @@ -15,6 +15,7 @@ import copy import errno import os +import sys import six from six.moves import range @@ -188,8 +189,13 @@ class UnixctlServer(object): if path is not None: path = "punix:%s" % ovs.util.abs_file_name(ovs.dirs.RUNDIR, path) else: - path = "punix:%s/%s.%d.ctl" % (ovs.dirs.RUNDIR, - ovs.util.PROGRAM_NAME, os.getpid()) + if sys.platform == "win32": + path = "punix:%s/%s.ctl" % (ovs.dirs.RUNDIR, + ovs.util.PROGRAM_NAME) + else: + path = "punix:%s/%s.%d.ctl" % (ovs.dirs.RUNDIR, + ovs.util.PROGRAM_NAME, + os.getpid()) if version is None: version = ovs.version.VERSION