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

Fix problem with 0 disk flavors #1595 #1594

Merged
merged 4 commits into from
Jul 11, 2024
Merged
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
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