Skip to content

Commit eab222b

Browse files
authored
Merge pull request #1642 from grycap/devel
Devel
2 parents bcfc346 + 37ddf63 commit eab222b

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

IM/InfrastructureManager.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -2031,16 +2031,17 @@ def EstimateResouces(radl_data, auth):
20312031
if disk_size:
20322032
vm['diskSizeInGigabytes'] = disk_size
20332033

2034-
res[cloud_id]["compute"].append(vm)
2035-
2036-
cont = 1
2037-
while (concrete_system.getValue("disk." + str(cont) + ".size")):
2038-
volume_size = concrete_system.getFeature("disk." + str(cont) + ".size").getValue('G')
2039-
vol_info = {"sizeInGigabytes": volume_size}
2040-
if concrete_system.getValue("disk." + str(cont) + ".type"):
2041-
vol_info["type"] = concrete_system.getValue("disk." + str(cont) + ".type")
2042-
res[cloud_id]["storage"].append(vol_info)
2043-
cont += 1
2034+
for _ in range(0, deploy.vm_number):
2035+
res[cloud_id]["compute"].append(vm)
2036+
2037+
cont = 1
2038+
while (concrete_system.getValue("disk." + str(cont) + ".size")):
2039+
volume_size = concrete_system.getFeature("disk." + str(cont) + ".size").getValue('G')
2040+
vol_info = {"sizeInGigabytes": volume_size}
2041+
if concrete_system.getValue("disk." + str(cont) + ".type"):
2042+
vol_info["type"] = concrete_system.getValue("disk." + str(cont) + ".type")
2043+
res[cloud_id]["storage"].append(vol_info)
2044+
cont += 1
20442045

20452046
return res
20462047

doc/source/manual.rst

+26
Original file line numberDiff line numberDiff line change
@@ -593,3 +593,29 @@ you can use the ``delete_old_infs`` script. It will delete from DB all the infra
593593
created before a specified date::
594594

595595
python delete_old_infs.py <date>
596+
597+
Add new Cloud Connectors
598+
========================
599+
600+
To add a new Cloud Connector you have to create a new Python file in the directory
601+
``IM/connectors/`` of the IM source code. The file must have a class with the same
602+
name as the file that inherits from the `CloudConnector <https://github.com/grycap/im/blob/master/IM/connectors/CloudConnector.py>`_
603+
class. This class must implement all the abstract methods of the ``CloudConnector``
604+
class. The new connector must implement at least the following methods:
605+
606+
- ``concrete_system``: Return a list of compatible systems with the cloud provider.
607+
- ``updateVMInfo``: Updates the information of a VM.
608+
- ``launch``: Launch a set of VMs to the Cloud provider.
609+
- ``finalize``: Terminates a VM and all the associated resources.
610+
611+
To have full support you have to implement the following methods:
612+
613+
- ``alterVM``: Modifies/resizes the features of a VM.
614+
- ``start``: Starts a (previously stopped) VM.
615+
- ``stop``: Stops (but not finalizes) a VM.
616+
- ``reboot``: Reboots a VM.
617+
- ``list_images``: Get a list of images on the cloud provider using IM URI format.
618+
- ``get_quotas``: Get the number of used and available resources in the cloud provider
619+
620+
The new connector must be added to the ``__all__`` variable in ``__init__.py`` file
621+
of the ``IM/connectors/``

test/unit/test_im_logic.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1541,20 +1541,27 @@ def test_estimate_resources(self):
15411541
net_interface.0.connection = 'privada' and
15421542
disk.0.image.url = 'mock0://linux.for.ev.er' and
15431543
disk.0.free_size >= 10GB and
1544-
disk.0.os.name = 'linux'
1544+
disk.0.os.name = 'linux' and
1545+
disk.1.size=20GB and
1546+
disk.1.device='hdb' and
1547+
disk.1.fstype='ext4' and
1548+
disk.1.mount_path='/mnt/disk'
15451549
)
15461550
15471551
deploy front 1
1548-
deploy wn 1
1552+
deploy wn 2
15491553
"""
15501554
res = IM.EstimateResouces(radl, self.getAuth([0], [], [("Dummy", 0)]))
15511555
self.assertEqual(res, {
15521556
'cloud0': {
15531557
'cloudType': 'Dummy',
15541558
'cloudEndpoint': 'http://server.com:80/path',
15551559
'compute': [{'cpuCores': 2, 'memoryInMegabytes': 4000, 'diskSizeInGigabytes': 40},
1560+
{'cpuCores': 1, 'memoryInMegabytes': 2000, 'diskSizeInGigabytes': 10},
15561561
{'cpuCores': 1, 'memoryInMegabytes': 2000, 'diskSizeInGigabytes': 10}],
1557-
'storage': [{'sizeInGigabytes': 100}]
1562+
'storage': [{'sizeInGigabytes': 100},
1563+
{'sizeInGigabytes': 20},
1564+
{'sizeInGigabytes': 20}]
15581565
}})
15591566

15601567
@patch('IM.Stats.DataBase')

0 commit comments

Comments
 (0)