Skip to content

Commit

Permalink
return first site image only
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Jan 10, 2023
1 parent 247a934 commit d3f8275
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion IM/InfrastructureManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions test/unit/test_im_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down

0 comments on commit d3f8275

Please sign in to comment.