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

New inventory module: Proxmox #545

Merged
merged 37 commits into from
Aug 21, 2020
Merged

New inventory module: Proxmox #545

merged 37 commits into from
Aug 21, 2020

Conversation

Thulium-Drake
Copy link
Contributor

SUMMARY

Proxmox inventory module: based on the foreman/satellite plugin. I proposed this one earlier in ansible/ansible#59054

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

proxmox

@ansibullbot ansibullbot added affects_2.10 community_review inventory inventory plugin needs_triage new_contributor Help guide this first time contributor new_plugin New plugin plugins plugin (any type) labels Jun 20, 2020
@Thulium-Drake
Copy link
Contributor Author

bot_status

@ansibullbot
Copy link
Collaborator

Components

plugins/inventory/proxmox.py
support: core
maintainers:

Metadata

waiting_on: ansible
changes_requested_by: null
needs_info: False
needs_revision: False
needs_rebase: False
merge_commits: []
too many files or commits: False
mergeable_state: clean
shippable_status: success
maintainer_shipits (module maintainers): 0
community_shipits (namespace maintainers): 0
ansible_shipits (core team members): 0
shipit_actors (maintainer or core team member): []
shipit_actors_other: []
automerge: automerge shipit test failed

click here for bot help

@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Jun 29, 2020
@felixfontein felixfontein changed the base branch from master to main July 6, 2020 06:54
@ansibullbot ansibullbot removed the stale_ci CI is older than 7 days, rerun before merging label Jul 31, 2020
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.

You need to add tests (probably unit tests, to avoid setting up proxmox).

@Thulium-Drake
Copy link
Contributor Author

Thulium-Drake commented Aug 19, 2020

A lot of tinkering later... I seem to finally been able to make the module process mocked API replies to an inventory.

I also made some basic assertions, are these expansive enough?

@felixfontein
Copy link
Collaborator

How about instead only mocking _get_json, let it return preconfigured results based on the URL passed to it, and then checking whether the inventory has been filled with the correct values? Right now, you seem to be only testing a very small part of the code.

@Thulium-Drake
Copy link
Contributor Author

This should do it :-)

@felixfontein
Copy link
Collaborator

Looks good! (Except the version bump.)

@felixfontein
Copy link
Collaborator

Sorry, found a few details :)

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@felixfontein felixfontein merged commit 73be912 into ansible-collections:main Aug 21, 2020
@felixfontein
Copy link
Collaborator

@Thulium-Drake thanks a lot for contributing this!
@bmillemathias @Andersson007 thanks a lot for reviewing!

@Andersson007
Copy link
Contributor

@Thulium-Drake thanks for persistence and the contribution!:)

@Thulium-Drake
Copy link
Contributor Author

No problem, it were the first unit tests I ever wrote (so there was a lot of learning involved ;-) )

But hey, at the end of the day we all win :-)

patchback bot pushed a commit that referenced this pull request Sep 13, 2020
* This commit adds proxmox inventory module and proxmox_snap for snapshot management

* Fixed pylint errors

* Missed this one..

* This should fix the doc errors

* Remove proxmox_snap to allow for single module per PR

* Changes as suggested by felixfontein in #535

* Reverted back to AnsibleError as module.fail_json broke it. Need to investigate further

* Made importerror behave similar to docker_swarm and gitlab_runner

* FALSE != False

* Added myself as author

* Added a requested feature from a colleague to also sort VMs based on their running state

* Prevent VM templates from being added to the inventory

* Processed feedback

* Updated my email and included version

* Processed doc feedback

* More feedback processed

* Shortened this line of documentation, it is a duplicate and it was causing a sanity error (> 160 characters)

* Added test from PR #736 to check what needs to be changed to make it work

* Changed some tests around

* Remove some tests, first get these working

* Disabled all tests, except the one I am hacking together now

* Added mocker, still trying to figure this out

* Am I looking in the right direction?

* Processed docs feedback

* Fixed bot feedback

* Removed all other tests, started with basic ones (borrowed from cobbler)

* Removed all other tests, started with basic ones (borrowed from cobbler)

* Removed all other tests, started with basic ones (borrowed from cobbler)

* Removed init_cache test as it is implemented on a different way in the original foreman/satellite inventory (and thus also this one)

* This actually passes! Need to check if I need to add asserts as well

* Made bot happy again?

* Added some assertions

* Added note about PVE API version

* Mocked only get_json, the rest functions as-is

* Fixed sanity errors

* Fixed version bump (again...) ;-)

* Processed feedback

(cherry picked from commit 73be912)
felixfontein pushed a commit that referenced this pull request Sep 17, 2020
* This commit adds proxmox inventory module and proxmox_snap for snapshot management

* Fixed pylint errors

* Missed this one..

* This should fix the doc errors

* Remove proxmox_snap to allow for single module per PR

* Changes as suggested by felixfontein in #535

* Reverted back to AnsibleError as module.fail_json broke it. Need to investigate further

* Made importerror behave similar to docker_swarm and gitlab_runner

* FALSE != False

* Added myself as author

* Added a requested feature from a colleague to also sort VMs based on their running state

* Prevent VM templates from being added to the inventory

* Processed feedback

* Updated my email and included version

* Processed doc feedback

* More feedback processed

* Shortened this line of documentation, it is a duplicate and it was causing a sanity error (> 160 characters)

* Added test from PR #736 to check what needs to be changed to make it work

* Changed some tests around

* Remove some tests, first get these working

* Disabled all tests, except the one I am hacking together now

* Added mocker, still trying to figure this out

* Am I looking in the right direction?

* Processed docs feedback

* Fixed bot feedback

* Removed all other tests, started with basic ones (borrowed from cobbler)

* Removed all other tests, started with basic ones (borrowed from cobbler)

* Removed all other tests, started with basic ones (borrowed from cobbler)

* Removed init_cache test as it is implemented on a different way in the original foreman/satellite inventory (and thus also this one)

* This actually passes! Need to check if I need to add asserts as well

* Made bot happy again?

* Added some assertions

* Added note about PVE API version

* Mocked only get_json, the rest functions as-is

* Fixed sanity errors

* Fixed version bump (again...) ;-)

* Processed feedback

(cherry picked from commit 73be912)

Co-authored-by: Jeffrey van Pelt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_review inventory inventory plugin needs_triage new_contributor Help guide this first time contributor new_plugin New plugin plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants