From 5a673fcdada46d57bfb80d617f5fab70888a71c2 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Mon, 25 Nov 2024 16:50:47 +0100 Subject: [PATCH 1/3] Add docs about cloud conn --- doc/source/manual.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/source/manual.rst b/doc/source/manual.rst index b3caa58a..028d5af8 100644 --- a/doc/source/manual.rst +++ b/doc/source/manual.rst @@ -593,3 +593,28 @@ 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 + +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 `_ +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/`` \ No newline at end of file From da46dde0f6fccf0bec34f3dedc105caa73531a35 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Mon, 25 Nov 2024 16:53:31 +0100 Subject: [PATCH 2/3] Fix typo --- doc/source/manual.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/manual.rst b/doc/source/manual.rst index 028d5af8..39e2a5ec 100644 --- a/doc/source/manual.rst +++ b/doc/source/manual.rst @@ -609,6 +609,7 @@ class. The new connector must implement at least the following methods: - ``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. From 37ddf63a3a007c692cbae9297a898ed8fd40591c Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 12 Dec 2024 10:33:57 +0100 Subject: [PATCH 3/3] Fix EstimateResouces --- IM/InfrastructureManager.py | 21 +++++++++++---------- test/unit/test_im_logic.py | 13 ++++++++++--- 2 files changed, 21 insertions(+), 13 deletions(-) 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')