diff --git a/linode_api4/objects/linode.py b/linode_api4/objects/linode.py index 8fe71bb7..776e1f98 100644 --- a/linode_api4/objects/linode.py +++ b/linode_api4/objects/linode.py @@ -269,6 +269,7 @@ class Type(Base): "vcpus": Property(), "gpus": Property(), "successor": Property(), + "accelerated_devices": Property(), # type_class is populated from the 'class' attribute of the returned JSON } diff --git a/test/fixtures/linode_types.json b/test/fixtures/linode_types.json index 819867b7..dee3209e 100644 --- a/test/fixtures/linode_types.json +++ b/test/fixtures/linode_types.json @@ -1,9 +1,10 @@ { - "results": 4, + "results": 5, "pages": 1, "page": 1, "data": [ { + "accelerated_devices": 0, "disk": 20480, "memory": 1024, "transfer": 1000, @@ -52,6 +53,7 @@ "successor": null }, { + "accelerated_devices": 0, "disk": 20480, "memory": 16384, "transfer": 5000, @@ -100,6 +102,7 @@ "successor": null }, { + "accelerated_devices": 0, "disk": 30720, "memory": 2048, "transfer": 2000, @@ -148,6 +151,7 @@ "successor": null }, { + "accelerated_devices": 0, "disk": 49152, "memory": 4096, "transfer": 3000, @@ -194,6 +198,33 @@ } ], "successor": null + }, + { + "id": "g1-accelerated-netint-vpu-t1u1-m", + "label": "Netint Quadra T1U x1 Medium", + "price": { + "hourly": 0.0, + "monthly": 0.0 + }, + "region_prices": [], + "addons": { + "backups": { + "price": { + "hourly": 0.0, + "monthly": 0.0 + }, + "region_prices": [] + } + }, + "memory": 24576, + "disk": 307200, + "transfer": 0, + "vcpus": 12, + "gpus": 0, + "network_out": 16000, + "class": "accelerated", + "successor": null, + "accelerated_devices": 1 } ] } \ No newline at end of file diff --git a/test/integration/models/linode/test_linode.py b/test/integration/models/linode/test_linode.py index a8ba2b21..2ec1fed6 100644 --- a/test/integration/models/linode/test_linode.py +++ b/test/integration/models/linode/test_linode.py @@ -38,7 +38,7 @@ def linode_with_volume_firewall(test_linode_client): linode_instance, password = client.linode.instance_create( "g6-nanode-1", region, - image="linode/debian10", + image="linode/debian12", label=label + "_modlinode", ) @@ -76,7 +76,27 @@ def linode_for_network_interface_tests(test_linode_client, e2e_test_firewall): linode_instance, password = client.linode.instance_create( "g6-nanode-1", region, - image="linode/debian10", + image="linode/debian12", + label=label, + firewall=e2e_test_firewall, + ) + + yield linode_instance + + linode_instance.delete() + + +@pytest.fixture(scope="session") +def linode_for_vpu_tests(test_linode_client, e2e_test_firewall): + client = test_linode_client + region = "us-lax" + + label = get_test_label(length=8) + + linode_instance, password = client.linode.instance_create( + "g1-accelerated-netint-vpu-t1u1-s", + region, + image="linode/debian12", label=label, firewall=e2e_test_firewall, ) @@ -147,7 +167,7 @@ def create_linode_for_long_running_tests(test_linode_client, e2e_test_firewall): linode_instance, password = client.linode.instance_create( "g6-nanode-1", region, - image="linode/debian10", + image="linode/debian12", label=label + "_long_tests", firewall=e2e_test_firewall, ) @@ -196,6 +216,13 @@ def test_get_linode(test_linode_client, linode_with_volume_firewall): assert linode.id == linode_with_volume_firewall.id +def test_get_vpu(test_linode_client, linode_for_vpu_tests): + linode = test_linode_client.load(Instance, linode_for_vpu_tests.id) + + assert linode.label == linode_for_vpu_tests.label + assert hasattr(linode.specs, "accelerated_devices") + + def test_linode_transfer(test_linode_client, linode_with_volume_firewall): linode = test_linode_client.load(Instance, linode_with_volume_firewall.id) @@ -214,7 +241,7 @@ def test_linode_rebuild(test_linode_client): label = get_test_label() + "_rebuild" linode, password = client.linode.instance_create( - "g6-nanode-1", region, image="linode/debian10", label=label + "g6-nanode-1", region, image="linode/debian12", label=label ) wait_for_condition(10, 100, get_status, linode, "running") @@ -222,14 +249,14 @@ def test_linode_rebuild(test_linode_client): retry_sending_request( 3, linode.rebuild, - "linode/debian10", + "linode/debian12", disk_encryption=InstanceDiskEncryptionType.disabled, ) wait_for_condition(10, 100, get_status, linode, "rebuilding") assert linode.status == "rebuilding" - assert linode.image.id == "linode/debian10" + assert linode.image.id == "linode/debian12" assert linode.disk_encryption == InstanceDiskEncryptionType.disabled @@ -272,7 +299,7 @@ def test_delete_linode(test_linode_client): linode_instance, password = client.linode.instance_create( "g6-nanode-1", region, - image="linode/debian10", + image="linode/debian12", label=label + "_linode", ) @@ -591,6 +618,9 @@ def test_get_linode_types(test_linode_client): assert len(types) > 0 assert "g6-nanode-1" in ids + for linode_type in types: + assert hasattr(linode_type, "accelerated_devices") + def test_get_linode_types_overrides(test_linode_client): types = test_linode_client.linode.types() @@ -691,6 +721,9 @@ def test_create_vlan(self, linode_for_network_interface_tests): assert interface.label == "testvlan" assert interface.ipam_address == "10.0.0.2/32" + def test_create_vpu(self, test_linode_client, linode_for_vpu_tests): + assert hasattr(linode_for_vpu_tests.specs, "accelerated_devices") + def test_create_vpc( self, test_linode_client, diff --git a/test/unit/objects/linode_test.py b/test/unit/objects/linode_test.py index 700e5d0d..5f95e8d3 100644 --- a/test/unit/objects/linode_test.py +++ b/test/unit/objects/linode_test.py @@ -656,7 +656,7 @@ def test_get_types(self): """ types = self.client.linode.types() - self.assertEqual(len(types), 4) + self.assertEqual(len(types), 5) for t in types: self.assertTrue(t._populated) self.assertIsNotNone(t.id) @@ -667,6 +667,7 @@ def test_get_types(self): self.assertIsNone(t.successor) self.assertIsNotNone(t.region_prices) self.assertIsNotNone(t.addons.backups.region_prices) + self.assertIsNotNone(t.accelerated_devices) def test_get_type_by_id(self): """