[ovirt-users] Python: Clone snapshot into VM

gregor gregor_forum at catrix.at
Sat Sep 19 19:59:26 UTC 2015


Hi,

a new version is available on github which supports a list of VM's in
the config.

https://github.com/wefixit-AT/oVirtBackup

cheers
gregor

On 2015-09-18 07:50, Karli Sjöberg wrote:
> tor 2015-09-17 klockan 21:24 +0200 skrev gregor:
>> Hi,
>>
>> thanks, the tool is ready and online on github.
> 
> Looks really cool. Good job! What do you think of making the backing up
> into a loop and fetching VMs from a list? My thinking is that you
> usually have more than one VM you´d want to back up, so something like
> this maybe:
> 
> def getVMsFromList(VMS_LIST):
>     try:
>         print 'Getting list of VMs from file \"%s\".' % (VMS_LIST)
>         fo = open(VMS_LIST)
>         output = []
>         for line in fo:
>             strippedline = line.strip('\r\n')
>             output.append(strippedline)
>         fo.close()
>         return output
>     except Exception as e:
>         print 'Exception in getting list of VMs:\n%s' % str(e)
>         exit(1)
> 
> And then you can loop:
> for LIST_VM_NAME in getVMsFromList('VMs.list'):
>     ....
> 
> Or to have the list of VMs in the config and then:
> config = Config(config_file, debug)
> VMS_LIST = vms_list
> for LIST_VM_NAME in getVMsFromList(VMS_LIST):
>     ....
> 
> /K
> 
>>
>> https://github.com/wefixit-AT/oVirtBackup
>>
>> cheers
>> gregor
>>
>> On 2015-09-16 15:11, Amador Pahim wrote:
>>> On 09/15/2015 11:57 AM, gregor wrote:
>>>> Hi,
>>>>
>>>> I write currently a little backup tool in Python which use the following
>>>> workflow:
>>>> - create a snapshot -> works
>>>> - clone snapshot into VM -> help needed
>>>
>>> snapshot =
>>> params.Snapshot(id=api.vms.get('my_vm01').snapshots.list(description='my_vm_snap_01')[0].id)
>>>
>>>
>>> snapshots = params.Snapshots(snapshot=[snapshot])
>>>
>>> api.vms.add(params.VM(name='new_vm', memory=2524971008,
>>> cluster=api.clusters.get("Default"), snapshots=snapshots))
>>>
>>>> - delete the snapshot -> works
>>>> - export VM to NFS share -> works
>>>> - delete cloned VM -> TODO
>>>>
>>>> Is it possible to clone a snapshot into a VM like from the web-interface?
>>>>
>>>> The above workflow is a little bit resource expensive but it will when
>>>> it is finished make Online-Full-backups of VM's.
>>>>
>>>> cheers
>>>> gregor
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at ovirt.org
>>>> http://lists.ovirt.org/mailman/listinfo/users
>>>
>> _______________________________________________
>> Users mailing list
>> Users at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/users
> 



More information about the Users mailing list