From nobody Wed Jan 15 13:53:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1486605771621448.30095348932855; Wed, 8 Feb 2017 18:02:51 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 5A0538205CD; Thu, 9 Feb 2017 02:02:50 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id BE12582059B for ; Thu, 9 Feb 2017 02:02:23 +0000 (UTC) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v191wTsX010514 for ; Wed, 8 Feb 2017 21:02:23 -0500 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0a-001b2d01.pphosted.com with ESMTP id 28gbc0g6m7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 08 Feb 2017 21:02:22 -0500 Received: from localhost by e24smtp03.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Feb 2017 00:02:20 -0200 Received: from d24dlp02.br.ibm.com (9.18.248.206) by e24smtp03.br.ibm.com (10.172.0.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Feb 2017 00:02:17 -0200 Received: from d24relay04.br.ibm.com (d24relay04.br.ibm.com [9.18.232.146]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id BAD7D1DC0054 for ; Wed, 8 Feb 2017 21:02:17 -0500 (EST) Received: from d24av05.br.ibm.com (d24av05.br.ibm.com [9.18.232.44]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1922GbD21037310 for ; Thu, 9 Feb 2017 00:02:16 -0200 Received: from d24av05.br.ibm.com (localhost [127.0.0.1]) by d24av05.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v1922Gbe015786 for ; Thu, 9 Feb 2017 00:02:17 -0200 Received: from alinefm-TP440.ibmmodules.com ([9.80.222.200]) by d24av05.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v1922D8F015772 for ; Thu, 9 Feb 2017 00:02:16 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Thu, 9 Feb 2017 00:01:57 -0200 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170209020202.17425-1-alinefm@linux.vnet.ibm.com> References: <20170209020202.17425-1-alinefm@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020902-0024-0000-0000-0000015185E2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020902-0025-0000-0000-00001615AA19 Message-Id: <20170209020202.17425-2-alinefm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-09_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702090015 Subject: [Kimchi-devel] [PATCH] [Kimchi 1/6] Specify objectstore location when running on test mode X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" That way, the objectstore file can be deleted on server shutting down and the system keeps clean of any changes while running on test mode. Signed-off-by: Aline Manera --- root.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/root.py b/root.py index bffaef0..5ba4f68 100644 --- a/root.py +++ b/root.py @@ -17,9 +17,10 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 +import cherrypy import json import os -import cherrypy +import tempfile =20 from wok.plugins.kimchi import config, mockmodel, websocket from wok.plugins.kimchi.i18n import messages @@ -44,12 +45,22 @@ class Kimchi(WokRoot): if not os.path.isdir(directory): os.makedirs(directory) =20 - if hasattr(wok_options, "model"): - self.model =3D wok_options.model - elif wok_options.test: - self.model =3D mockmodel.MockModel() + # When running on test mode, specify the objectstore location to + # remove the file on server shutting down. That way, the system wi= ll + # not suffer any change while running on test mode + if wok_options.test and (wok_options.test is True or + wok_options.test.lower() =3D=3D 'true'): + self.objectstore_loc =3D tempfile.mktemp() + self.model =3D mockmodel.MockModel(self.objectstore_loc) + + def remove_objectstore(): + if os.path.exists(self.objectstore_loc): + os.unlink(self.objectstore_loc) + cherrypy.engine.subscribe('exit', remove_objectstore) else: self.model =3D kimchiModel.Model() + ws_proxy =3D websocket.new_ws_proxy() + cherrypy.engine.subscribe('exit', ws_proxy.terminate) =20 dev_env =3D wok_options.environment !=3D 'production' super(Kimchi, self).__init__(self.model, dev_env) @@ -57,10 +68,6 @@ class Kimchi(WokRoot): for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) =20 - if isinstance(self.model, kimchiModel.Model): - ws_proxy =3D websocket.new_ws_proxy() - cherrypy.engine.subscribe('exit', ws_proxy.terminate) - self.api_schema =3D json.load(open(os.path.join(os.path.dirname( os.path.abspath(__file__)), 'API.json'= ))) self.paths =3D config.kimchiPaths --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel