From nobody Fri Mar 29 08:52:47 2024 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 Reviewed-By: Lucio Correia --- 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 From nobody Fri Mar 29 08:52:47 2024 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 1486605786838735.5769378900096; Wed, 8 Feb 2017 18:03:06 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id C630C8205CD; Thu, 9 Feb 2017 02:03:05 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 4E60682059B for ; Thu, 9 Feb 2017 02:02:24 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v191wVdk108752 for ; Wed, 8 Feb 2017 21:02:23 -0500 Received: from e24smtp02.br.ibm.com (e24smtp02.br.ibm.com [32.104.18.86]) by mx0b-001b2d01.pphosted.com with ESMTP id 28gcrj4tre-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 08 Feb 2017 21:02:23 -0500 Received: from localhost by e24smtp02.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 d24dlp01.br.ibm.com (9.18.248.204) by e24smtp02.br.ibm.com (10.172.0.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Feb 2017 00:02:18 -0200 Received: from d24relay01.br.ibm.com (d24relay01.br.ibm.com [9.8.31.16]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 3AA41352005F for ; Wed, 8 Feb 2017 21:01:45 -0500 (EST) Received: from d24av05.br.ibm.com (d24av05.br.ibm.com [9.18.232.44]) by d24relay01.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1922I124784196 for ; Thu, 9 Feb 2017 00:02:18 -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 v1922I56015796 for ; Thu, 9 Feb 2017 00:02:18 -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 v1922D8G015772 for ; Thu, 9 Feb 2017 00:02:17 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Thu, 9 Feb 2017 00:01:58 -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-0020-0000-0000-000002857447 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020902-0021-0000-0000-0000309F95C1 Message-Id: <20170209020202.17425-3-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 2/6] Update run_server() calls to do not pass model instance 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" The model instance will be gotten from cherrypy when needed. Signed-off-by: Aline Manera Reviewed-By: Lucio Correia --- tests/test_authorization.py | 10 ++++------ tests/test_host.py | 15 +++------------ tests/test_livemigration.py | 6 +----- tests/test_mock_network.py | 10 ++++------ tests/test_mock_storagepool.py | 12 ++++-------- tests/test_mock_storagevolume.py | 11 ++++------- tests/test_mockmodel.py | 8 +++----- tests/test_model_network.py | 18 +++++++++++------- tests/test_model_storagepool.py | 18 ++++++++++-------- tests/test_model_storagevolume.py | 18 +++++++++++------- tests/test_rest.py | 7 +++---- tests/test_template.py | 9 ++++----- 12 files changed, 62 insertions(+), 80 deletions(-) diff --git a/tests/test_authorization.py b/tests/test_authorization.py index 565f446..b67d8d6 100644 --- a/tests/test_authorization.py +++ b/tests/test_authorization.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2014-2016 +# Copyright IBM Corp, 2014-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -17,6 +17,7 @@ # 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 unittest @@ -25,8 +26,6 @@ from functools import partial from tests.utils import get_fake_user, patch_auth from tests.utils import request, run_server, wait_task =20 -from wok.plugins.kimchi import mockmodel - from iso_gen import construct_fake_iso =20 =20 @@ -39,8 +38,8 @@ def setUpModule(): global test_server, model =20 patch_auth(sudo=3DFalse) - model =3D mockmodel.MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 # Create fake ISO to do the tests construct_fake_iso(fake_iso, True, '12.04', 'ubuntu') @@ -48,7 +47,6 @@ def setUpModule(): =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') os.unlink(fake_iso) =20 =20 diff --git a/tests/test_host.py b/tests/test_host.py index 1ee3368..6db6839 100644 --- a/tests/test_host.py +++ b/tests/test_host.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -19,33 +19,24 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA =20 import json -import os -import tempfile import unittest from functools import partial =20 from tests.utils import patch_auth, request, run_server =20 -from wok.plugins.kimchi.mockmodel import MockModel - =20 test_server =3D None -model =3D None -tmpfile =3D None =20 =20 def setUpModule(): - global test_server, model, tmpfile + global test_server =20 patch_auth() - tmpfile =3D tempfile.mktemp() - model =3D MockModel(tmpfile) - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) =20 =20 def tearDownModule(): test_server.stop() - os.unlink(tmpfile) =20 =20 class HostTests(unittest.TestCase): diff --git a/tests/test_livemigration.py b/tests/test_livemigration.py index 7d49dc1..90fdaa1 100644 --- a/tests/test_livemigration.py +++ b/tests/test_livemigration.py @@ -407,12 +407,8 @@ class LiveMigrationTests(unittest.TestCase): 'not possible to test a live migration') def test_vm_livemigrate_persistent_API(self): patch_auth() - - inst =3D model.Model(libvirt_uri=3D'qemu:///system', - objstore_loc=3Dself.tmp_store) - with RollbackContext() as rollback: - test_server =3D run_server(test_mode=3DTrue, model=3Dinst) + test_server =3D run_server() rollback.prependDefer(test_server.stop) =20 self.request =3D partial(request) diff --git a/tests/test_mock_network.py b/tests/test_mock_network.py index 48e5557..c1e875d 100644 --- a/tests/test_mock_network.py +++ b/tests/test_mock_network.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,14 +18,13 @@ # 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 unittest from functools import partial =20 from tests.utils import patch_auth, request, run_server =20 -from wok.plugins.kimchi.mockmodel import MockModel from wok.plugins.kimchi.model.featuretests import FeatureTests =20 from test_model_network import _do_network_test @@ -39,13 +38,12 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') =20 =20 class MockNetworkTests(unittest.TestCase): diff --git a/tests/test_mock_storagepool.py b/tests/test_mock_storagepool.py index 5c152e4..f584382 100644 --- a/tests/test_mock_storagepool.py +++ b/tests/test_mock_storagepool.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,16 +18,13 @@ # 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 unittest from functools import partial =20 from tests.utils import patch_auth, request, run_server =20 -from wok.plugins.kimchi.mockmodel import MockModel - - model =3D None test_server =3D None =20 @@ -36,13 +33,12 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') =20 =20 class MockStoragepoolTests(unittest.TestCase): diff --git a/tests/test_mock_storagevolume.py b/tests/test_mock_storagevolu= me.py index 3380bd5..4b3306b 100644 --- a/tests/test_mock_storagevolume.py +++ b/tests/test_mock_storagevolume.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,15 +18,13 @@ # 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 unittest from functools import partial =20 from tests.utils import patch_auth, request, run_server =20 -from wok.plugins.kimchi.mockmodel import MockModel - from test_model_storagevolume import _do_volume_test =20 =20 @@ -38,13 +36,12 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') =20 =20 class MockStorageVolumeTests(unittest.TestCase): diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py index 826af12..19994ab 100644 --- a/tests/test_mockmodel.py +++ b/tests/test_mockmodel.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2013-2016 +# Copyright IBM Corp, 2013-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -27,7 +27,6 @@ from tests.utils import patch_auth, request, run_server from tests.utils import wait_task =20 from wok.exception import InvalidOperation -from wok.plugins.kimchi import mockmodel from wok.plugins.kimchi.osinfo import get_template_default =20 import iso_gen @@ -40,16 +39,15 @@ fake_iso =3D None def setUpModule(): global model, test_server, fake_iso cherrypy.request.headers =3D {'Accept': 'application/json'} - model =3D mockmodel.MockModel('/tmp/obj-store-test') patch_auth() - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model fake_iso =3D '/tmp/fake.iso' iso_gen.construct_fake_iso(fake_iso, True, '12.04', 'ubuntu') =20 =20 def tearDown(): test_server.stop() - os.unlink('/tmp/obj-store-test') os.unlink(fake_iso) =20 =20 diff --git a/tests/test_model_network.py b/tests/test_model_network.py index 79fda88..e83c515 100644 --- a/tests/test_model_network.py +++ b/tests/test_model_network.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,8 +18,11 @@ # 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 mock import os +import tempfile import unittest from functools import partial =20 @@ -28,25 +31,26 @@ from tests.utils import run_server =20 from wok.rollbackcontext import RollbackContext =20 -from wok.plugins.kimchi.model.model import Model from wok.plugins.kimchi.model.featuretests import FeatureTests =20 - model =3D None +objectstore_loc =3D tempfile.mktemp() test_server =3D None =20 =20 -def setUpModule(): +@mock.patch('wok.plugins.kimchi.config.get_object_store') +def setUpModule(func): + func.return_value =3D objectstore_loc global test_server, model =20 patch_auth() - model =3D Model(None, '/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DFalse) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') + os.unlink(objectstore_loc) =20 =20 def _do_network_test(self, model, params): diff --git a/tests/test_model_storagepool.py b/tests/test_model_storagepool= .py index 2210a37..a1a5d95 100644 --- a/tests/test_model_storagepool.py +++ b/tests/test_model_storagepool.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,7 +18,9 @@ # 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 mock import os import shutil import tempfile @@ -27,27 +29,27 @@ from functools import partial =20 from wok.rollbackcontext import RollbackContext =20 -from wok.plugins.kimchi.model.model import Model - from tests.utils import patch_auth, request from tests.utils import run_server =20 - model =3D None +objectstore_loc =3D tempfile.mktemp() test_server =3D None =20 =20 -def setUpModule(): +@mock.patch('wok.plugins.kimchi.config.get_object_store') +def setUpModule(func): + func.return_value =3D objectstore_loc global test_server, model =20 patch_auth() - model =3D Model(None, '/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DFalse) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') + os.unlink(objectstore_loc) =20 =20 class StoragepoolTests(unittest.TestCase): diff --git a/tests/test_model_storagevolume.py b/tests/test_model_storagevo= lume.py index cacfbb5..a1f1db9 100644 --- a/tests/test_model_storagevolume.py +++ b/tests/test_model_storagevolume.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,9 +18,12 @@ # 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 mock import os import requests +import tempfile import unittest from functools import partial =20 @@ -32,24 +35,25 @@ from wok.config import paths from wok.rollbackcontext import RollbackContext =20 from wok.plugins.kimchi.config import READONLY_POOL_TYPE -from wok.plugins.kimchi.model.model import Model - =20 model =3D None +objectstore_loc =3D tempfile.mktemp() test_server =3D None =20 =20 -def setUpModule(): +@mock.patch('wok.plugins.kimchi.config.get_object_store') +def setUpModule(func): + func.return_value =3D objectstore_loc global test_server, model =20 patch_auth() - model =3D Model(None, '/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DFalse) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') + os.unlink(objectstore_loc) =20 =20 def _do_volume_test(self, model, pool_name): diff --git a/tests/test_rest.py b/tests/test_rest.py index a06cfe5..09fd8a5 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -18,6 +18,7 @@ # 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 re @@ -32,7 +33,6 @@ from tests.utils import patch_auth, request, run_server, = wait_task from wok.asynctask import AsyncTask from wok.rollbackcontext import RollbackContext =20 -from wok.plugins.kimchi import mockmodel from wok.plugins.kimchi.osinfo import get_template_default =20 import iso_gen @@ -50,8 +50,8 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D mockmodel.MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model =20 # Create fake ISO to do the tests iso_gen.construct_fake_iso(fake_iso, True, '12.04', 'ubuntu') @@ -61,7 +61,6 @@ def setUpModule(): =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') os.unlink(fake_iso) os.unlink("/var/lib/libvirt/images/fedora.iso") =20 diff --git a/tests/test_template.py b/tests/test_template.py index 8127a82..bf63acf 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,6 +18,7 @@ # 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 iso_gen import json import os @@ -28,7 +29,6 @@ from functools import partial from tests.utils import patch_auth, request, run_server =20 from wok.plugins.kimchi.config import READONLY_POOL_TYPE -from wok.plugins.kimchi.mockmodel import MockModel from wok.plugins.kimchi.model.featuretests import FeatureTests from wok.plugins.kimchi.model.templates import MAX_MEM_LIM =20 @@ -43,14 +43,13 @@ def setUpModule(): global test_server, model =20 patch_auth() - model =3D MockModel('/tmp/obj-store-test') - test_server =3D run_server(test_mode=3DTrue, model=3Dmodel) + test_server =3D run_server(test_mode=3DTrue) + model =3D cherrypy.tree.apps['/plugins/kimchi'].root.model iso_gen.construct_fake_iso(MOCK_ISO, True, '14.04', 'ubuntu') =20 =20 def tearDownModule(): test_server.stop() - os.unlink('/tmp/obj-store-test') =20 =20 class TemplateTests(unittest.TestCase): --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Fri Mar 29 08:52:47 2024 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 1486605800087319.7793610800377; Wed, 8 Feb 2017 18:03:20 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 1B18F8205EA; Thu, 9 Feb 2017 02:03:19 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 97E928205B7 for ; Thu, 9 Feb 2017 02:02:24 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v191wVwJ061629 for ; Wed, 8 Feb 2017 21:02:24 -0500 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0b-001b2d01.pphosted.com with ESMTP id 28gburevy2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 08 Feb 2017 21:02:23 -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:21 -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:20 -0200 Received: from d24relay03.br.ibm.com (d24relay03.br.ibm.com [9.18.232.225]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id 203251DC006D for ; Wed, 8 Feb 2017 21:02:21 -0500 (EST) Received: from d24av05.br.ibm.com (d24av05.br.ibm.com [9.18.232.44]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1922JRs39125068 for ; Thu, 9 Feb 2017 00:02:19 -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 v1922KEQ015808 for ; Thu, 9 Feb 2017 00:02:20 -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 v1922D8H015772 for ; Thu, 9 Feb 2017 00:02:19 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Thu, 9 Feb 2017 00:01:59 -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-0000015185E4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020902-0025-0000-0000-00001615AA1B Message-Id: <20170209020202.17425-4-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 3/6] Bug fix: Set default host value while generating the virt-viewer config file 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" The test case was failing as below: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ERROR: test_vm_virtviewerfile_vmlifecycle (test_model.ModelTests) Reviewed-By: Lucio Correia ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/mock/mock.py", line 1305, in patch= ed return func(*args, **keywargs) File "test_model.py", line 571, in test_vm_virtviewerfile_vmlifecycle vvmodel.lookup(vm_name.decode('utf-8')) File "/home/alinefm/wok/src/wok/plugins/kimchi/model/virtviewerfile.py", = line 133, in lookup file_path =3D create_virt_viewer_file(name, graphics_info) File "/home/alinefm/wok/src/wok/plugins/kimchi/model/virtviewerfile.py", = line 82, in create_virt_viewer_file {'name': vm_name, 'err': e.message}) OperationFailed: KCHVM0084E: KCHVM0084E Because the virt-viewer config file generation was relying on Wok configuration to get the host information but the host information is not part of Wok anymore. Instead of that, it is being configured on nginx. Set it to 'localhost' when that information is not part of request headers. Signed-off-by: Aline Manera --- model/virtviewerfile.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/model/virtviewerfile.py b/model/virtviewerfile.py index 8e3be8f..533978f 100644 --- a/model/virtviewerfile.py +++ b/model/virtviewerfile.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2016 +# Copyright IBM Corp, 2016-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -22,7 +22,6 @@ import cherrypy import libvirt import os =20 -from wok.config import config as wok_config from wok.exception import InvalidOperation, OperationFailed from wok.plugins.kimchi import config as kimchi_config from wok.plugins.kimchi.model.vms import VMModel @@ -49,9 +48,7 @@ port=3D%(graphics_port)s =20 =20 def _get_request_host(): - host =3D cherrypy.request.headers.get('Host') - if not host: - host =3D wok_config.get("server", "host") + host =3D cherrypy.request.headers.get('Host', 'localhost') host =3D host.split(':')[0] return host =20 @@ -107,7 +104,8 @@ class VMVirtViewerFileModel(object): vm_name =3D dom.name() self.firewall_mngr.remove_vm_graphics_port(vm_name) cb_id =3D self.vm_event_callbacks.pop(vm_name, None) - self.conn.get().domainEventDeregisterAny(cb_id) + if cb_id is not None: + self.conn.get().domainEventDeregisterAny(cb_id) =20 def handleVMShutdownPowerOff(self, vm_name): try: --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Fri Mar 29 08:52:47 2024 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 14866058115841005.2363421235829; Wed, 8 Feb 2017 18:03:31 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 6CB108205EA; Thu, 9 Feb 2017 02:03:30 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 4A3028205B7 for ; Thu, 9 Feb 2017 02:02:27 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v191wWJF013254 for ; Wed, 8 Feb 2017 21:02:26 -0500 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0a-001b2d01.pphosted.com with ESMTP id 28g0c8df92-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 08 Feb 2017 21:02:26 -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:23 -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:22 -0200 Received: from d24relay03.br.ibm.com (d24relay03.br.ibm.com [9.18.232.225]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id 9B28E1DC0054 for ; Wed, 8 Feb 2017 21:02:22 -0500 (EST) Received: from d24av05.br.ibm.com (d24av05.br.ibm.com [9.18.232.44]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1922L7940435758 for ; Thu, 9 Feb 2017 00:02:21 -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 v1922LTe015813 for ; Thu, 9 Feb 2017 00:02:21 -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 v1922D8I015772 for ; Thu, 9 Feb 2017 00:02:20 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Thu, 9 Feb 2017 00:02:00 -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-0000015185E5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020902-0025-0000-0000-00001615AA1C Message-Id: <20170209020202.17425-5-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 4/6] Fix snapshots test case 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" Commit a2063007 has added a new test to validate snapshot on running guest but it has not considered the whole test case in count and it was failing as below: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D FAIL: test_vm_lifecycle (test_model.ModelTests) Reviewed-By: Lucio Correia ---------------------------------------------------------------------- Traceback (most recent call last): File "test_model.py", line 218, in test_vm_lifecycle self.assertEquals({}, empty_snap) AssertionError: {} !=3D {'state': u'running', 'name': u'1486470484', 'paren= t': u'', 'created': u'1486470 [truncated]... - {} + {'created': u'1486470484', + 'name': u'1486470484', + 'parent': u'', + 'state': u'running'} So fix it. Signed-off-by: Aline Manera --- tests/test_model.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index a14cf56..95c9e08 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -210,12 +210,14 @@ class ModelTests(unittest.TestCase): inst.task_wait(task['id']) task =3D inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) + snap_name =3D task['target_uri'].split('/')[-1] + created_snaps =3D [snap_name] =20 inst.vm_poweroff(u'kimchi-vm') vm =3D inst.vm_lookup(u'kimchi-vm') =20 - empty_snap =3D inst.currentvmsnapshot_lookup(u'kimchi-vm') - self.assertEquals({}, empty_snap) + current_snap =3D inst.currentvmsnapshot_lookup(u'kimchi-vm') + self.assertEquals(created_snaps[0], current_snap['name']) =20 # this snapshot should be deleted when its VM is deleted params =3D {'name': u'mysnap'} @@ -223,6 +225,7 @@ class ModelTests(unittest.TestCase): inst.task_wait(task['id']) task =3D inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) + created_snaps.append(params['name']) =20 self.assertRaises(NotFoundError, inst.vmsnapshot_lookup, u'kimchi-vm', u'foobar') @@ -231,10 +234,10 @@ class ModelTests(unittest.TestCase): self.assertTrue(int(time.time()) >=3D int(snap['created'])) self.assertEquals(vm['state'], snap['state']) self.assertEquals(params['name'], snap['name']) - self.assertEquals(u'', snap['parent']) + self.assertEquals(created_snaps[0], snap['parent']) =20 snaps =3D inst.vmsnapshots_get_list(u'kimchi-vm') - self.assertEquals([params['name']], snaps) + self.assertEquals(created_snaps, snaps) =20 current_snap =3D inst.currentvmsnapshot_lookup(u'kimchi-vm') self.assertEquals(snap, current_snap) @@ -246,10 +249,10 @@ class ModelTests(unittest.TestCase): inst.task_wait(task['id']) task =3D inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) + created_snaps.append(snap_name) =20 snaps =3D inst.vmsnapshots_get_list(u'kimchi-vm') - self.assertEquals(sorted([params['name'], snap_name], - key=3Dunicode.lower), snaps) + self.assertEquals(sorted(created_snaps, key=3Dunicode.lower), = snaps) =20 snap =3D inst.vmsnapshot_lookup(u'kimchi-vm', snap_name) current_snap =3D inst.currentvmsnapshot_lookup(u'kimchi-vm') --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Fri Mar 29 08:52:47 2024 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 1486605823358679.8855095930425; Wed, 8 Feb 2017 18:03:43 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 70FA48205DC; Thu, 9 Feb 2017 02:03:42 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 3B7828205B7 for ; Thu, 9 Feb 2017 02:02:28 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v191wUON108722 for ; Wed, 8 Feb 2017 21:02:27 -0500 Received: from e24smtp05.br.ibm.com (e24smtp05.br.ibm.com [32.104.18.26]) by mx0b-001b2d01.pphosted.com with ESMTP id 28gcrj4tu9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 08 Feb 2017 21:02:27 -0500 Received: from localhost by e24smtp05.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Feb 2017 00:02:24 -0200 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp05.br.ibm.com (10.172.0.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Feb 2017 00:02:23 -0200 Received: from d24relay02.br.ibm.com (d24relay02.br.ibm.com [9.18.232.42]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id DA977352005F for ; Wed, 8 Feb 2017 21:01:49 -0500 (EST) Received: from d24av05.br.ibm.com (d24av05.br.ibm.com [9.18.232.44]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1922MWJ28049466 for ; Thu, 9 Feb 2017 00:02:22 -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 v1922NVw015823 for ; Thu, 9 Feb 2017 00:02:23 -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 v1922D8J015772 for ; Thu, 9 Feb 2017 00:02:22 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Thu, 9 Feb 2017 00:02:01 -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> MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020902-0032-0000-0000-0000053C84B7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020902-0033-0000-0000-000011BEAF85 Message-Id: <20170209020202.17425-6-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 5/6] Fix memory hotplug test case 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: , Content-Type: text/plain; charset="utf-8" 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 The memory hotplug support depends on libvirt and qemu support. The libvirt test driver does not support this type of configuration so update the test case to verify the system has its support or not. Signed-off-by: Aline Manera Reviewed-By: Lucio Correia --- tests/test_rest.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/test_rest.py b/tests/test_rest.py index 09fd8a5..4c7ab5b 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -179,7 +179,10 @@ class RestTests(unittest.TestCase): resp =3D self.request('/plugins/kimchi/vms/vm-1', req, 'PUT') self.assertEquals(400, resp.status) =20 - if not os.uname()[4] =3D=3D "s390x": + # Check if there is support to memory hotplug + resp =3D self.request('/plugins/kimchi/config/capabilities').read() + conf =3D json.loads(resp) + if os.uname()[4] !=3D "s390x" and conf['mem_hotplug_support']: req =3D json.dumps({'memory': {'maxmemory': 3072}}) resp =3D self.request('/plugins/kimchi/vms/vm-1', req, 'PUT') self.assertEquals(200, resp.status) @@ -195,9 +198,7 @@ class RestTests(unittest.TestCase): resp =3D self.request('/plugins/kimchi/vms/vm-1', req, 'PUT') self.assertEquals(400, resp.status) =20 - # Check if there is support to memory hotplug, once vm is running - resp =3D self.request('/plugins/kimchi/config/capabilities').read() - conf =3D json.loads(resp) + # Test memory hotplug req =3D json.dumps({'memory': {'current': 2048}}) resp =3D self.request('/plugins/kimchi/vms/vm-1', req, 'PUT') if conf['mem_hotplug_support']: @@ -254,6 +255,9 @@ class RestTests(unittest.TestCase): vm =3D json.loads( self.request('/plugins/kimchi/vms/vm-1', req).read() ) + + # The maxmemory will be automatically increased when the amount of + # memory value is greater than the current maxmemory value params =3D {'name': u'=E2=88=A8=D0=BC-=D1=86=D1=80d=CE=B1t=D0=B5d'= , 'cpu_info': {'vcpus': 5}, 'memory': {'current': 3072}} req =3D json.dumps(params) @@ -265,11 +269,9 @@ class RestTests(unittest.TestCase): # Memory was hot plugged vm['name'] =3D u'=E2=88=A8=D0=BC-=D1=86=D1=80d=CE=B1t=D0=B5d' vm['cpu_info'].update(params['cpu_info']) - if not os.uname()[4] =3D=3D "s390x": - vm['memory'].update(params['memory']) - else: - vm['memory']['current'] =3D 3072 - vm['memory']['maxmemory'] =3D 3072 + vm['memory']['current'] =3D 3072 + vm['memory']['maxmemory'] =3D 3072 + for key in params.keys(): self.assertEquals(vm[key], vm_updated[key]) =20 --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Fri Mar 29 08:52:47 2024 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 1486605835789382.81372495729306; Wed, 8 Feb 2017 18:03:55 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id D99A98205AB; Thu, 9 Feb 2017 02:03:54 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 721BC8205B7 for ; Thu, 9 Feb 2017 02:02:29 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v191wTsg062599 for ; Wed, 8 Feb 2017 21:02:28 -0500 Received: from e24smtp01.br.ibm.com (e24smtp01.br.ibm.com [32.104.18.85]) by mx0b-001b2d01.pphosted.com with ESMTP id 28gekb9722-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 08 Feb 2017 21:02:28 -0500 Received: from localhost by e24smtp01.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Feb 2017 00:02:26 -0200 Received: from d24dlp02.br.ibm.com (9.18.248.206) by e24smtp01.br.ibm.com (10.172.0.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Feb 2017 00:02:25 -0200 Received: from d24relay01.br.ibm.com (d24relay01.br.ibm.com [9.8.31.16]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id 9AB451DC0054 for ; Wed, 8 Feb 2017 21:02:25 -0500 (EST) Received: from d24av05.br.ibm.com (d24av05.br.ibm.com [9.18.232.44]) by d24relay01.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1922Oas4792528 for ; Thu, 9 Feb 2017 00:02:24 -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 v1922O97015834 for ; Thu, 9 Feb 2017 00:02:24 -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 v1922D8K015772 for ; Thu, 9 Feb 2017 00:02:23 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Thu, 9 Feb 2017 00:02:02 -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-1523-0000-0000-0000027D77E3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020902-1524-0000-0000-00002A1199DD Message-Id: <20170209020202.17425-7-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 6/6] Improve logic to identify if a network is in use or not 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" The function get_vms_attach_to_a_network() to identify which virtual machines are using a given network was being called multiple times without need. So improve the logic. Signed-off-by: Aline Manera Reviewed-By: Lucio Correia --- i18n.py | 4 ++-- model/networks.py | 42 ++++++++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/i18n.py b/i18n.py index f505693..4460ce5 100644 --- a/i18n.py +++ b/i18n.py @@ -300,8 +300,8 @@ messages =3D { "KCHNET0014E": _("Network interfaces must be an array."), "KCHNET0015E": _("Network VLAN ID must be an integer between 1 and 409= 4"), "KCHNET0016E": _("Specify name and type to create a Network"), - "KCHNET0017E": _("Unable to delete or update network %(name)s. There a= re some virtual machines %(vms)s and/or templates linked to this network."), - "KCHNET0018E": _("Unable to deactivate network %(name)s. There are som= e virtual machines %(vms)s and/or templates linked to this network."), + "KCHNET0017E": _("Unable to delete or update network %(name)s as it is= linked to some virtual machines (%(vms)s) and/or templates (%(tmpls)s)."), + "KCHNET0018E": _("Unable to deactivate network %(name)s as it is linke= d to are some virtual machines (%(vms)s) and/or templates (%(tmpls)s)."), "KCHNET0019E": _("Bridge device %(name)s can not be the trunk device o= f a VLAN."), "KCHNET0020E": _("Failed to activate interface %(iface)s: %(err)s."), "KCHNET0021E": _("Failed to activate interface %(iface)s. Please check= the physical link status."), diff --git a/model/networks.py b/model/networks.py index be4eec2..eb1590e 100644 --- a/model/networks.py +++ b/model/networks.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM Corp, 2015-2016 +# Copyright IBM Corp, 2015-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -383,12 +383,14 @@ class NetworkModel(object): else: interfaces =3D [interface] =20 + network_in_use, used_by_vms, _ =3D self._is_network_in_use(name) + return {'connection': connection, 'interfaces': interfaces, 'subnet': subnet, 'dhcp': dhcp, - 'vms': self._get_vms_attach_to_a_network(name), - 'in_use': self._is_network_in_use(name), + 'vms': used_by_vms, + 'in_use': network_in_use, 'autostart': network.autostart() =3D=3D 1, 'state': network.isActive() and "active" or "inactive", 'persistent': True if network.isPersistent() else False} @@ -397,20 +399,24 @@ class NetworkModel(object): # All the networks listed as default in template.conf file should = not # be deactivate or deleted. Otherwise, we will allow user create # inconsistent templates from scratch + vms =3D self._get_vms_attach_to_a_network(name) + tmpls =3D self._is_network_used_by_template(name) + if name in tmpl_defaults['networks']: - return True + return (True, vms, tmpls) =20 - vms =3D self._get_vms_attach_to_a_network(name) - return bool(vms) or self._is_network_used_by_template(name) + return (bool(vms) or bool(tmpls), vms, tmpls) =20 def _is_network_used_by_template(self, network): + tmpl_list =3D [] + with self.objstore as session: templates =3D session.get_list('template') for tmpl in templates: tmpl_net =3D session.get('template', tmpl)['networks'] if network in tmpl_net: - return True - return False + tmpl_list.append(tmpl) + return tmpl_list =20 def _get_vms_attach_to_a_network(self, network, filter=3D"all"): DOM_STATE_MAP =3D {'nostate': 0, 'running': 1, 'blocked': 2, @@ -440,21 +446,25 @@ class NetworkModel(object): 'err': e.message}) =20 def deactivate(self, name): - if self._is_network_in_use(name): - vms =3D self._get_vms_attach_to_a_network(name) - vms.sort() + in_use, used_by_vms, used_by_tmpls =3D self._is_network_in_use(nam= e) + vms =3D 'N/A' if len(used_by_vms) =3D=3D 0 else ', '.join(used_by_= vms) + tmpls =3D 'N/A' if len(used_by_tmpls) =3D=3D 0 else ', '.join(used= _by_tmpls) + if in_use: raise InvalidOperation("KCHNET0018E", {'name': name, - 'vms': ', '.join(vms)}) + 'vms': vms, + 'tmpls': tmpls}) =20 network =3D self.get_network(self.conn.get(), name) network.destroy() =20 def delete(self, name): - if self._is_network_in_use(name): - vms =3D self._get_vms_attach_to_a_network(name) - vms.sort() + in_use, used_by_vms, used_by_tmpls =3D self._is_network_in_use(nam= e) + vms =3D 'N/A' if len(used_by_vms) =3D=3D 0 else ', '.join(used_by_= vms) + tmpls =3D 'N/A' if len(used_by_tmpls) =3D=3D 0 else ', '.join(used= _by_tmpls) + if in_use: raise InvalidOperation("KCHNET0017E", {'name': name, - 'vms': ', '.join(vms)}) + 'vms': vms, + 'tmpls': tmpls}) =20 network =3D self.get_network(self.conn.get(), name) if network.isActive(): --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel