-
Notifications
You must be signed in to change notification settings - Fork 54
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
Upgrade to python-ovirt-engine-sdk4 #21
Comments
Any news? |
Work with oVirt 4.0? Thanks @wefixit-AT |
Hi, yes it works with oVirt 4.0 but not with the latest ovirt sdk4. I started working on it but it's not so easy because there are zero documentation and all information's have to gather from the python ovirt library or trough the engine java source. |
It works correctly, thanks for everything |
@wefixit-AT - there are many examples @ https://github.com/oVirt/ovirt-engine-sdk/tree/master/sdk/examples (and we'll add more). |
Hi, examples are good but a documentation is much better. It's hard for software engineers to learn by try and error or copy/paste from examples :-( |
Hi, I am opening discussion for this issue since I am willing to implement the support for the new api, though before starting to implement anything I would like some feedback. There are two main approaches that I can see right now: My first thought was that we should have both ovirt-engine-sdk-python packages installed on the system (although they have the same name it can be done by installing the packages with -I option in pip), and support both APIs in the same file. This should be done by importing the default module or if only one available, the existing module, and then having some common interface for the API calls that we need, which will map us to the right API function call. The other approach that we could follow, is completely separate the support for the new API into different branch, however this is not preferable in my opinion, since it will results it double effort to maintain the project. Please let me know your thoughts on these. |
Here are my thoughts on moving from SDK to SDK4:
|
Does anybody has ideas, or worked on moving to sdk4 or to ansible? |
I managed to make Ansible role with tasks like this: ---
# tasks file for ovbackup
- name: Backup VMs via oVirt engine
block:
- name: Return current time
local_action:
module: command
cmd: 'date +%Y%m%dT%H%M%S'
register: current_time
changed_when: false
- name: Obtain SSO token
local_action:
module: ovirt_auth
url: "{{ovirt_url}}"
username: "{{ovirt_user}}"
ca_file: "{{ovirt_ca}}"
password: "{{ovirt_pass}}"
run_once: True
- name: "Create snapshots of virtual machines"
local_action:
module: ovirt_snapshot
auth: "{{ovirt_auth}}"
vm_name: "{{vm_name}}"
description: "{{snapshot_name}}"
use_memory: false
timeout: 600
register: snapshot
- name: "Gather info for snapshots of virtual machines"
local_action:
module: ovirt_snapshot_info
auth: "{{ovirt_auth}}"
vm: "{{vm_name}}"
description: "{{snapshot_name}}"
register: result
- name: "Snapshots statuses"
debug:
msg: "{{snapshot_name}}: {{ result.ovirt_snapshots[0].snapshot_status }}"
- name: "Pause for 1 minute to settle down"
pause:
minutes: 1
- name: "Create clones of virtual machines"
local_action:
module: ovirt_vm
auth: "{{ovirt_auth}}"
snapshot_vm: "{{vm_name}}"
snapshot_name: "{{snapshot_name}}"
name: "{{vm_clone_name}}"
state: present
timeout: 3600
- name: "Delete snapshots of virtual machines"
local_action:
module: ovirt_snapshot
auth: "{{ovirt_auth}}"
vm_name: "{{vm_name}}"
state: absent
snapshot_id: "{{ snapshot.id }}"
timeout: 600
- name: "Export images of virtual machines"
local_action:
module: ovirt_vm
auth: "{{ovirt_auth}}"
name: "{{vm_clone_name}}"
state: exported
cluster: "{{cluster}}"
export_domain: "{{export_domain}}"
timeout: 3600
- name: "Remove clones of virtual machines"
local_action:
module: ovirt_vm
auth: "{{ovirt_auth}}"
state: absent
name: "{{vm_clone_name}}"
timeout: 600
always:
- name: Revoke the SSO token
local_action:
module: ovirt_auth
state: absent
ovirt_auth: "{{ovirt_auth}}" Unfortunately I couldn't find a way for housekeeping backups in export domain. |
Thanks I try it on my environment. |
Be aware, you need to reduce parallel tasks. I do this by setting serial = 2: ---
- hosts: backup_vms
gather_facts: no
serial: 2
roles:
- role: ovbackup
If you need, my defaults for role look like this: ---
# defaults file for ovbackup
ovirt_url: https://ovirt.engine.host/ovirt-engine/api
ovirt_ca: /path/to/ovirt/ca.crt
ovirt_user: ovirtuser@internal
ovirt_pass: ovirtpass
cluster: ovirt_cluster
snapshot_name: ovbackup_playbook
export_domain: export
vm_name: "{{ inventory_hostname | regex_replace('^([a-z0-9-]+)\\..*$', '\\1') }}"
vm_clone_name: "{{vm_name}}_BCK_{{current_time.stdout}}"
I think it would be quite neat solution if I manage somehow to delete old backups from export domain. |
Done with the latest pull request |
There are a lot of changes between oVirt 3.* and 4.*.
I have started working on this
The text was updated successfully, but these errors were encountered: