new: Add support for Placement Groups - #396
Conversation
| from linode_api4.objects.region import Region | ||
|
|
||
|
|
||
| class PlacementAPIGroup(Group): |
There was a problem hiding this comment.
I'm not quite sure what to name this class given the convention here would be {route_name}Group, but that conflicts with PlacementGroup
There was a problem hiding this comment.
Otherwise I can think of PlacementsGroup, but I think the current naming PlacementAPIGroup is less confusing and probably the best way to go 👍
| return self._transfer | ||
|
|
||
| @property | ||
| def placement_group(self) -> Optional[PlacementGroup]: |
There was a problem hiding this comment.
Surely there's a way better way to do this, but for the time being we don't have a way to transform an arbitrary ID into an object like we can with derived classes & slugs.
|
|
||
|
|
||
| @dataclass | ||
| class PlacementGroupMember(JSONObject): |
There was a problem hiding this comment.
In the future it'd be nice to have a property method to access the underlying Linode object from here.
| return len(vars(self)) | ||
|
|
||
|
|
||
| class StrEnum(str, Enum): |
There was a problem hiding this comment.
Like the comment says, we can remove this in favor of the official StrEnum class once Python 3.11 is our minimum supported version 👍
|
Docs preview: https://linode-api4--396.org.readthedocs.build/en/396/ |
| from linode_api4.objects.region import Region | ||
|
|
||
|
|
||
| class PlacementAPIGroup(Group): |
There was a problem hiding this comment.
Otherwise I can think of PlacementsGroup, but I think the current naming PlacementAPIGroup is less confusing and probably the best way to go 👍
@yec-akamai Assuming you're running against Alpha it's probably an API issue. I'll look into it and let you know once it's been fixed 👍 edit: Just confirmed this is an API error |
yec-akamai
left a comment
There was a problem hiding this comment.
Works well on my end!
For some reason the test region eu-west doesn't work for me. It raised linode_api4.errors.ApiError: 403: The Linode plan you chose is not currently available in the selected region. Please select another region or plan type, or contact Support for assistance. But I switched to use other region, i.e. us-east, can work and pass the tests.
@yec-akamai Thanks for taking a second look! The eu-west issue is known internally so I switched over to us-east for the time being 👍 |
ykim-akamai
left a comment
There was a problem hiding this comment.
Apologies for taking long reviewing this, verified test and manual steps locally with changing region to 'us-east'. Excellent work!
📝 Description
This pull request adds support for the upcoming Placement Groups feature, including the following changes:
New Endpoints:
placement/groupsplacement/groupsplacement/groups/{pg_id}placement/groups/{pg_id}placement/groups/{pg_id}/assignplacement/groups/{pg_id}/unassignplacement/groups/{pg_id}Updated Endpoints:
/linode/instances&/linode/instances/{linode_id}- Updated to include PG info/linode/instances- Updated to accept a PG to assign the Linode to on creation/linode/instances/{linode_id}/migrate- Updated to accept a PG to assign the Linode to on creation/linode/instances/{linode_id}/clone- Updated to accept a PG to assign the Linode to on creation/regions&/regions/{region_id}- Updated to include PG limitsThis pull request also contains the corresponding unit and integration tests.
✔️ How to Test
The following test steps assume you have pulled down this PR locally and run
make install.Additionally, these tests will not currently run against production so the target API URL will need to be overridden.
e.g.
Unit Testing
Integration Testing
Manual Testing
linode_api4sandbox environment (e.g. dx-devenv), run the following: