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

Get interfaces for Proxmox LXC containers #8713

Merged
merged 9 commits into from
Aug 12, 2024

Conversation

scottlangendyk
Copy link
Contributor

@scottlangendyk scottlangendyk commented Aug 4, 2024

SUMMARY
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

proxmox

ADDITIONAL INFORMATION

Useful for setting the ansible_host variable for lxc containers interfaces using dhcp.

Fact example:

"proxmox_lxc_interfaces": [
    {
        "hwaddr": "00:00:00:00:00:00",
        "inet": "127.0.0.1/8",
        "inet6": "::1/128",
        "name": "lo"
    },
    {
        "hwaddr": "00:00:5e:00:53:a1",
        "inet": "192.0.2.12/24",
        "inet6": "2001:db8:3c4d:0015:0000:0000:1a2f:1a2b/48",
        "name": "eth0"
    }
]

@ansibullbot

This comment was marked as outdated.

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added ci_verified Push fixes to PR branch to re-run CI feature This issue/PR relates to a feature request inventory inventory plugin needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_contributor Help guide this first time contributor plugins plugin (any type) labels Aug 4, 2024
@ansibullbot ansibullbot removed ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Aug 4, 2024
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-9 Automatically create a backport for the stable-9 branch labels Aug 5, 2024
Copy link
Collaborator

@felixfontein felixfontein left a 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.

changelogs/fragments/8713-proxmox_lxc_interfaces.yml Outdated Show resolved Hide resolved
try:
ret = self._get_json("%s/api2/json/nodes/%s/lxc/%s/interfaces" % (self.proxmox_url, node, vmid))
except Exception:
return
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

Copy link
Collaborator

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).

Copy link
Contributor Author

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.

  1. Requests for a container that are not running will return null, so there is an explicit check for the status fact.
  2. 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?

Copy link
Collaborator

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".

@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Aug 10, 2024
@felixfontein
Copy link
Collaborator

Please note that the unit tests are currently failing.

@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added tests tests unit tests/unit labels Aug 11, 2024
@scottlangendyk
Copy link
Contributor Author

@felixfontein Unit test failure has been addressed

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Aug 11, 2024
@felixfontein
Copy link
Collaborator

If nobody objects, I'll merge this tomorrow for the next release.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Aug 12, 2024
@felixfontein felixfontein merged commit 0f59bb7 into ansible-collections:main Aug 12, 2024
147 checks passed
Copy link

patchback bot commented Aug 12, 2024

Backport to stable-9: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-9/0f59bb7a99258be7f885f8f77e5fcf1de8a0b0e5/pr-8713

Backported as #8750

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Aug 12, 2024
* 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)
@felixfontein
Copy link
Collaborator

@scottlangendyk thanks for your contribution!

felixfontein pushed a commit that referenced this pull request Aug 12, 2024
… 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]>
aioue pushed a commit to aioue/community.general that referenced this pull request Oct 1, 2024
* 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]>
TobiasZeuch181 pushed a commit to TobiasZeuch181/zypper_repository_add_list that referenced this pull request Oct 2, 2024
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-9 Automatically create a backport for the stable-9 branch feature This issue/PR relates to a feature request inventory inventory plugin new_contributor Help guide this first time contributor plugins plugin (any type) tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants