Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel #1642

Merged
merged 4 commits into from
Dec 12, 2024
Merged

Devel #1642

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 26 additions & 0 deletions doc/source/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,29 @@ you can use the ``delete_old_infs`` script. It will delete from DB all the infra
created before a specified date::

python delete_old_infs.py <date>

Add new Cloud Connectors
========================

To add a new Cloud Connector you have to create a new Python file in the directory
``IM/connectors/`` of the IM source code. The file must have a class with the same
name as the file that inherits from the `CloudConnector <https://github.com/grycap/im/blob/master/IM/connectors/CloudConnector.py>`_
class. This class must implement all the abstract methods of the ``CloudConnector``
class. The new connector must implement at least the following methods:

- ``concrete_system``: Return a list of compatible systems with the cloud provider.
- ``updateVMInfo``: Updates the information of a VM.
- ``launch``: Launch a set of VMs to the Cloud provider.
- ``finalize``: Terminates a VM and all the associated resources.

To have full support you have to implement the following methods:

- ``alterVM``: Modifies/resizes the features of a VM.
- ``start``: Starts a (previously stopped) VM.
- ``stop``: Stops (but not finalizes) a VM.
- ``reboot``: Reboots a VM.
- ``list_images``: Get a list of images on the cloud provider using IM URI format.
- ``get_quotas``: Get the number of used and available resources in the cloud provider

The new connector must be added to the ``__all__`` variable in ``__init__.py`` file
of the ``IM/connectors/``
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
Loading