-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Get interfaces for Proxmox LXC containers #8713
Get interfaces for Proxmox LXC containers #8713
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I've added some first comments.
try: | ||
ret = self._get_json("%s/api2/json/nodes/%s/lxc/%s/interfaces" % (self.proxmox_url, node, vmid)) | ||
except Exception: | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply ignoring all errors seems wrong to me. For which reasons can this call fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this to avoid introducing a breaking change, since this particular API is somewhat new (introduced in proxmox 8.1).
Maybe a version check makes more sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A version check would probably be best.
Otherwise you need to distinguish between "API doesn't support this" (can be ignored) and "other kind of error" (needs to be reported).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixfontein I've made some small changes.
- Requests for a container that are not running will return null, so there is an explicit check for the status fact.
- From my tests and a bit of reading, previous versions of the API will return 501 for requests to unknown endpoint. I verified this behavior with a server running version 7.
Adding an explicit version check can be done, but is more complicated. How many versions back does this plugin need to support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding an explicit version check can be done, but is more complicated.
Checking for 501 sounds good to me.
How many versions back does this plugin need to support?
I cannot find anything in the documenation, so basically "all versions the plugin worked with so far".
Co-authored-by: Felix Fontein <[email protected]>
Please note that the unit tests are currently failing. |
This comment was marked as outdated.
This comment was marked as outdated.
@felixfontein Unit test failure has been addressed |
If nobody objects, I'll merge this tomorrow for the next release. |
Backport to stable-9: 💚 backport PR created✅ Backport PR branch: Backported as #8750 🤖 @patchback |
* Get interfaces for Proxmox LXC containers * Add changelog * Don't use bare except * Update changelog from suggestion Co-authored-by: Felix Fontein <[email protected]> * Only lookup interfaces for running containers * Ignore not implemented status * Check that key exists in properties dict * define ignore errors in mock * Use not in --------- Co-authored-by: Felix Fontein <[email protected]> (cherry picked from commit 0f59bb7)
@scottlangendyk thanks for your contribution! |
… containers (#8750) Get interfaces for Proxmox LXC containers (#8713) * Get interfaces for Proxmox LXC containers * Add changelog * Don't use bare except * Update changelog from suggestion Co-authored-by: Felix Fontein <[email protected]> * Only lookup interfaces for running containers * Ignore not implemented status * Check that key exists in properties dict * define ignore errors in mock * Use not in --------- Co-authored-by: Felix Fontein <[email protected]> (cherry picked from commit 0f59bb7) Co-authored-by: Scott Langendyk <[email protected]>
* Get interfaces for Proxmox LXC containers * Add changelog * Don't use bare except * Update changelog from suggestion Co-authored-by: Felix Fontein <[email protected]> * Only lookup interfaces for running containers * Ignore not implemented status * Check that key exists in properties dict * define ignore errors in mock * Use not in --------- Co-authored-by: Felix Fontein <[email protected]>
* Get interfaces for Proxmox LXC containers * Add changelog * Don't use bare except * Update changelog from suggestion Co-authored-by: Felix Fontein <[email protected]> * Only lookup interfaces for running containers * Ignore not implemented status * Check that key exists in properties dict * define ignore errors in mock * Use not in --------- Co-authored-by: Felix Fontein <[email protected]>
SUMMARY
ISSUE TYPE
COMPONENT NAME
proxmox
ADDITIONAL INFORMATION
Useful for setting the ansible_host variable for lxc containers interfaces using dhcp.
Fact example: