feat(inventory): add polymorphic host classes#87
Draft
Laure-di wants to merge 18 commits intoscaleway:mainfrom
Draft
feat(inventory): add polymorphic host classes#87Laure-di wants to merge 18 commits intoscaleway:mainfrom
Laure-di wants to merge 18 commits intoscaleway:mainfrom
Conversation
Gnoale
reviewed
Oct 3, 2025
Contributor
Gnoale
left a comment
There was a problem hiding this comment.
Nice to see some abstraction, I think it should be a bit simplified though, you can try to split the main class in smaller unit of work, and you should add a few tests to make sure everything works as expected...
plugins/inventory/scaleway.py
Outdated
| @dataclass | ||
| class _ElasticMetalHost(_Host): | ||
| def populate_network(self, server: "BaremetalServer", client: "Client") -> None: | ||
| for ip in server.ips or []: |
Contributor
There was a problem hiding this comment.
easier to read/understand
if server.ips is None:
return
for ips in server.ips
...
| ips: list[IP] = [ | ||
| ip | ||
| for pn in private_networks_id | ||
| for ip in ipam_api.list_i_ps_all(resource_id=pn.id, attached=True) |
Contributor
There was a problem hiding this comment.
| # If the hostname attribute is a list, create a host for each element | ||
| hostnames = hostname_value if isinstance(hostname_value, list) else [hostname_value] | ||
|
|
||
| for idx, hostname in enumerate(hostnames): |
Contributor
There was a problem hiding this comment.
you should probably add a few tests and maybe split the class it seems a bit large no ?
4474481 to
696f708
Compare
696f708 to
c0e44e8
Compare
6fb11fd to
8a3eaaf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
How to test:
ansible-galaxy collection install . --forceansible-inventory -i inventory.scw.yml --yaml --list