From d3f82757c8280352452c0cb415bd016565430701 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 10 Jan 2023 08:05:52 +0100 Subject: [PATCH] return first site image only --- IM/InfrastructureManager.py | 3 ++- test/unit/test_im_logic.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/IM/InfrastructureManager.py b/IM/InfrastructureManager.py index dbc5c6831..06bf8dadf 100644 --- a/IM/InfrastructureManager.py +++ b/IM/InfrastructureManager.py @@ -403,6 +403,7 @@ def search_vm(inf, radl_sys, auth): new_sys = system(radl_sys.name) new_sys.setValue("disk.0.image.url", image["uri"]) res.append(new_sys) + break return res @staticmethod @@ -451,7 +452,7 @@ def systems_with_iis(sel_inf, radl, auth): vmrc_res = [s0 for vmrc in vmrc_list for s0 in vmrc.search_vm(s)] appdbis_res = [s0 for appdbis in appdbis_list for s0 in appdbis.search_vm(s)] - local_res = InfrastructureManager.search_vm(sel_inf, radl, auth) + local_res = InfrastructureManager.search_vm(sel_inf, s, auth) # Check that now the image URL is in the RADL if not s.getValue("disk.0.image.url") and not vmrc_res and not appdbis_res and not local_res: sel_inf.add_cont_msg("No VMI obtained from VMRC nor AppDBIS nor Sites to system: " + system_id) diff --git a/test/unit/test_im_logic.py b/test/unit/test_im_logic.py index d79270bdd..cf4c53f27 100755 --- a/test/unit/test_im_logic.py +++ b/test/unit/test_im_logic.py @@ -1481,13 +1481,15 @@ def test_search_vm(self, dummycc): dummy = MagicMock(["list_images"]) dummycc.return_value = dummy dummy.list_images.side_effect = [[{"name": "ubuntu-20.04-raw", "uri": "imageuri"}], - [{"name": "ubuntu-20.04-raw", "uri": "imageuri2"}]] + [{"name": "ubuntu-22.04-raw", "uri": "imageuri2"}, + {"name": "ubuntu-20.04-raw", "uri": "imageuri3"}, + {"name": "ubuntu-20.04-raw", "uri": "imageuri4"}]] res = IM.search_vm(inf, radl_sys, auth) self.assertEqual(len(res), 2) self.assertEqual(res[0].name, "s0") self.assertEqual(res[0].getValue("disk.0.image.url"), "imageuri") self.assertEqual(res[1].name, "s0") - self.assertEqual(res[1].getValue("disk.0.image.url"), "imageuri2") + self.assertEqual(res[1].getValue("disk.0.image.url"), "imageuri3") if __name__ == "__main__":