Skip to content

Commit 4c3f306

Browse files
Merge pull request #368 from linode/dev
Release v5.12.0
2 parents c88d8ed + d09d2ea commit 4c3f306

28 files changed

+278
-181
lines changed

.github/workflows/e2e-test-pr.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
uses: actions/checkout@v3
3636
with:
3737
ref: ${{ inputs.sha }}
38+
fetch-depth: 0
39+
submodules: 'recursive'
3840

3941
- name: Get the hash value of the latest commit from the PR branch
4042
uses: octokit/graphql-action@v2.x
@@ -94,7 +96,7 @@ jobs:
9496
- name: Add additional information to XML report
9597
run: |
9698
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
97-
python test/script/add_to_xml_test_report.py \
99+
python tod_scripts/add_to_xml_test_report.py \
98100
--branch_name "${GITHUB_REF#refs/*/}" \
99101
--gha_run_id "$GITHUB_RUN_ID" \
100102
--gha_run_number "$GITHUB_RUN_NUMBER" \
@@ -103,7 +105,7 @@ jobs:
103105
- name: Upload test results
104106
run: |
105107
report_filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
106-
python3 test/script/test_report_upload_script.py "${report_filename}"
108+
python3 tod_scripts/test_report_upload_script.py "${report_filename}"
107109
env:
108110
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
109111
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tod_scripts"]
2+
path = tod_scripts
3+
url = https://github.com/linode/TOD-test-report-uploader.git

linode_api4/objects/linode.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ def _populate(self, json):
256256
"""
257257
Allows changing the name "class" in JSON to "type_class" in python
258258
"""
259+
259260
super()._populate(json)
260261

261-
if "class" in json:
262+
if json is not None and "class" in json:
262263
setattr(self, "type_class", json["class"])
263264
else:
264265
setattr(self, "type_class", None)
@@ -612,6 +613,11 @@ def _interface_create(self, body: Dict[str, Any]) -> NetworkInterface:
612613
return i
613614

614615

616+
class MigrationType:
617+
COLD = "cold"
618+
WARM = "warm"
619+
620+
615621
class Instance(Base):
616622
"""
617623
A Linode Instance.
@@ -948,7 +954,13 @@ def reboot(self):
948954
return False
949955
return True
950956

951-
def resize(self, new_type, allow_auto_disk_resize=True, **kwargs):
957+
def resize(
958+
self,
959+
new_type,
960+
allow_auto_disk_resize=True,
961+
migration_type: MigrationType = MigrationType.COLD,
962+
**kwargs,
963+
):
952964
"""
953965
Resizes a Linode you have the read_write permission to a different Type. If any
954966
actions are currently running or queued, those actions must be completed first
@@ -970,6 +982,10 @@ def resize(self, new_type, allow_auto_disk_resize=True, **kwargs):
970982
data must fit within the smaller disk size. Defaults to true.
971983
:type: allow_auto_disk_resize: bool
972984
985+
:param migration_type: Type of migration to be used when resizing a Linode.
986+
Customers can choose between warm and cold, the default type is cold.
987+
:type: migration_type: str
988+
973989
:returns: True if the operation was successful.
974990
:rtype: bool
975991
"""
@@ -979,6 +995,7 @@ def resize(self, new_type, allow_auto_disk_resize=True, **kwargs):
979995
params = {
980996
"type": new_type,
981997
"allow_auto_disk_resize": allow_auto_disk_resize,
998+
"migration_type": migration_type,
982999
}
9831000
params.update(kwargs)
9841001

@@ -1438,7 +1455,12 @@ def mutate(self, allow_auto_disk_resize=True):
14381455

14391456
return True
14401457

1441-
def initiate_migration(self, region=None, upgrade=None):
1458+
def initiate_migration(
1459+
self,
1460+
region=None,
1461+
upgrade=None,
1462+
migration_type: MigrationType = MigrationType.COLD,
1463+
):
14421464
"""
14431465
Initiates a pending migration that is already scheduled for this Linode
14441466
Instance
@@ -1459,10 +1481,16 @@ def initiate_migration(self, region=None, upgrade=None):
14591481
region field does not allow upgrades, then the endpoint will return a 400 error
14601482
code and the migration will not be performed.
14611483
:type: upgrade: bool
1484+
1485+
:param migration_type: The type of migration that will be used for this Linode migration.
1486+
Customers can only use this param when activating a support-created migration.
1487+
Customers can choose between a cold and warm migration, cold is the default type.
1488+
:type: mirgation_type: str
14621489
"""
14631490
params = {
14641491
"region": region.id if issubclass(type(region), Base) else region,
14651492
"upgrade": upgrade,
1493+
"type": migration_type,
14661494
}
14671495

14681496
util.drop_null_keys(params)

linode_api4/objects/lke.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ def _populate(self, json):
8181
"""
8282
Parse Nodes into more useful LKENodePoolNode objects
8383
"""
84-
if json != {}:
84+
if json is not None and json != {}:
8585
new_nodes = [
86-
LKENodePoolNode(self._client, c) for c in json["nodes"]
86+
LKENodePoolNode(self._client, c)
87+
if not isinstance(c, dict)
88+
else c
89+
for c in json["nodes"]
8790
]
8891
json["nodes"] = new_nodes
8992

linode_api4/objects/nodebalancer.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Property,
1010
Region,
1111
)
12-
from linode_api4.objects.networking import IPAddress
12+
from linode_api4.objects.networking import Firewall, IPAddress
1313

1414

1515
class NodeBalancerNode(DerivedBase):
@@ -303,3 +303,21 @@ def statistics(self):
303303
"Unexpected response generating stats!", json=result
304304
)
305305
return MappedObject(**result)
306+
307+
def firewalls(self):
308+
"""
309+
View Firewall information for Firewalls associated with this NodeBalancer.
310+
311+
API Documentation: https://www.linode.com/docs/api/nodebalancers/#nodebalancer-firewalls-list
312+
313+
:returns: A List of Firewalls of the Linode NodeBalancer.
314+
:rtype: List[Firewall]
315+
"""
316+
result = self._client.get(
317+
"{}/firewalls".format(NodeBalancer.api_endpoint), model=self
318+
)
319+
320+
return [
321+
Firewall(self._client, firewall["id"])
322+
for firewall in result["data"]
323+
]

test/fixtures/linode_instances.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"hypervisor": "kvm",
99
"id": 123,
1010
"status": "running",
11-
"type": "g5-standard-1",
11+
"type": "g6-standard-1",
1212
"alerts": {
1313
"network_in": 5,
1414
"network_out": 5,

test/fixtures/linode_types.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"network_out": 1000,
3232
"vcpus": 1,
3333
"gpus": 0,
34-
"id": "g5-nanode-1",
34+
"id": "g6-nanode-1",
3535
"label": "Linode 1024",
3636
"price": {
3737
"hourly": 0.0075,
@@ -127,7 +127,7 @@
127127
"network_out": 1000,
128128
"vcpus": 1,
129129
"gpus": 0,
130-
"id": "g5-standard-1",
130+
"id": "g6-standard-1",
131131
"label": "Linode 2048",
132132
"price": {
133133
"hourly": 0.015,
@@ -175,7 +175,7 @@
175175
"network_out": 1000,
176176
"vcpus": 2,
177177
"gpus": 1,
178-
"id": "g5-gpu-2",
178+
"id": "g6-gpu-2",
179179
"label": "Linode 4096",
180180
"price": {
181181
"hourly": 0.03,
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"disk": 20480,
3+
"memory": 1024,
4+
"transfer": 1000,
5+
"addons": {
6+
"backups": {
7+
"price": {
8+
"hourly": 0.003,
9+
"monthly": 2
10+
},
11+
"region_prices": [
12+
{
13+
"id": "ap-west",
14+
"hourly": 0.02,
15+
"monthly": 20
16+
},
17+
{
18+
"id": "ap-northeast",
19+
"hourly": 0.02,
20+
"monthly": 20
21+
}
22+
]
23+
}
24+
},
25+
"class": "nanode",
26+
"network_out": 1000,
27+
"vcpus": 1,
28+
"gpus": 0,
29+
"id": "g5-nanode-1",
30+
"label": "Linode 1024",
31+
"price": {
32+
"hourly": 0.0075,
33+
"monthly": 5
34+
},
35+
"region_prices": [
36+
{
37+
"id": "us-east",
38+
"hourly": 0.02,
39+
"monthly": 20
40+
},
41+
{
42+
"id": "ap-northeast",
43+
"hourly": 0.02,
44+
"monthly": 20
45+
}
46+
],
47+
"successor": null
48+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"data": [
3+
{
4+
"created": "2018-01-01T00:01:01",
5+
"id": 123,
6+
"label": "firewall123",
7+
"rules": {
8+
"inbound": [
9+
{
10+
"action": "ACCEPT",
11+
"addresses": {
12+
"ipv4": [
13+
"192.0.2.0/24"
14+
],
15+
"ipv6": [
16+
"2001:DB8::/32"
17+
]
18+
},
19+
"description": "An example firewall rule description.",
20+
"label": "firewallrule123",
21+
"ports": "22-24, 80, 443",
22+
"protocol": "TCP"
23+
}
24+
],
25+
"inbound_policy": "DROP",
26+
"outbound": [
27+
{
28+
"action": "ACCEPT",
29+
"addresses": {
30+
"ipv4": [
31+
"192.0.2.0/24"
32+
],
33+
"ipv6": [
34+
"2001:DB8::/32"
35+
]
36+
},
37+
"description": "An example firewall rule description.",
38+
"label": "firewallrule123",
39+
"ports": "22-24, 80, 443",
40+
"protocol": "TCP"
41+
}
42+
],
43+
"outbound_policy": "DROP"
44+
},
45+
"status": "enabled",
46+
"tags": [
47+
"example tag",
48+
"another example"
49+
],
50+
"updated": "2018-01-02T00:01:01"
51+
}
52+
],
53+
"page": 1,
54+
"pages": 1,
55+
"results": 1
56+
}

test/fixtures/tags_something.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"hypervisor": "kvm",
1111
"id": 123,
1212
"status": "running",
13-
"type": "g5-standard-1",
13+
"type": "g6-standard-1",
1414
"alerts": {
1515
"network_in": 5,
1616
"network_out": 5,

test/integration/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def run_long_tests():
5454
def create_linode(test_linode_client):
5555
client = test_linode_client
5656
available_regions = client.regions()
57-
chosen_region = available_regions[0]
57+
chosen_region = available_regions[4]
5858
timestamp = str(time.time_ns())
5959
label = "TestSDK-" + timestamp
6060

@@ -71,7 +71,7 @@ def create_linode(test_linode_client):
7171
def create_linode_for_pass_reset(test_linode_client):
7272
client = test_linode_client
7373
available_regions = client.regions()
74-
chosen_region = available_regions[0]
74+
chosen_region = available_regions[4]
7575
timestamp = str(time.time_ns())
7676
label = "TestSDK-" + timestamp
7777

@@ -155,7 +155,7 @@ def test_domain(test_linode_client):
155155
def test_volume(test_linode_client):
156156
client = test_linode_client
157157
timestamp = str(time.time_ns())
158-
region = client.regions()[0]
158+
region = client.regions()[4]
159159
label = "TestSDK-" + timestamp
160160

161161
volume = client.volume_create(label=label, region=region)
@@ -308,7 +308,7 @@ def create_vpc_with_subnet_and_linode(
308308
label = "TestSDK-" + timestamp
309309

310310
instance, password = test_linode_client.linode.instance_create(
311-
"g5-standard-4", vpc.region, image="linode/debian11", label=label
311+
"g6-standard-1", vpc.region, image="linode/debian11", label=label
312312
)
313313

314314
yield vpc, subnet, instance, password

0 commit comments

Comments
 (0)