def test_get_available_resources_not_found(database_connection): """ Mock context : openstack's quotas says there currently remains: 128 - 28 = 100 instances 500 - 199 = 301 vcpus 286,720 - 184,320 = 102,400 ram (100 GiO) 128 - 100 = 28 volumes 1000 - 720 = 280 GiO of volume storage """ magic_castle = MagicCastle(database_connection) assert magic_castle.get_available_resources() == { "quotas": { "instance_count": { "max": 100 }, "ram": { "max": 102_400 }, "vcpus": { "max": 301 }, "volume_count": { "max": 28 }, "volume_size": { "max": 280 }, }, "resource_details": { "instance_types": [ { "name": "p1-1.5gb", "vcpus": 1, "ram": 1_536, "required_volume_count": 1, "required_volume_size": 10, }, { "name": "p2-3gb", "vcpus": 2, "ram": 3_072, "required_volume_count": 1, "required_volume_size": 10, }, { "name": "p4-6gb", "vcpus": 4, "ram": 6_144, "required_volume_count": 1, "required_volume_size": 10, }, { "name": "c8-30gb-186", "vcpus": 8, "ram": 30_720, "required_volume_count": 0, "required_volume_size": 0, }, { "name": "c8-90gb-186", "vcpus": 8, "ram": 92_160, "required_volume_count": 0, "required_volume_size": 0, }, { "name": "g2-c24-112gb-500", "vcpus": 24, "ram": 114_688, "required_volume_count": 0, "required_volume_size": 0, }, { "name": "c16-120gb-392", "vcpus": 16, "ram": 122_880, "required_volume_count": 0, "required_volume_size": 0, }, ] }, "possible_resources": { "image": ["centos7", "CentOS-8 x64", "CentOS VGPU"], "instances": { "mgmt": { "type": [ "p4-6gb", "c8-30gb-186", "c8-90gb-186", "g2-c24-112gb-500", "c16-120gb-392", ] }, "login": { "type": [ "p2-3gb", "p4-6gb", "c8-30gb-186", "c8-90gb-186", "g2-c24-112gb-500", "c16-120gb-392", ] }, "node": { "type": [ "p2-3gb", "p4-6gb", "c8-30gb-186", "c8-90gb-186", "g2-c24-112gb-500", "c16-120gb-392", ] }, }, "os_floating_ips": [ "Automatic allocation", "2.1.1.1", "2.1.1.2", "2.1.1.3", ], "storage": { "type": ["nfs"] }, "domain": ["calculquebec.cloud", "c3.ca", "sub.example.com"], }, }
def test_get_available_resources_missing_nodes(database_connection): """ Mock context : missingnodes cluster uses 0 instance 0 vcpus 0 ram 0 [root disks] + 3 [external volumes] = 3 volumes 0 + 0 + 0 [root disks] + 50 + 50 + 100 [external volumes] = 200 GiO of volume storage openstack's quotas says there currently remains: 128 - 28 = 100 instances 500 - 199 = 301 vcpus 286,720 - 184,320 = 102,400 ram (100 GiO) 128 - 100 = 28 volumes 1000 - 720 = 280 GiO of volume storage Therefore, missingnodes cluster can use a total of: 0 + 100 = 0 instances 0 + 301 = 301 vcpus 0 + 102,400 = 102,400 ram (100 GiO) 3 + 28 = 31 volumes 200 + 280 = 480 GiO of volume storage """ magic_castle = MagicCastle(database_connection, "missingnodes.sub.example.com") assert magic_castle.get_available_resources() == { "quotas": { "instance_count": { "max": 100 }, "ram": { "max": 102_400 }, "vcpus": { "max": 301 }, "volume_count": { "max": 31 }, "volume_size": { "max": 480 }, }, "resource_details": { "instance_types": [ { "name": "p1-1.5gb", "vcpus": 1, "ram": 1_536, "required_volume_count": 1, "required_volume_size": 10, }, { "name": "p2-3gb", "vcpus": 2, "ram": 3_072, "required_volume_count": 1, "required_volume_size": 10, }, { "name": "p4-6gb", "vcpus": 4, "ram": 6_144, "required_volume_count": 1, "required_volume_size": 10, }, { "name": "c8-30gb-186", "vcpus": 8, "ram": 30_720, "required_volume_count": 0, "required_volume_size": 0, }, { "name": "c8-90gb-186", "vcpus": 8, "ram": 92_160, "required_volume_count": 0, "required_volume_size": 0, }, { "name": "g2-c24-112gb-500", "vcpus": 24, "ram": 114_688, "required_volume_count": 0, "required_volume_size": 0, }, { "name": "c16-120gb-392", "vcpus": 16, "ram": 122_880, "required_volume_count": 0, "required_volume_size": 0, }, ] }, "possible_resources": { "image": ["centos7", "CentOS-8 x64", "CentOS VGPU"], "instances": { "mgmt": { "type": [ "p4-6gb", "c8-30gb-186", "c8-90gb-186", "g2-c24-112gb-500", "c16-120gb-392", ] }, "login": { "type": [ "p2-3gb", "p4-6gb", "c8-30gb-186", "c8-90gb-186", "g2-c24-112gb-500", "c16-120gb-392", ] }, "node": { "type": [ "p2-3gb", "p4-6gb", "c8-30gb-186", "c8-90gb-186", "g2-c24-112gb-500", "c16-120gb-392", ] }, }, "os_floating_ips": [ "Automatic allocation", "100.101.102.103", "2.1.1.1", "2.1.1.2", "2.1.1.3", ], "storage": { "type": ["nfs"] }, "domain": ["calculquebec.cloud", "c3.ca", "sub.example.com"], }, }