CLOUDSTACK-6358: Missing patches in master for VMware
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/62e63a1b Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/62e63a1b Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/62e63a1b Branch: refs/heads/master Commit: 62e63a1bf7b9f3326523fd30278847f4dcf794a4 Parents: 09069fc Author: amoghvk <amogh.vase...@citrix.com> Authored: Mon Jun 9 17:06:26 2014 -0700 Committer: amoghvk <amogh.vase...@citrix.com> Committed: Mon Jul 14 16:54:10 2014 -0700 ---------------------------------------------------------------------- .../vmsnapshot/DefaultVMSnapshotStrategy.java | 12 +++++++++- .../com/cloud/hypervisor/guru/VMwareGuru.java | 11 +++++++++ .../vmware/resource/VmwareResource.java | 24 +++++++++++++++----- 3 files changed, 40 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/62e63a1b/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java ---------------------------------------------------------------------- diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java index 9154b34..c5c54df 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java @@ -138,7 +138,11 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion()); CreateVMSnapshotCommand ccmd = new CreateVMSnapshotCommand(userVm.getInstanceName(), target, volumeTOs, guestOS.getDisplayName(), userVm.getState()); - ccmd.setPlatformEmulator(guestOsMapping.getGuestOsName()); + if (guestOsMapping == null) { + ccmd.setPlatformEmulator(null); + } else { + ccmd.setPlatformEmulator(guestOsMapping.getGuestOsName()); + } ccmd.setWait(_wait); answer = (CreateVMSnapshotAnswer)agentMgr.send(hostId, ccmd); @@ -349,6 +353,12 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs, guestOS.getDisplayName()); HostVO host = hostDao.findById(hostId); GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion()); + RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs, guestOS.getDisplayName()); + if (guestOsMapping == null) { + revertToSnapshotCommand.setPlatformEmulator(null); + } else { + revertToSnapshotCommand.setPlatformEmulator(guestOsMapping.getGuestOsName()); + } RevertToVMSnapshotAnswer answer = (RevertToVMSnapshotAnswer)agentMgr.send(hostId, revertToSnapshotCommand); if (answer != null && answer.getResult()) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/62e63a1b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java index 77c45b2..08d12f2 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java @@ -81,11 +81,13 @@ import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; import com.cloud.secstorage.CommandExecLogDao; import com.cloud.secstorage.CommandExecLogVO; import com.cloud.storage.DataStoreRole; +import com.cloud.storage.GuestOSHypervisorVO; import com.cloud.storage.GuestOSVO; import com.cloud.storage.Storage; import com.cloud.storage.Volume; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.GuestOSDao; +import com.cloud.storage.dao.GuestOSHypervisorDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.template.VirtualMachineTemplate.BootloaderType; @@ -112,6 +114,8 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co @Inject private GuestOSDao _guestOsDao; @Inject + GuestOSHypervisorDao _guestOsHypervisorDao; + @Inject private HostDao _hostDao; @Inject private HostDetailsDao _hostDetailsDao; @@ -309,6 +313,13 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId()); to.setOs(guestOS.getDisplayName()); to.setHostName(vm.getHostName()); + HostVO host = _hostDao.findById(vm.getVirtualMachine().getHostId()); + GuestOSHypervisorVO guestOsMapping = _guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), getHypervisorType().toString(), host.getHypervisorVersion()); + if (guestOsMapping == null) { + to.setPlatformEmulator(null); + } else { + to.setPlatformEmulator(guestOsMapping.getGuestOsName()); + } return to; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/62e63a1b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 15eeb13..494cf66 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -38,6 +38,7 @@ import java.util.Random; import java.util.Set; import java.util.TimeZone; import java.util.UUID; + import javax.naming.ConfigurationException; import org.apache.log4j.Logger; @@ -238,7 +239,6 @@ import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost; import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary; import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostResourceSummary; import com.cloud.hypervisor.vmware.util.VmwareContext; -import com.cloud.hypervisor.vmware.util.VmwareGuestOsMapper; import com.cloud.hypervisor.vmware.util.VmwareHelper; import com.cloud.network.Networks; import com.cloud.network.Networks.BroadcastDomainType; @@ -1408,7 +1408,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa tearDownVm(vmMo); }else if (!hyperHost.createBlankVm(vmNameOnVcenter, vmInternalCSName, vmSpec.getCpus(), vmSpec.getMaxSpeed().intValue(), getReservedCpuMHZ(vmSpec), vmSpec.getLimitCpuUse(), (int)(vmSpec.getMaxRam() / (1024 * 1024)), getReservedMemoryMb(vmSpec), - translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value(), rootDiskDataStoreDetails.first(), false)) { + translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs(), vmSpec.getPlatformEmulator()).value(), rootDiskDataStoreDetails.first(), false)) { throw new Exception("Failed to create VM. vmName: " + vmInternalCSName); } } @@ -1432,7 +1432,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa } VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec(); - String guestOsId = translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value(); + String guestOsId = translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs(), vmSpec.getPlatformEmulator()).value(); VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int)(vmSpec.getMaxRam() / (1024 * 1024)), getReservedMemoryMb(vmSpec), @@ -4426,13 +4426,25 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa } } - private VirtualMachineGuestOsIdentifier translateGuestOsIdentifier(String cpuArchitecture, String cloudGuestOs) { + private VirtualMachineGuestOsIdentifier translateGuestOsIdentifier(String cpuArchitecture, String guestOs, String cloudGuestOs) { if (cpuArchitecture == null) { - s_logger.warn("CPU arch is not set, default to i386. guest os: " + cloudGuestOs); + s_logger.warn("CPU arch is not set, default to i386. guest os: " + guestOs); cpuArchitecture = "i386"; } - VirtualMachineGuestOsIdentifier identifier = VmwareGuestOsMapper.getGuestOsIdentifier(cloudGuestOs); + if(cloudGuestOs == null) { + s_logger.warn("Guest OS mapping name is not set for guest os: " + guestOs); + } + + VirtualMachineGuestOsIdentifier identifier = null; + try { + if (cloudGuestOs != null) { + identifier = VirtualMachineGuestOsIdentifier.fromValue(cloudGuestOs); + s_logger.debug("Using mapping name : " + identifier.toString()); + } + } catch (IllegalArgumentException e) { + s_logger.warn("Unable to find Guest OS Identifier in VMware for mapping name: " + cloudGuestOs + ". Continuing with defaults."); + } if (identifier != null) { return identifier; }