TPT-4324: Allow dict passthrough for config_create 'devices' field#673
TPT-4324: Allow dict passthrough for config_create 'devices' field#673lgarber-akamai wants to merge 1 commit intolinode:devfrom
Conversation
04d5132 to
d89e53c
Compare
There was a problem hiding this comment.
Pull request overview
Adds backwards-compatible support for passing a raw device mapping dict into Instance.config_create(..., devices=...), enabling explicit sdX key selection during config creation (needed for ansible_linode workflows around expanded volume limits).
Changes:
- Update
Instance.config_createto accept a raw device-map dict and to normalize/serialize device inputs more flexibly. - Add a unit test to ensure device-map dicts are passed through unchanged.
- Add an integration test validating config creation using an explicit device-map key.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
linode_api4/objects/linode.py |
Extends config_create input handling/typing to support device-map dict passthrough; also adjusts clone defaults/normalization. |
test/unit/objects/linode_test.py |
Adds unit coverage asserting raw device-map dict passthrough in config_create. |
test/integration/models/volume/test_blockstorage.py |
Adds integration coverage for creating a config using an explicit device-map key. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
linode_api4/objects/linode.py
Outdated
| ConfigCreateDevice = Union["Disk", "Volume", Dict[str, Any]] | ||
| ConfigCreateDisk = Union["Disk", int] | ||
| ConfigCreateVolume = Union["Volume", int] | ||
|
|
||
| # create derived objects | ||
| def config_create( | ||
| self, | ||
| kernel=None, | ||
| label=None, | ||
| devices=[], | ||
| disks=[], | ||
| volumes=[], | ||
| interfaces=[], | ||
| kernel: Optional[Union[Kernel, str]] = None, | ||
| label: Optional[str] = None, | ||
| devices: Optional[ | ||
| Union[ | ||
| ConfigCreateDevice, | ||
| List[ConfigCreateDevice], | ||
| Dict[str, Any], | ||
| ] | ||
| ] = None, |
There was a problem hiding this comment.
The new type aliases/annotation for devices are inconsistent with the runtime behavior: ConfigCreateDevice includes Dict[str, Any], and devices itself allows Dict[str, Any], but _build_devices() treats any dict as the full device-map passthrough (keys like sda, sdb). This makes it ambiguous for type-checkers/users and suggests supported inputs (a single device-entry dict or dicts inside the devices list) that the implementation doesn’t actually handle. Consider tightening the typing to distinguish a device-entry vs a device-map (e.g. Dict[str, ConfigCreateDeviceEntry]) and aligning the implementation/docs accordingly.
| else: | ||
| raise TypeError("Disk or Volume expected!") | ||
| if len(device_map) < 1: | ||
| raise ValueError("Must include at least one disk or volume!") |
| @@ -25,10 +25,11 @@ classifiers = [ | |||
| "License :: OSI Approved :: BSD License", | |||
| "Programming Language :: Python", | |||
| "Programming Language :: Python :: 3", | |||
| "Programming Language :: Python :: 3.9", | |||
| "Programming Language :: Python :: 3.10", | |||
| "Programming Language :: Python :: 3.11", | |||
| "Programming Language :: Python :: 3.12", | |||
| "Programming Language :: Python :: 3.13", | |||
| "Programming Language :: Python :: 3.14", | |||
| ] | |||
| dependencies = ["requests", "polling", "deprecated"] | |||
There was a problem hiding this comment.
Per our support policy, we stop supporting Python versions as soon as they EOL.
I can split this out into a separate PR if needed. Just wanted to use the fancy new type hint syntax.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
11bf63a to
c62fefb
Compare
c62fefb to
b406990
Compare
📝 Description
Adds backwards-compatible support for passing a raw device mapping dict to the devices parameter of
Instance.config_create(...), allowing callers to explicitly specify thesdXkey for a device during config creation.This resolves an issue in ansible_linode that is currently blocking the release of Block Storage Volume Limits Increase.
✔️ How to Test
Unit Testing
Integration Testing