فهرست منبع

Add optional min and max memory to VM export info

Source providers can report the balloon floor and ceiling so destinations
no longer have to hardcode a minimum when dynamic memory is enabled.
Fabian Fulga 6 روز پیش
والد
کامیت
24d00e95f8

+ 8 - 0
coriolis/schemas/vm_export_info_schema.json

@@ -10,6 +10,14 @@
       "type": "integer",
       "description": "Memory of the VM in MegaBytes."
     },
+    "min_memory_mb": {
+      "type": "integer",
+      "description": "Minimum guaranteed/reserved memory of the VM in MegaBytes. Source providers should populate this from the source balloon floor, reservation, or dynamic-memory minimum. When dynamic memory is disabled, this should equal memory_mb."
+    },
+    "max_memory_mb": {
+      "type": "integer",
+      "description": "Maximum memory the VM may consume in MegaBytes when dynamic memory/ballooning is enabled. When omitted or when dynamic memory is disabled, this should equal memory_mb."
+    },
     "name": {
       "type": "string",
       "description": "Human-readable name of th VM."

+ 6 - 0
coriolis/tests/integration/test_provider/exp.py

@@ -218,6 +218,9 @@ class TestExportProvider(
             "instance_name": name,
             "num_cpu": 1,
             "memory_mb": 512,
+            "min_memory_mb": 512,
+            "max_memory_mb": 512,
+            "dynamic_memory_enabled": False,
             "os_type": "linux",
             "nested_virtualization": False,
             "devices": {
@@ -268,6 +271,9 @@ class TestExportProvider(
             "instance_name": instance_name,
             "num_cpu": 1,
             "memory_mb": 512,
+            "min_memory_mb": 512,
+            "max_memory_mb": 512,
+            "dynamic_memory_enabled": False,
             "os_type": "linux",
             "nested_virtualization": False,
             "devices": {

+ 3 - 0
coriolis/tests/integration/test_provider/imp.py

@@ -312,6 +312,9 @@ class TestImportProvider(
             "name": "test-instance",
             "num_cpu": 1,
             "memory_mb": 512,
+            "min_memory_mb": 512,
+            "max_memory_mb": 512,
+            "dynamic_memory_enabled": False,
             "os_type": "linux",
             "nested_virtualization": False,
             "devices": {

+ 37 - 0
coriolis/tests/test_schemas.py

@@ -159,3 +159,40 @@ class SchemasTestCase(test_base.CoriolisBaseTestCase):
                 test_value, test_schema, raise_on_error=False
             )
         self.assertEqual(result, False)
+
+
+def _minimal_export_info():
+    return {
+        "id": "vm-id",
+        "name": "vm-name",
+        "num_cpu": 1,
+        "memory_mb": 4096,
+        "os_type": "linux",
+        "nested_virtualization": False,
+        "devices": {
+            "disks": [{"id": "disk-1", "size_bytes": 1}],
+            "cdroms": [],
+            "nics": [{"network_name": "net", "mac_address": "00:00:00:00:00:00"}],
+            "serial_ports": [],
+            "floppies": [],
+            "controllers": [],
+        },
+    }
+
+
+class VMExportInfoSchemaTestCase(test_base.CoriolisBaseTestCase):
+    def test_memory_ballooning_fields_optional(self):
+        schemas.validate_value(
+            _minimal_export_info(), schemas.CORIOLIS_VM_EXPORT_INFO_SCHEMA
+        )
+
+    def test_memory_ballooning_fields_accepted(self):
+        export_info = _minimal_export_info()
+        export_info.update(
+            {
+                "dynamic_memory_enabled": True,
+                "min_memory_mb": 2048,
+                "max_memory_mb": 8192,
+            }
+        )
+        schemas.validate_value(export_info, schemas.CORIOLIS_VM_EXPORT_INFO_SCHEMA)