From nobody Fri Apr 19 21:47:06 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 1486492564862541.3673920967688; Tue, 7 Feb 2017 10:36:04 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id E2A718205D1; Tue, 7 Feb 2017 18:36:03 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 01D3E82040C for ; Tue, 7 Feb 2017 18:35:36 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v17ISXrT142762 for ; Tue, 7 Feb 2017 13:35:36 -0500 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0a-001b2d01.pphosted.com with ESMTP id 28ffdc5rcy-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Feb 2017 13:35:35 -0500 Received: from localhost by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Feb 2017 16:35:34 -0200 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Feb 2017 16:35:32 -0200 Received: from d24relay03.br.ibm.com (d24relay03.br.ibm.com [9.18.232.225]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 18BB8352006C for ; Tue, 7 Feb 2017 13:34:59 -0500 (EST) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v17IZW7r37093532 for ; Tue, 7 Feb 2017 16:35:32 -0200 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v17IZVI0003335 for ; Tue, 7 Feb 2017 16:35:32 -0200 Received: from alinefm-TP440.ibmmodules.com ([9.85.187.18]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v17IZRMx003298 for ; Tue, 7 Feb 2017 16:35:31 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Tue, 7 Feb 2017 16:35:11 -0200 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> References: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020718-0028-0000-0000-00000192FDBE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020718-0029-0000-0000-0000148F2CD1 Message-Id: <20170207183516.5661-2-alinefm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-07_10:, , 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-1702070175 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 | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/root.py b/root.py index bffaef0..3b39c05 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,20 @@ 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: + 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 +66,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 Apr 19 21:47:06 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 1486492593165623.8196348810014; Tue, 7 Feb 2017 10:36:33 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 52AA58205C4; Tue, 7 Feb 2017 18:36:32 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 05AAB82054C for ; Tue, 7 Feb 2017 18:35:40 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v17ISVtZ142697 for ; Tue, 7 Feb 2017 13:35:40 -0500 Received: from e24smtp02.br.ibm.com (e24smtp02.br.ibm.com [32.104.18.86]) by mx0a-001b2d01.pphosted.com with ESMTP id 28feqjr41r-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Feb 2017 13:35:40 -0500 Received: from localhost by e24smtp02.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Feb 2017 16:35:37 -0200 Received: from d24dlp02.br.ibm.com (9.18.248.206) by e24smtp02.br.ibm.com (10.172.0.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Feb 2017 16:35:34 -0200 Received: from d24relay03.br.ibm.com (d24relay03.br.ibm.com [9.18.232.225]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id 1191C1DC006D for ; Tue, 7 Feb 2017 13:35:35 -0500 (EST) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v17IZXGv39911604 for ; Tue, 7 Feb 2017 16:35:33 -0200 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v17IZXxC003353 for ; Tue, 7 Feb 2017 16:35:33 -0200 Received: from alinefm-TP440.ibmmodules.com ([9.85.187.18]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v17IZRN0003298 for ; Tue, 7 Feb 2017 16:35:32 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Tue, 7 Feb 2017 16:35:12 -0200 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> References: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020718-0020-0000-0000-00000284E69E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020718-0021-0000-0000-0000309F0776 Message-Id: <20170207183516.5661-3-alinefm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-07_10:, , 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-1702070175 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 --- root.py | 3 ++- 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 ++++----- 13 files changed, 64 insertions(+), 81 deletions(-) diff --git a/root.py b/root.py index 3b39c05..68c4a78 100644 --- a/root.py +++ b/root.py @@ -48,9 +48,10 @@ class Kimchi(WokRoot): # 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: + if wok_options.test is True or wok_options.test.lower() =3D=3D 'tr= ue': 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) 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 Apr 19 21:47:06 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 1486492578043493.36949790407255; Tue, 7 Feb 2017 10:36:18 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 22CCB8205DD; Tue, 7 Feb 2017 18:36:17 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 8BBD882054C for ; Tue, 7 Feb 2017 18:35:40 +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 v17IXwg9039704 for ; Tue, 7 Feb 2017 13:35:40 -0500 Received: from e24smtp02.br.ibm.com (e24smtp02.br.ibm.com [32.104.18.86]) by mx0a-001b2d01.pphosted.com with ESMTP id 28fj84btaj-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Feb 2017 13:35:39 -0500 Received: from localhost by e24smtp02.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Feb 2017 16:35:37 -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; Tue, 7 Feb 2017 16:35:36 -0200 Received: from d24relay02.br.ibm.com (d24relay02.br.ibm.com [9.18.232.42]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 67AC1352006C for ; Tue, 7 Feb 2017 13:35:02 -0500 (EST) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v17IZZKv39649498 for ; Tue, 7 Feb 2017 16:35:35 -0200 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v17IZZFa003375 for ; Tue, 7 Feb 2017 16:35:35 -0200 Received: from alinefm-TP440.ibmmodules.com ([9.85.187.18]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v17IZRN1003298 for ; Tue, 7 Feb 2017 16:35:34 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Tue, 7 Feb 2017 16:35:13 -0200 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> References: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020718-0020-0000-0000-00000284E6A0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020718-0021-0000-0000-0000309F0778 Message-Id: <20170207183516.5661-4-alinefm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-07_10:, , 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-1702070175 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 Apr 19 21:47:06 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 1486492604562946.4443090168513; Tue, 7 Feb 2017 10:36:44 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 790198205C4; Tue, 7 Feb 2017 18:36:43 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 0805282054C for ; Tue, 7 Feb 2017 18:35:41 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v17ISVl8146268 for ; Tue, 7 Feb 2017 13:35:41 -0500 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0a-001b2d01.pphosted.com with ESMTP id 28faw8bb6j-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Feb 2017 13:35:41 -0500 Received: from localhost by e24smtp03.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Feb 2017 16:35:38 -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; Tue, 7 Feb 2017 16:35:37 -0200 Received: from d24relay01.br.ibm.com (d24relay01.br.ibm.com [9.8.31.16]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id 1F3ED1DC0054 for ; Tue, 7 Feb 2017 13:35:38 -0500 (EST) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay01.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v17IZa2f3829870 for ; Tue, 7 Feb 2017 16:35:36 -0200 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v17IZaDR003391 for ; Tue, 7 Feb 2017 16:35:36 -0200 Received: from alinefm-TP440.ibmmodules.com ([9.85.187.18]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v17IZRN2003298 for ; Tue, 7 Feb 2017 16:35:36 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Tue, 7 Feb 2017 16:35:14 -0200 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> References: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020718-0024-0000-0000-00000150F628 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020718-0025-0000-0000-0000161519BE Message-Id: <20170207183516.5661-5-alinefm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-07_10:, , 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-1702070175 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 Apr 19 21:47:06 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 1486492616381292.9805369261469; Tue, 7 Feb 2017 10:36:56 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id A05CB8205C4; Tue, 7 Feb 2017 18:36:55 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 991BF82054C for ; Tue, 7 Feb 2017 18:35:43 +0000 (UTC) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v17ISUSA119151 for ; Tue, 7 Feb 2017 13:35:42 -0500 Received: from e24smtp05.br.ibm.com (e24smtp05.br.ibm.com [32.104.18.26]) by mx0b-001b2d01.pphosted.com with ESMTP id 28feynf7fr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Feb 2017 13:35:42 -0500 Received: from localhost by e24smtp05.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Feb 2017 16:35:40 -0200 Received: from d24dlp02.br.ibm.com (9.18.248.206) by e24smtp05.br.ibm.com (10.172.0.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Feb 2017 16:35:39 -0200 Received: from d24relay03.br.ibm.com (d24relay03.br.ibm.com [9.18.232.225]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id B839C1DC0054 for ; Tue, 7 Feb 2017 13:35:39 -0500 (EST) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v17IZcwq41025728 for ; Tue, 7 Feb 2017 16:35:38 -0200 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v17IZcrW003417 for ; Tue, 7 Feb 2017 16:35:38 -0200 Received: from alinefm-TP440.ibmmodules.com ([9.85.187.18]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v17IZRN3003298 for ; Tue, 7 Feb 2017 16:35:37 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Tue, 7 Feb 2017 16:35:15 -0200 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> References: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020718-0032-0000-0000-0000053BF64A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020718-0033-0000-0000-000011BE205A Message-Id: <20170207183516.5661-6-alinefm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-07_10:, , 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-1702070175 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 Apr 19 21:47:06 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 1486492628621253.35011617833788; Tue, 7 Feb 2017 10:37:08 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id CA3238205C1; Tue, 7 Feb 2017 18:37:07 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id EE02A82054C for ; Tue, 7 Feb 2017 18:35:46 +0000 (UTC) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v17ISqS4064314 for ; Tue, 7 Feb 2017 13:35:46 -0500 Received: from e24smtp01.br.ibm.com (e24smtp01.br.ibm.com [32.104.18.85]) by mx0a-001b2d01.pphosted.com with ESMTP id 28fgmt1cv8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Feb 2017 13:35:45 -0500 Received: from localhost by e24smtp01.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Feb 2017 16:35:43 -0200 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp01.br.ibm.com (10.172.0.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Feb 2017 16:35:41 -0200 Received: from d24relay01.br.ibm.com (d24relay01.br.ibm.com [9.8.31.16]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 96D44352006C for ; Tue, 7 Feb 2017 13:35:07 -0500 (EST) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay01.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v17IZedt4047030 for ; Tue, 7 Feb 2017 16:35:40 -0200 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v17IZeCm003451 for ; Tue, 7 Feb 2017 16:35:40 -0200 Received: from alinefm-TP440.ibmmodules.com ([9.85.187.18]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v17IZRN4003298 for ; Tue, 7 Feb 2017 16:35:39 -0200 X-Original-To: kimchi-devel@ovirt.org From: Aline Manera To: Kimchi Devel Date: Tue, 7 Feb 2017 16:35:16 -0200 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> References: <20170207183516.5661-1-alinefm@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020718-1523-0000-0000-0000027CEAD9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020718-1524-0000-0000-00002A110C0F Message-Id: <20170207183516.5661-7-alinefm@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-07_10:, , 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-1702070175 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