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

Release v5.12.0 #368

Merged
merged 8 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions .github/workflows/e2e-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ inputs.sha }}
fetch-depth: 0
submodules: 'recursive'

- name: Get the hash value of the latest commit from the PR branch
uses: octokit/[email protected]
Expand Down Expand Up @@ -94,7 +96,7 @@ jobs:
- name: Add additional information to XML report
run: |
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
python test/script/add_to_xml_test_report.py \
python tod_scripts/add_to_xml_test_report.py \
--branch_name "${GITHUB_REF#refs/*/}" \
--gha_run_id "$GITHUB_RUN_ID" \
--gha_run_number "$GITHUB_RUN_NUMBER" \
Expand All @@ -103,7 +105,7 @@ jobs:
- name: Upload test results
run: |
report_filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
python3 test/script/test_report_upload_script.py "${report_filename}"
python3 tod_scripts/test_report_upload_script.py "${report_filename}"
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tod_scripts"]
path = tod_scripts
url = https://github.com/linode/TOD-test-report-uploader.git
34 changes: 31 additions & 3 deletions linode_api4/objects/linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,10 @@ def _populate(self, json):
"""
Allows changing the name "class" in JSON to "type_class" in python
"""

super()._populate(json)

if "class" in json:
if json is not None and "class" in json:
setattr(self, "type_class", json["class"])
else:
setattr(self, "type_class", None)
Expand Down Expand Up @@ -612,6 +613,11 @@ def _interface_create(self, body: Dict[str, Any]) -> NetworkInterface:
return i


class MigrationType:
COLD = "cold"
WARM = "warm"


class Instance(Base):
"""
A Linode Instance.
Expand Down Expand Up @@ -948,7 +954,13 @@ def reboot(self):
return False
return True

def resize(self, new_type, allow_auto_disk_resize=True, **kwargs):
def resize(
self,
new_type,
allow_auto_disk_resize=True,
migration_type: MigrationType = MigrationType.COLD,
**kwargs,
):
"""
Resizes a Linode you have the read_write permission to a different Type. If any
actions are currently running or queued, those actions must be completed first
Expand All @@ -970,6 +982,10 @@ def resize(self, new_type, allow_auto_disk_resize=True, **kwargs):
data must fit within the smaller disk size. Defaults to true.
:type: allow_auto_disk_resize: bool

:param migration_type: Type of migration to be used when resizing a Linode.
Customers can choose between warm and cold, the default type is cold.
:type: migration_type: str

:returns: True if the operation was successful.
:rtype: bool
"""
Expand All @@ -979,6 +995,7 @@ def resize(self, new_type, allow_auto_disk_resize=True, **kwargs):
params = {
"type": new_type,
"allow_auto_disk_resize": allow_auto_disk_resize,
"migration_type": migration_type,
}
params.update(kwargs)

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

return True

def initiate_migration(self, region=None, upgrade=None):
def initiate_migration(
self,
region=None,
upgrade=None,
migration_type: MigrationType = MigrationType.COLD,
):
"""
Initiates a pending migration that is already scheduled for this Linode
Instance
Expand All @@ -1459,10 +1481,16 @@ def initiate_migration(self, region=None, upgrade=None):
region field does not allow upgrades, then the endpoint will return a 400 error
code and the migration will not be performed.
:type: upgrade: bool

:param migration_type: The type of migration that will be used for this Linode migration.
Customers can only use this param when activating a support-created migration.
Customers can choose between a cold and warm migration, cold is the default type.
:type: mirgation_type: str
"""
params = {
"region": region.id if issubclass(type(region), Base) else region,
"upgrade": upgrade,
"type": migration_type,
}

util.drop_null_keys(params)
Expand Down
7 changes: 5 additions & 2 deletions linode_api4/objects/lke.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ def _populate(self, json):
"""
Parse Nodes into more useful LKENodePoolNode objects
"""
if json != {}:
if json is not None and json != {}:
new_nodes = [
LKENodePoolNode(self._client, c) for c in json["nodes"]
LKENodePoolNode(self._client, c)
if not isinstance(c, dict)
else c
for c in json["nodes"]
]
json["nodes"] = new_nodes

Expand Down
20 changes: 19 additions & 1 deletion linode_api4/objects/nodebalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Property,
Region,
)
from linode_api4.objects.networking import IPAddress
from linode_api4.objects.networking import Firewall, IPAddress


class NodeBalancerNode(DerivedBase):
Expand Down Expand Up @@ -303,3 +303,21 @@ def statistics(self):
"Unexpected response generating stats!", json=result
)
return MappedObject(**result)

def firewalls(self):
"""
View Firewall information for Firewalls associated with this NodeBalancer.

API Documentation: https://www.linode.com/docs/api/nodebalancers/#nodebalancer-firewalls-list

:returns: A List of Firewalls of the Linode NodeBalancer.
:rtype: List[Firewall]
"""
result = self._client.get(
"{}/firewalls".format(NodeBalancer.api_endpoint), model=self
)

return [
Firewall(self._client, firewall["id"])
for firewall in result["data"]
]
2 changes: 1 addition & 1 deletion test/fixtures/linode_instances.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"hypervisor": "kvm",
"id": 123,
"status": "running",
"type": "g5-standard-1",
"type": "g6-standard-1",
"alerts": {
"network_in": 5,
"network_out": 5,
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/linode_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"network_out": 1000,
"vcpus": 1,
"gpus": 0,
"id": "g5-nanode-1",
"id": "g6-nanode-1",
"label": "Linode 1024",
"price": {
"hourly": 0.0075,
Expand Down Expand Up @@ -127,7 +127,7 @@
"network_out": 1000,
"vcpus": 1,
"gpus": 0,
"id": "g5-standard-1",
"id": "g6-standard-1",
"label": "Linode 2048",
"price": {
"hourly": 0.015,
Expand Down Expand Up @@ -175,7 +175,7 @@
"network_out": 1000,
"vcpus": 2,
"gpus": 1,
"id": "g5-gpu-2",
"id": "g6-gpu-2",
"label": "Linode 4096",
"price": {
"hourly": 0.03,
Expand Down
48 changes: 48 additions & 0 deletions test/fixtures/linode_types_g6-nanode-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"disk": 20480,
"memory": 1024,
"transfer": 1000,
"addons": {
"backups": {
"price": {
"hourly": 0.003,
"monthly": 2
},
"region_prices": [
{
"id": "ap-west",
"hourly": 0.02,
"monthly": 20
},
{
"id": "ap-northeast",
"hourly": 0.02,
"monthly": 20
}
]
}
},
"class": "nanode",
"network_out": 1000,
"vcpus": 1,
"gpus": 0,
"id": "g5-nanode-1",
"label": "Linode 1024",
"price": {
"hourly": 0.0075,
"monthly": 5
},
"region_prices": [
{
"id": "us-east",
"hourly": 0.02,
"monthly": 20
},
{
"id": "ap-northeast",
"hourly": 0.02,
"monthly": 20
}
],
"successor": null
}
56 changes: 56 additions & 0 deletions test/fixtures/nodebalancers_12345_firewalls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"data": [
{
"created": "2018-01-01T00:01:01",
"id": 123,
"label": "firewall123",
"rules": {
"inbound": [
{
"action": "ACCEPT",
"addresses": {
"ipv4": [
"192.0.2.0/24"
],
"ipv6": [
"2001:DB8::/32"
]
},
"description": "An example firewall rule description.",
"label": "firewallrule123",
"ports": "22-24, 80, 443",
"protocol": "TCP"
}
],
"inbound_policy": "DROP",
"outbound": [
{
"action": "ACCEPT",
"addresses": {
"ipv4": [
"192.0.2.0/24"
],
"ipv6": [
"2001:DB8::/32"
]
},
"description": "An example firewall rule description.",
"label": "firewallrule123",
"ports": "22-24, 80, 443",
"protocol": "TCP"
}
],
"outbound_policy": "DROP"
},
"status": "enabled",
"tags": [
"example tag",
"another example"
],
"updated": "2018-01-02T00:01:01"
}
],
"page": 1,
"pages": 1,
"results": 1
}
2 changes: 1 addition & 1 deletion test/fixtures/tags_something.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"hypervisor": "kvm",
"id": 123,
"status": "running",
"type": "g5-standard-1",
"type": "g6-standard-1",
"alerts": {
"network_in": 5,
"network_out": 5,
Expand Down
8 changes: 4 additions & 4 deletions test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def run_long_tests():
def create_linode(test_linode_client):
client = test_linode_client
available_regions = client.regions()
chosen_region = available_regions[0]
chosen_region = available_regions[4]
timestamp = str(time.time_ns())
label = "TestSDK-" + timestamp

Expand All @@ -71,7 +71,7 @@ def create_linode(test_linode_client):
def create_linode_for_pass_reset(test_linode_client):
client = test_linode_client
available_regions = client.regions()
chosen_region = available_regions[0]
chosen_region = available_regions[4]
timestamp = str(time.time_ns())
label = "TestSDK-" + timestamp

Expand Down Expand Up @@ -155,7 +155,7 @@ def test_domain(test_linode_client):
def test_volume(test_linode_client):
client = test_linode_client
timestamp = str(time.time_ns())
region = client.regions()[0]
region = client.regions()[4]
label = "TestSDK-" + timestamp

volume = client.volume_create(label=label, region=region)
Expand Down Expand Up @@ -308,7 +308,7 @@ def create_vpc_with_subnet_and_linode(
label = "TestSDK-" + timestamp

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

yield vpc, subnet, instance, password
Expand Down
Loading
Loading