cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [4/5] git commit: updated refs/heads/4.4 to c934e7b
Date Tue, 10 Jun 2014 11:39:59 GMT
CLOUDSTACK-6358: Remove hardcoded VMware mappings, handle snapshots

(cherry picked from commit a4b401f29f83f2f0b467a9d05b509f951b5a3bca)


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b490da25
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b490da25
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b490da25

Branch: refs/heads/4.4
Commit: b490da25ba574710000d128426fd7ad4b347f4be
Parents: 04665ee
Author: amoghvk <amogh.vasekar@citrix.com>
Authored: Mon Jun 9 17:06:26 2014 -0700
Committer: Daan Hoogland <daan@onecht.net>
Committed: Tue Jun 10 13:18:56 2014 +0200

----------------------------------------------------------------------
 .../vmsnapshot/DefaultVMSnapshotStrategy.java   | 12 ++++++++--
 .../com/cloud/hypervisor/guru/VMwareGuru.java   | 11 +++++++++
 .../vmware/resource/VmwareResource.java         | 24 +++++++++++++++-----
 3 files changed, 39 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b490da25/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 21f4968..bfc6d79 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
@@ -136,7 +136,11 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements
VMSnapshot
             HostVO host = hostDao.findById(hostId);
             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);
@@ -347,7 +351,11 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements
VMSnapshot
             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());
-            revertToSnapshotCommand.setPlatformEmulator(guestOsMapping.getGuestOsName());
+            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/b490da25/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/b490da25/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 46b1015..da83d18 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;
@@ -239,7 +240,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;
@@ -1395,7 +1395,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);
                     }
                 }
@@ -1419,7 +1419,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),
@@ -4520,13 +4520,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;
         }


Mime
View raw message