diff --git a/IM/InfrastructureManager.py b/IM/InfrastructureManager.py index eab08d99..21ca9017 100644 --- a/IM/InfrastructureManager.py +++ b/IM/InfrastructureManager.py @@ -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 diff --git a/test/unit/test_im_logic.py b/test/unit/test_im_logic.py index 68ce6315..5750911c 100644 --- a/test/unit/test_im_logic.py +++ b/test/unit/test_im_logic.py @@ -1541,11 +1541,15 @@ 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, { @@ -1553,8 +1557,11 @@ def test_estimate_resources(self): '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')