Skip to content

Commit 8d2a008

Browse files
author
Kelven Yang
committed
bug 14090: handle the case when command is sent to a different host that is not owner of the VM
1 parent eaf9d3d commit 8d2a008

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd)
161161
String workerVMName = null;
162162
String volumePath = cmd.getVolumePath();
163163
ManagedObjectReference morDs = null;
164-
String snapshotUUID = null;
165164
DatastoreMO dsMo=null;
166165

167166
// By default assume failure
@@ -203,16 +202,12 @@ public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd)
203202
// attach volume to worker VM
204203
String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
205204
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+
}
216211

217212
snapshotBackupUuid = backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
218213
hostService.getWorkerName(context, cmd, 1));

0 commit comments

Comments
 (0)