[ovirt-users] Unable to Delete a VM snapshot .

Juan Hernández jhernand at redhat.com
Wed May 13 08:35:56 UTC 2015


On 05/11/2015 02:12 PM, Kumar R, Prashanth (Prashanth) wrote:
> Hi All,
> 
>  
> 
> I am facing issue in deleting a VM snapshot.
> 
> I am using ovirt-engine-sdk-java-3.5.0.5.jar
> 
>  
> 
>  
> 
> According to the SDK API,I can delete a VM using :
> 
> api.getVMs().get(vmName).getSnapshots().getById(snapshotId).delete();
> 
>  
> 
> But there is no way to fetch the snapshot ID of a particular snapshot.
> 

Why not?

  List<VMSnapshot> snapshots = vm.getSnapshots().list();
  for (VMSnapshot snapshot : snapshots) {
    System.out.println(snapshot.getId());
  }

>  
> 
> Or
> 
>  
> 
> List<VMSnapshot> vmSnapshots =
> api.getVMs().get(vmName).getSnapshots().list();
> 
>      *for*(VMSnapshot vmSnapshot : vmSnapshots) {
> 
>       *if*(vmSnapshot.getDescription() == _snapshotdescription_){
> 
>          vmSnapshot.delete();
> 
>       }
> 
>  
> 
> I cannot use the above snippet of code to delete a snapshot,but the
> multiple snapshots for a vm can be created with the same description.
> 
>  
> 
>  
> 
> So is there a way to create a snapshot with a snapshot name assigned to it.
> 
> SO that delete,restore opeartions can be performed based on the snapshot
> name .
> 
>  
> 
> Thanks,
> 
> Prashanth R
> 

What you can't do, if understand correctly, is assign your own unique
symbolic name to a snapshot, like you do with the VM "name" attribute,
for example. That is a limitation of the engine, snapshots don't have a
"name" attribute.

Currently your only chance is to use the "description" attribute, but as
you said there is no guarantee that it will be unique.

Note that this happens with the Java SDK, with the Python SDK or with
any other client.

-- 
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