On 10/22/2015 07:50 AM, Indunil Jayasooriya wrote:
> Hi list,
> 
> I want to *schedule a VM backup* in ovirt 3.5. I read below
> URL.<http://resources.ovirt.org/pub/yum-repo/ovirt-release35.rpm>
> 
> http://www.ovirt.org/Features/Backup-Restore_API_Integration#Full_VM_Backups
> 
> It gives an below example of VM backup
> 
> 
>         Example for VM Backup
> 
>   * Use existing VM Snapshot/Create a vm snapshot (example): 
> 
>  URL = SERVER:PORT/api/vms/VM_ID/snapshots
>  Method = POST
>  (with Content-Type:application/xml header)
>  Body =
>  <snapshot>
>  <description>Virtual Machine 1 - Snapshot For Backup</description>
>  </snapshot>
> 
> 
> 
> But, How can I find the *VM_ID* of the VM that I want to backup?
> 
> How can I write this below format?
> 
>  URL = SERVER:PORT/api/vms/VM_ID/snapshots
> 
> MY Ovirt Engine manager is running on another PC. (let's say 
> engine.example.com <http://engine.example.com> ) i can access it by typing 
> https://engine.example.com/
> 
> is it https://engine.example.com/api/vms/*VM_ID*/snapshots ? I can't access 
> it in firefox browser?
> 
> 
> Should I write a script? is there any Youtube video or doc that makes me to 
> understand this? 
> 
> Hope to hear from you.
> 

If you know the name of the VM then you can find it, including its id,
doing a search:

https://engine.example.com/ovirt-engine/api/vms?search=name%3Dmyvm

If you prefer to use a script, which is probably the right thing, then
you can do something like this, using the Python SDK:

---8<---
#!/usr/bin/python

from ovirtsdk.api import API
from ovirtsdk.xml import params

# Connect to the server:
api = API(
    url="https://engine.example.com/ovirt-engine/api";,
    username="admin@internal",
    password="******",
    ca_file="/etc/pki/ovirt-engine/ca.pem",
    debug=False
)

# Find the VM:
vm = api.vms.get(name="myvm")

# Print the id:
print(vm.get_id())

# Disconnect:
api.disconnect()
--->8---

Once you have the VM you can create a snapshot like this:

---8<---
vm.snapshots.add(
    params.Snapshot(description="My snapshot")
)
--->8---

You can also use the Java SDK, if you prefer Java.

-- 
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
_______________________________________________
Users mailing list
Users@ovirt.org
http://lists.ovirt.org/mailman/listinfo/users

Reply via email to