From patchwork Fri Jul 15 14:21:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Boca X-Patchwork-Id: 648837 X-Patchwork-Delegate: guru@ovn.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rrZX611TZz9s8d for ; Sat, 16 Jul 2016 00:22:14 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 8EA2610DAA; Fri, 15 Jul 2016 07:22:11 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id DEA2310DA8 for ; Fri, 15 Jul 2016 07:22:09 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 70D6D1E0077 for ; Fri, 15 Jul 2016 08:22:09 -0600 (MDT) X-ASG-Debug-ID: 1468592528-09eadd079819100001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id MBCdf9Bi5SG2mz6N (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 15 Jul 2016 08:22:08 -0600 (MDT) X-Barracuda-Envelope-From: pboca@cloudbasesolutions.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO cbssmtp1.cloudbase.local) (91.232.152.5) by mx1-pf2.cudamail.com with SMTP; 15 Jul 2016 14:22:08 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at cloudbasesolutions.com designates 91.232.152.5 as permitted sender) X-Barracuda-Apparent-Source-IP: 91.232.152.5 X-Barracuda-RBL-IP: 91.232.152.5 Received: from localhost (localhost [127.0.0.1]) by cbssmtp1.cloudbase.local (Postfix) with ESMTP id 162B54054C for ; Fri, 15 Jul 2016 17:22:07 +0300 (EEST) X-Virus-Scanned: amavisd-new at cloudbasesolutions.com Received: from cbssmtp1.cloudbase.local ([127.0.0.1]) by localhost (cbssmtp1.cloudbase.local [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fV6E9zSlE5zN for ; Fri, 15 Jul 2016 17:21:46 +0300 (EEST) Received: from CBSEX1.cloudbase.local (unknown [10.77.78.3]) by cbssmtp1.cloudbase.local (Postfix) with ESMTP id 1FDE440558 for ; Fri, 15 Jul 2016 17:21:24 +0300 (EEST) Received: from CBSEX1.cloudbase.local ([10.77.78.3]) by CBSEX1.cloudbase.local ([10.77.78.3]) with mapi id 14.03.0301.000; Fri, 15 Jul 2016 16:21:23 +0200 X-CudaMail-Envelope-Sender: pboca@cloudbasesolutions.com From: Paul Boca To: "dev@openvswitch.org" X-CudaMail-MID: CM-E2-714020858 X-CudaMail-DTE: 071516 X-CudaMail-Originating-IP: 91.232.152.5 Thread-Topic: [PATCH V7 03/16] python tests: Fixed ctl file name for Windows X-ASG-Orig-Subj: [##CM-E2-714020858##][PATCH V7 03/16] python tests: Fixed ctl file name for Windows Thread-Index: AQHR3qQqH3DE2f9cNEy6GJQOuyxXnQ== Date: Fri, 15 Jul 2016 14:21:23 +0000 Message-ID: <1468592469-10160-4-git-send-email-pboca@cloudbasesolutions.com> References: <1468592469-10160-1-git-send-email-pboca@cloudbasesolutions.com> In-Reply-To: <1468592469-10160-1-git-send-email-pboca@cloudbasesolutions.com> Accept-Language: en-US, it-IT Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.77.78.1] MIME-Version: 1.0 X-GBUdb-Analysis: 0, 91.232.152.5, Ugly c=0.36638 p=-0.542857 Source Normal X-MessageSniffer-Rules: 0-0-0-6189-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1468592528 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.10 X-Barracuda-Spam-Status: No, SCORE=0.10 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.31283 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS Subject: [ovs-dev] [PATCH V7 03/16] python tests: Fixed ctl file name for Windows X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" On Windows the CTL filename doesn't contain the pid of the process. Signed-off-by: Paul-Daniel Boca Acked-by: Alin Gabriel Serdean --- V2: No changes V3: No changes V4: No changes V5: No changes V6: No changes V7: Fixed flake8 errors. Addressed changes required by review. --- 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. """ 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..2f12608 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