Fix reinstall VM bug

This commit is contained in:
nvazquez 2020-10-20 03:00:21 -03:00
parent 50ab1b2fbe
commit 67794aba23
2 changed files with 6 additions and 4 deletions

View File

@ -31,7 +31,7 @@ public class DeployAsIsInfoTO {
@LogLevel(LogLevel.Log4jLevel.Off)
private Map<String, String> properties = new HashMap<>();
private Map<Integer, String> nicAdapterMap = new HashMap();
boolean replaceVm;
private boolean replaceVm;
public DeployAsIsInfoTO() {
}

View File

@ -1771,12 +1771,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
auxVM.destroy();
String vmNameInVcenter = virtualMachineMO.getName();
virtualMachineMO.tearDownDevices(new Class<?>[]{VirtualDisk.class});
s_logger.info("Changing VM datastore to " + dsMo);
virtualMachineMO.changeDatastore(morDatastore);
for (String vmdkFileBaseName : vmdkFileBaseNames) {
String newPath = null;
if (dsMo.folderExists(String.format("[%s]", dsMo.getName()), vmNameInVcenter)) {
newPath = VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmNameInVcenter, dsMo, vmdkFileBaseName, null);
String newPath = VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmNameInVcenter, dsMo, vmdkFileBaseName, null);
s_logger.info("Attaching disk to restored VM at: " + newPath + " on datastore: " + destDatastore);
virtualMachineMO.attachDisk(new String[] {newPath}, morDatastore);
}
virtualMachineMO.attachDisk(new String[] {newPath}, morDatastore);
}
}