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

Implemented changes for VPU #485

Merged
merged 7 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions linode_api4/objects/linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
33 changes: 32 additions & 1 deletion test/fixtures/linode_types.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"results": 4,
"results": 5,
"pages": 1,
"page": 1,
"data": [
{
"accelerated_devices": 0,
"disk": 20480,
"memory": 1024,
"transfer": 1000,
Expand Down Expand Up @@ -52,6 +53,7 @@
"successor": null
},
{
"accelerated_devices": 0,
"disk": 20480,
"memory": 16384,
"transfer": 5000,
Expand Down Expand Up @@ -100,6 +102,7 @@
"successor": null
},
{
"accelerated_devices": 0,
"disk": 30720,
"memory": 2048,
"transfer": 2000,
Expand Down Expand Up @@ -148,6 +151,7 @@
"successor": null
},
{
"accelerated_devices": 0,
"disk": 49152,
"memory": 4096,
"transfer": 3000,
Expand Down Expand Up @@ -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
}
]
}
33 changes: 33 additions & 0 deletions test/integration/models/linode/test_linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ def linode_for_network_interface_tests(test_linode_client, e2e_test_firewall):
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/debian10",
ezilber-akamai marked this conversation as resolved.
Show resolved Hide resolved
label=label,
firewall=e2e_test_firewall,
)

yield linode_instance

linode_instance.delete()


@pytest.fixture
def linode_for_disk_tests(test_linode_client, e2e_test_firewall):
client = test_linode_client
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion test/unit/objects/linode_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
"""
Expand Down
Loading