-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: New xen orchestra module #8470
base: main
Are you sure you want to change the base?
feat: New xen orchestra module #8470
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.
Please note https://github.com/ansible-collections/community.general/blob/main/CONTRIBUTING.md#creating-new-modules-or-plugins, which has some more information on what you need to add/to for new modules.
I've updated the code based on your comments, please note:
|
👍
If applied to the inventory plugin, yes, but there an alias can be added for the old name to keep compatibility.
There's Generally sharing similar/equal docs and code is a good idea, instead of simply copying. |
vm_uid = module.params['vm_uid'] | ||
|
||
if state == 'stopped': | ||
result = xen_orchestra.stop_vm(vm_uid) |
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.
Where are idempotency checks (is the VM already stopped)?
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.
See line 230, we set the task as changed=false
if the api returns an error saying the VM is not in a paused
, suspended
or running
state (meaning it's already stopped)
Update version from 9.1.0 to 9.2.0 Co-authored-by: Felix Fontein <[email protected]>
Hello, Any more updates required? @felixfontein |
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.
hi @shinuza
Thanks for your contribution. There are few things that need tending to, see comments below. Additionally, per the collection guidelines, you must also include tests (preferably integration tests, but if not, at least unit tests).
template: | ||
description: | ||
- UID of a template to create Virtual Machine from. | ||
- Muse be provided when O(state=present) |
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.
- Muse be provided when O(state=present) | |
- Must be provided when O(state=present). |
|
||
if state == 'present': | ||
result = xen_orchestra.create_vm() | ||
module.exit_json(changed=True, vm_uid=result) |
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.
If the VM is already present and no configuration changed, this should be False
for idempotency.
raise self.module.fail_json( | ||
'Could not delete vm: {0}'.format(answer['error'])) | ||
|
||
return answer['result'] |
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.
Is that a boolean value? Because it is being passed back to the user as changed
.
waited = 0 | ||
while waited < self.CALL_TIMEOUT: | ||
response = json.loads(self.conn.recv()) | ||
if 'id' in response and response['id'] == id: |
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.
This can be simplified to:
if 'id' in response and response['id'] == id: | |
if response.get('id') == id: |
vm_uid: | ||
description: | ||
- UID of the target Virtual Machine. Required when O(state=absent), O(state=started), O(state=stopped) or | ||
O(state=restarted) |
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.
O(state=restarted) | |
O(state=restarted). |
Ping @shinuza needs_info |
@shinuza This pullrequest is waiting for your response. Please respond or the pullrequest will be closed. |
SUMMARY
Added a xen_orchestra module to create/start/restart/stop/delete virtual machines
ISSUE TYPE
COMPONENT NAME
xen_orchestra