From a3065de36d3cddcbbacfca8082ace161a46f60dd Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 11 Jul 2024 13:25:08 +0200 Subject: [PATCH 1/3] Fix problem with 0 disk flavors --- IM/connectors/OpenStack.py | 6 ++++++ test/unit/connectors/OpenStack.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index f9dcef36..4f0ad11a 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -321,6 +321,12 @@ def get_instance_type(self, driver, radl, location=None): sgx = radl.getValue('cpu.sgx') epc_size = radl.getFeature('cpu.sgx.epc_size') + # If no disk size is set, set a default value + # for flavors with 0 disk size set + if disk_free <= 0 and not radl.getValue('disk.0.size'): + disk_free = 10 + disk_free_op = self.OPERATORSMAP.get(">=") + # get the node size with the lowest price, vcpus, memory and disk sizes.sort(key=lambda x: (x.price, x.extra['pci_devices'], x.vcpus, x.ram, x.disk)) for size in sizes: diff --git a/test/unit/connectors/OpenStack.py b/test/unit/connectors/OpenStack.py index 692fc761..23306983 100644 --- a/test/unit/connectors/OpenStack.py +++ b/test/unit/connectors/OpenStack.py @@ -81,7 +81,7 @@ def test_10_concrete(self, get_driver): node_size.id = '1' node_size.ram = 512 node_size.price = 1 - node_size.disk = 1 + node_size.disk = 10 node_size.vcpus = 1 node_size.name = "g.small" node_size.extra = {'pci_passthrough:alias': 'GPU:2,FPGA:1'} @@ -89,7 +89,7 @@ def test_10_concrete(self, get_driver): node_size.id = '2' node_size2.ram = 512 node_size2.price = 1 - node_size2.disk = 1 + node_size2.disk = 10 node_size2.vcpus = 1 node_size2.name = "small" node_size2.extra = {} From 593bfba1dd94788c21d3a98bb2b11ced41dc0aa3 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 11 Jul 2024 13:37:23 +0200 Subject: [PATCH 2/3] Fix tests --- test/unit/connectors/OpenStack.py | 6 +++--- test/unit/connectors/Orange.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/unit/connectors/OpenStack.py b/test/unit/connectors/OpenStack.py index 23306983..f0ba1e6f 100644 --- a/test/unit/connectors/OpenStack.py +++ b/test/unit/connectors/OpenStack.py @@ -156,7 +156,7 @@ def test_15_concrete_appdb(self, get_driver, get_image_id, get_site_url, get_sit node_size = MagicMock() node_size.ram = 512 node_size.price = 1 - node_size.disk = 1 + node_size.disk = 10 node_size.vcpus = 1 node_size.name = "small" driver.list_sizes.return_value = [node_size] @@ -219,7 +219,7 @@ def test_20_launch(self, get_image_data, save_data, get_driver): node_size = MagicMock() node_size.ram = 512 node_size.price = 1 - node_size.disk = 1 + node_size.disk = 10 node_size.vcpus = 1 node_size.name = "small" driver.list_sizes.return_value = [node_size] @@ -654,7 +654,7 @@ def test_55_alter(self, add_elastic_ip_from_pool, get_driver): node_size = MagicMock() node_size.ram = 2048 node_size.price = 1 - node_size.disk = 1 + node_size.disk = 10 node_size.vcpus = 2 node_size.name = "small" driver.list_sizes.return_value = [node_size] diff --git a/test/unit/connectors/Orange.py b/test/unit/connectors/Orange.py index ee940840..a8f57955 100644 --- a/test/unit/connectors/Orange.py +++ b/test/unit/connectors/Orange.py @@ -76,7 +76,7 @@ def test_10_concrete(self, get_driver): node_size = MagicMock() node_size.ram = 512 node_size.price = 1 - node_size.disk = 1 + node_size.disk = 10 node_size.vcpus = 1 node_size.name = "small" driver.list_sizes.return_value = [node_size] @@ -133,7 +133,7 @@ def test_20_launch(self, save_data, get_driver): node_size = MagicMock() node_size.ram = 512 node_size.price = 1 - node_size.disk = 1 + node_size.disk = 10 node_size.vcpus = 1 node_size.name = "small" driver.list_sizes.return_value = [node_size] @@ -468,7 +468,7 @@ def test_55_alter(self, add_elastic_ip_from_pool, get_driver): node_size = MagicMock() node_size.ram = 2048 node_size.price = 1 - node_size.disk = 1 + node_size.disk = 10 node_size.vcpus = 2 node_size.name = "small" driver.list_sizes.return_value = [node_size] From 87f4fe4d44446bf31af341dbedea9a661521106c Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 11 Jul 2024 13:38:43 +0200 Subject: [PATCH 3/3] Fix problem with 0 disk flavors --- IM/connectors/OpenStack.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index 4f0ad11a..1205709e 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -67,6 +67,8 @@ class OpenStackCloudConnector(LibCloudCloudConnector): """ Confirm Timeout """ DEFAULT_AUTH_VERSION = '2.0_password' """ Default authentication method """ + MINMUM_DISK_SIZE = 5 + """ Default minimum root disk size in GB """ def __init__(self, cloud_info, inf): self.auth = None @@ -324,7 +326,7 @@ def get_instance_type(self, driver, radl, location=None): # If no disk size is set, set a default value # for flavors with 0 disk size set if disk_free <= 0 and not radl.getValue('disk.0.size'): - disk_free = 10 + disk_free = self.MINMUM_DISK_SIZE disk_free_op = self.OPERATORSMAP.get(">=") # get the node size with the lowest price, vcpus, memory and disk