Skip to content

Commit

Permalink
Merge pull request #1594 from grycap/devel
Browse files Browse the repository at this point in the history
Fix problem with 0 disk flavors
  • Loading branch information
micafer authored Jul 11, 2024
2 parents b720bd8 + ab5d91c commit 9076d9d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 8 additions & 0 deletions IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -321,6 +323,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 = self.MINMUM_DISK_SIZE
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:
Expand Down
10 changes: 5 additions & 5 deletions test/unit/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ 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'}
node_size2 = MagicMock()
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 = {}
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions test/unit/connectors/Orange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 9076d9d

Please sign in to comment.