Skip to content

Commit

Permalink
Fix EstimateResouces
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Dec 12, 2024
1 parent 4c2b1c2 commit 37ddf63
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
21 changes: 11 additions & 10 deletions IM/InfrastructureManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2031,16 +2031,17 @@ def EstimateResouces(radl_data, auth):
if disk_size:
vm['diskSizeInGigabytes'] = disk_size

res[cloud_id]["compute"].append(vm)

cont = 1
while (concrete_system.getValue("disk." + str(cont) + ".size")):
volume_size = concrete_system.getFeature("disk." + str(cont) + ".size").getValue('G')
vol_info = {"sizeInGigabytes": volume_size}
if concrete_system.getValue("disk." + str(cont) + ".type"):
vol_info["type"] = concrete_system.getValue("disk." + str(cont) + ".type")
res[cloud_id]["storage"].append(vol_info)
cont += 1
for _ in range(0, deploy.vm_number):
res[cloud_id]["compute"].append(vm)

cont = 1
while (concrete_system.getValue("disk." + str(cont) + ".size")):
volume_size = concrete_system.getFeature("disk." + str(cont) + ".size").getValue('G')
vol_info = {"sizeInGigabytes": volume_size}
if concrete_system.getValue("disk." + str(cont) + ".type"):
vol_info["type"] = concrete_system.getValue("disk." + str(cont) + ".type")
res[cloud_id]["storage"].append(vol_info)
cont += 1

return res

Expand Down
13 changes: 10 additions & 3 deletions test/unit/test_im_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1541,20 +1541,27 @@ def test_estimate_resources(self):
net_interface.0.connection = 'privada' and
disk.0.image.url = 'mock0://linux.for.ev.er' and
disk.0.free_size >= 10GB and
disk.0.os.name = 'linux'
disk.0.os.name = 'linux' and
disk.1.size=20GB and
disk.1.device='hdb' and
disk.1.fstype='ext4' and
disk.1.mount_path='/mnt/disk'
)
deploy front 1
deploy wn 1
deploy wn 2
"""
res = IM.EstimateResouces(radl, self.getAuth([0], [], [("Dummy", 0)]))
self.assertEqual(res, {
'cloud0': {
'cloudType': 'Dummy',
'cloudEndpoint': 'http://server.com:80/path',
'compute': [{'cpuCores': 2, 'memoryInMegabytes': 4000, 'diskSizeInGigabytes': 40},
{'cpuCores': 1, 'memoryInMegabytes': 2000, 'diskSizeInGigabytes': 10},
{'cpuCores': 1, 'memoryInMegabytes': 2000, 'diskSizeInGigabytes': 10}],
'storage': [{'sizeInGigabytes': 100}]
'storage': [{'sizeInGigabytes': 100},
{'sizeInGigabytes': 20},
{'sizeInGigabytes': 20}]
}})

@patch('IM.Stats.DataBase')
Expand Down

0 comments on commit 37ddf63

Please sign in to comment.