@@ -161,7 +161,6 @@ public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd)
161
161
String workerVMName = null ;
162
162
String volumePath = cmd .getVolumePath ();
163
163
ManagedObjectReference morDs = null ;
164
- String snapshotUUID = null ;
165
164
DatastoreMO dsMo =null ;
166
165
167
166
// By default assume failure
@@ -203,16 +202,12 @@ public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd)
203
202
// attach volume to worker VM
204
203
String datastoreVolumePath = String .format ("[%s] %s.vmdk" , dsMo .getName (), volumePath );
205
204
vmMo .attachDisk (new String [] { datastoreVolumePath }, morDs );
206
- snapshotUUID = UUID .randomUUID ().toString ();
207
- if (!vmMo .createSnapshot (snapshotUUID , "Snapshot taken for " + cmd .getSnapshotName (), false , false )) {
208
- throw new Exception ("Failed to take snapshot " + cmd .getSnapshotName () + " on vm: " + cmd .getVmName ());
209
- }
210
- }
211
- } else {
212
- if (!vmMo .createSnapshot (snapshotUuid , "Snapshot taken for " + cmd .getSnapshotName (), false , false )) {
213
- throw new Exception ("Failed to take snapshot " + cmd .getSnapshotName () + " on vm: " + cmd .getVmName ());
214
- }
215
- }
205
+ }
206
+ }
207
+
208
+ if (!vmMo .createSnapshot (snapshotUuid , "Snapshot taken for " + cmd .getSnapshotName (), false , false )) {
209
+ throw new Exception ("Failed to take snapshot " + cmd .getSnapshotName () + " on vm: " + cmd .getVmName ());
210
+ }
216
211
217
212
snapshotBackupUuid = backupSnapshotToSecondaryStorage (vmMo , accountId , volumeId , cmd .getVolumePath (), snapshotUuid , secondaryStorageUrl , prevSnapshotUuid , prevBackupUuid ,
218
213
hostService .getWorkerName (context , cmd , 1 ));
0 commit comments