[ovirt-users] python-sdk: attach disk snapshot to another virtual machine
Juan Hernandez
jhernand at redhat.com
Fri Jun 13 12:18:05 UTC 2014
On 06/13/2014 10:43 AM, Michael Ablassmeier wrote:
> hi guys,
>
> according to an commit in Oct. 2013 there was a patch added to the SDK
> which allows to attach an existing snapshot to a virtual machine:
>
> commit 72e67dd5406f3c193234697ce88d92dbe64759d7
> Author: Michael pasternak <mpastern at redhat.com>
> Date: Wed Oct 30 11:24:19 2013 +0200
> sdk: regenerate against the latest api
> [..]
> - added ability to attach a disk snapshot to the virtual machine
> [..]
>
> I think this may be related to the new backup API:
>
> http://www.ovirt.org/Features/Backup-Restore_API_Integration
>
> can anyone give me an pointer on how to this through the python-sdk? Or
> is there an example for this anywhere to be found? Thanks!
>
It should be something like this:
#!/usr/bin/python
import ovirtsdk.api
import ovirtsdk.xml
api = ovirtsdk.api.API(
url="https://fedora.example.com/ovirt-engine/api",
username="admin at internal",
password="****",
insecure=True,
debug=False
)
# Find the snapshot that contains the disk that we want to backup:
vm = api.vms.get("myvm")
snaps = vm.snapshots.list()
snap = None
for current in snaps:
if current.get_description() == "mysnap":
snap = current
# Find the disk that we want to backup:
disks = snap.disks.list()
disk = None
for current in disks:
if current.get_name() == "mydisk":
disk = current
# Find the backup appliance VM:
appliance = api.vms.get("backupvm")
# Attach the disk to the backup appliance:
appliance.disks.add(disk)
# Tell the backup appliance to perform the backup, connecting
# with SSH, or with any other way that the backup appliance
# supports.
# Bye:
api.disconnect()
With a similar script you can also disconnect the disk from the backup
appliance.
--
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.
More information about the Users
mailing list