From patchwork Tue Aug 30 12:01:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Boca X-Patchwork-Id: 664125 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 3sNnFc0ZCYz9s1h for ; Tue, 30 Aug 2016 22:02:28 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 68D8610678; Tue, 30 Aug 2016 05:02:26 -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 6C030105DD for ; Tue, 30 Aug 2016 05:02:24 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 039021E05E8 for ; Tue, 30 Aug 2016 06:02:24 -0600 (MDT) X-ASG-Debug-ID: 1472558543-09eadd2fc720850001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id SQtVLeqCF2CJg4em (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 30 Aug 2016 06:02:23 -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; 30 Aug 2016 12:02:22 -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 6E5EA41A61 for ; Tue, 30 Aug 2016 15:02:21 +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 6izv7HlkmEtx for ; Tue, 30 Aug 2016 15:02:01 +0300 (EEST) Received: from CBSEX1.cloudbase.local (unknown [10.77.78.3]) by cbssmtp1.cloudbase.local (Postfix) with ESMTP id 22EE441A42 for ; Tue, 30 Aug 2016 15:01:02 +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; Tue, 30 Aug 2016 14:01:01 +0200 X-CudaMail-Envelope-Sender: pboca@cloudbasesolutions.com From: Paul Boca To: "dev@openvswitch.org" X-CudaMail-MID: CM-E2-829010568 X-CudaMail-DTE: 083016 X-CudaMail-Originating-IP: 91.232.152.5 Thread-Topic: [PATCH V2 06/10] python tests: Implemented wrapper over daemon_unix.py X-ASG-Orig-Subj: [##CM-E2-829010568##][PATCH V2 06/10] python tests: Implemented wrapper over daemon_unix.py Thread-Index: AQHSArYt/z/JrQsTkEi0vmJc0irGmg== Date: Tue, 30 Aug 2016 12:01:01 +0000 Message-ID: <1472558417-2016-7-git-send-email-pboca@cloudbasesolutions.com> References: <1472558417-2016-1-git-send-email-pboca@cloudbasesolutions.com> In-Reply-To: <1472558417-2016-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.226425 p=-0.555556 Source Normal X-MessageSniffer-Rules: 0-0-0-7308-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1472558543 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.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_RULE_7582B, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.32454 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE_7582B Custom Rule 7582B 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS Subject: [ovs-dev] [PATCH V2 06/10] python tests: Implemented wrapper over daemon_unix.py 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" Implemented a wrapper over every function from daemon_unix. This will help on porting daemon to Windows. Signed-off-by: Paul-Daniel Boca --- V2: No changes. --- python/automake.mk | 1 + python/ovs/daemon.py | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 python/ovs/daemon.py diff --git a/python/automake.mk b/python/automake.mk index 157604d..1bbe390 100644 --- a/python/automake.mk +++ b/python/automake.mk @@ -10,6 +10,7 @@ ovstest_pyfiles = \ ovs_pyfiles = \ python/ovs/__init__.py \ + python/ovs/daemon.py \ python/ovs/daemon_unix.py \ python/ovs/fcntl_win.py \ python/ovs/db/__init__.py \ diff --git a/python/ovs/daemon.py b/python/ovs/daemon.py new file mode 100644 index 0000000..b1d6c36 --- /dev/null +++ b/python/ovs/daemon.py @@ -0,0 +1,77 @@ +# Copyright (c) 2016 Cloudbase Solutions Srl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys + +# This is only a wrapper over Linux implementations +if sys.platform != "win32": + import ovs.daemon_unix as daemon_util + +RESTART_EXIT_CODE = daemon_util.RESTART_EXIT_CODE + + +def make_pidfile_name(name): + return daemon_util.make_pidfile_name(name) + + +def set_pidfile(name): + daemon_util.set_pidfile(name) + + +def set_no_chdir(): + daemon_util.set_no_chdir() + + +def ignore_existing_pidfile(): + daemon_util.ignore_existing_pidfile() + + +def set_detach(): + daemon_util.set_detach() + + +def get_detach(): + return daemon_util.get_detach() + + +def set_monitor(): + daemon_util.set_monitor() + + +def daemonize(): + daemon_util.daemonize() + + +def daemonize_start(): + daemon_util.daemonize_start() + + +def daemonize_complete(): + daemon_util.daemonize_complete() + + +def usage(): + daemon_util.usage() + + +def read_pidfile(pidfile_name): + return daemon_util.read_pidfile(pidfile_name) + + +def add_args(parser): + daemon_util.add_args(parser) + + +def handle_args(args): + daemon_util.handle_args(args)