Unable to Delete a VM snapshot .

--_000_04352BA62627804FA4254F7542A9CF375C77E45BAZFFEXMB04globa_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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. Or List<VMSnapshot> vmSnapshots =3D api.getVMs().get(vmName).getSnapshots().li= st(); for (VMSnapshot vmSnapshot : vmSnapshots) { if(vmSnapshot.getDescription() =3D=3D snapshotdescription){ vmSnapshot.delete(); } I cannot use the above snippet of code to delete a snapshot,but the multipl= e 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 na= me . Thanks, Prashanth R --_000_04352BA62627804FA4254F7542A9CF375C77E45BAZFFEXMB04globa_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr= osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:= //www.w3.org/TR/REC-html40"> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
<meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)"> <style><!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:Consolas; panose-1:2 11 6 9 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-compose; font-family:"Calibri","sans-serif"; color:windowtext;} .MsoChpDefault {mso-style-type:export-only;} @page WordSection1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--> </head> <body lang=3D"EN-US" link=3D"blue" vlink=3D"purple"> <div class=3D"WordSection1"> <p class=3D"MsoNormal">Hi All,<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">I am facing issue in deleting a VM snapshot.<o:p></o= :p></p> <p class=3D"MsoNormal">I am using ovirt-engine-sdk-java-3.5.0.5.jar <o:p></= o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">According to the SDK API,I can delete a VM using :<o= :p></o:p></p> <p class=3D"MsoNormal">api.getVMs().get(vmName).getSnapshots().getById(snap= shotId).delete();<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">But there is no way to fetch the snapshot ID of a pa= rticular snapshot.<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal" style=3D"text-autospace:none">Or <o:p></o:p></p> <p class=3D"MsoNormal" style=3D"text-autospace:none"><o:p> </o:p></p> <p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si= ze:10.0pt;font-family:Consolas;color:black">List<VMSnapshot> vmSnapsh= ots =3D api.getVMs().get(vmName).getSnapshots().list();</span><span style= =3D"font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p> <p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si= ze:10.0pt;font-family:Consolas;color:black"> </span><b><span style=3D"font-size:10.0pt;font-family:Consolas;color:#7F005= 5">for</span></b><span style=3D"font-size:10.0pt;font-family:Consolas;color= :black"> (VMSnapshot vmSnapshot : vmSnapshots) {</span><span style=3D"font-= size:10.0pt;font-family:Consolas"><o:p></o:p></span></p> <p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si= ze:10.0pt;font-family:Consolas;color:black"> </span><b><span style=3D"font-size:10.0pt;font-family:Consolas;color:#7F005= 5">if</span></b><span style=3D"font-size:10.0pt;font-family:Consolas;color:= black">(vmSnapshot.getDescription() =3D=3D <u>snapshotdescription</u>){</span><span style=3D"font-size:10.0pt;font-fam= ily:Consolas"><o:p></o:p></span></p> <p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si= ze:10.0pt;font-family:Consolas;color:black"> &= nbsp; vmSnapshot.delete();</span><span style=3D"font-size:10.0p= t;font-family:Consolas"><o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas= ;color:black"> }</span><o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">I cannot use the above snippet of code to delete a s= napshot,but the multiple snapshots for a vm can be created with the same de= scription.<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">So is there a way to create a snapshot with a snapsh= ot name assigned to it.<o:p></o:p></p> <p class=3D"MsoNormal">SO that delete,restore opeartions can be performed b= ased on the snapshot name .<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> <p class=3D"MsoNormal">Thanks,<o:p></o:p></p> <p class=3D"MsoNormal">Prashanth R<o:p></o:p></p> <p class=3D"MsoNormal"><o:p> </o:p></p> </div> </body> </html> --_000_04352BA62627804FA4254F7542A9CF375C77E45BAZFFEXMB04globa_--

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.
participants (2)
-
Juan Hernández
-
Kumar R, Prashanth (Prashanth)