cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject git commit: updated refs/heads/4.2 to 059e4b2
Date Wed, 07 Aug 2013 17:29:37 GMT
Updated Branches:
  refs/heads/4.2 a9d8333c5 -> 059e4b2ae


CLOUDSTACK-3886: check in for review request https://reviews.apache.org/r/13008/


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

Branch: refs/heads/4.2
Commit: 059e4b2ae0a44205a8567a79bf9a154a54a83492
Parents: a9d8333
Author: Kelven Yang <kelveny@gmail.com>
Authored: Wed Aug 7 10:28:47 2013 -0700
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Wed Aug 7 10:29:18 2013 -0700

----------------------------------------------------------------------
 .../orchestration/CloudOrchestrator.java        |   3 +-
 .../com/cloud/hypervisor/guru/VMwareGuru.java   |   1 +
 .../vmware/manager/VmwareManagerImpl.java       |  10 ++
 .../manager/VmwareStorageManagerImpl.java       |   2 +-
 .../vmware/resource/VmwareResource.java         | 103 ++++++++++++++-----
 .../resource/VmwareStorageProcessor.java        |  67 +++++++-----
 server/src/com/cloud/configuration/Config.java  |   5 +-
 .../cloud/ha/HighAvailabilityManagerImpl.java   |  10 +-
 .../cloud/hypervisor/HypervisorGuruBase.java    |   1 -
 server/src/com/cloud/vm/UserVmManagerImpl.java  | 100 +++++++++---------
 .../com/cloud/vm/VirtualMachineManagerImpl.java |   5 +-
 setup/db/db/schema-410to420.sql                 |   2 +-
 .../cloud/hypervisor/vmware/mo/ClusterMO.java   |   4 +-
 .../vmware/mo/CustomFieldConstants.java         |   1 +
 .../com/cloud/hypervisor/vmware/mo/HostMO.java  |  98 +++++++++++++-----
 .../vmware/mo/HypervisorHostHelper.java         |  46 +++++++--
 .../hypervisor/vmware/mo/VirtualMachineMO.java  |   2 +-
 .../vmware/mo/VmwareHypervisorHost.java         |   2 +-
 18 files changed, 304 insertions(+), 158 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
index 96fb1d9..c46a461 100755
--- a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
@@ -229,7 +229,6 @@ public class CloudOrchestrator implements OrchestrationService {
     	//load vm instance and offerings and call virtualMachineManagerImpl
     	VMInstanceVO vm = _vmDao.findByUuid(id);
 
-
 		Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null, null);
 		ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
 		rootDiskOffering.first(offering);
@@ -266,7 +265,7 @@ public class CloudOrchestrator implements OrchestrationService {
 
 		HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
 
-    	if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null,	plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
+        if (_itMgr.allocate(_userVmDao.findById(vm.getId(), true), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType, _accountDao.findById(new Long(owner))) == null) {
 			return null;
 		}
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/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 292f7e9..8aae8c8 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
@@ -270,6 +270,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
         // Determine the VM's OS description
         GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId());
         to.setOs(guestOS.getDisplayName());
+        to.setHostName(vm.getHostName());
         return to;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index 8d6bdb8..b9afeaf 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -162,6 +162,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
     int _portsPerDvPortGroup = 256;
     boolean _nexusVSwitchActive;
     boolean _fullCloneFlag;
+    boolean _instanceNameFlag;
     String _serviceConsoleName;
     String _managemetPortGroupName;
     String _defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString();
@@ -232,6 +233,14 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
         } else {
             _fullCloneFlag = Boolean.parseBoolean(value);
         }
+
+        value = _configDao.getValue(Config.SetVmInternalNameUsingDisplayName.key());
+        if (value == null) {
+            _instanceNameFlag = false;
+        } else {
+            _instanceNameFlag = Boolean.parseBoolean(value);
+        }
+
         _portsPerDvPortGroup = NumbersUtil.parseInt(_configDao.getValue(Config.VmwarePortsPerDVPortGroup.key()), _portsPerDvPortGroup);
 
         _serviceConsoleName = _configDao.getValue(Config.VmwareServiceConsole.key());
@@ -506,6 +515,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
     @Override
     public void setupResourceStartupParams(Map<String, Object> params) {
         params.put("vmware.create.full.clone", _fullCloneFlag);
+        params.put("vm.instancename.flag", _instanceNameFlag);
         params.put("service.console.name", _serviceConsoleName);
         params.put("management.portgroup.name", _managemetPortGroupName);
         params.put("vmware.reserve.cpu", _reserveCpu);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
index 6b721de..d2408b3 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
@@ -332,7 +332,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
 						workerVMName = hostService.getWorkerName(context, cmd, 0);
 
 						// attach a volume to dummay wrapper VM for taking snapshot and exporting the VM for backup
-						if (!hyperHost.createBlankVm(workerVMName, 1, 512, 0, false, 4, 0, VirtualMachineGuestOsIdentifier.OTHER_GUEST.value(), morDs, false)) {
+						if (!hyperHost.createBlankVm(workerVMName, null, 1, 512, 0, false, 4, 0, VirtualMachineGuestOsIdentifier.OTHER_GUEST.value(), morDs, false)) {
 							String msg = "Unable to create worker VM to execute BackupSnapshotCommand";
 							s_logger.error(msg);
 							throw new Exception(msg);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/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 f4ed570..57747ab 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
@@ -361,6 +361,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
     protected VmwareTrafficLabel _publicTrafficInfo = new VmwareTrafficLabel(TrafficType.Public);
     protected int _portsPerDvPortGroup;
     protected boolean _fullCloneFlag = false;
+    protected boolean _instanceNameFlag = false;
 
     protected boolean _reserveCpu = false;
 
@@ -2566,8 +2567,18 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         }
 
         VirtualMachineTO vmSpec = cmd.getVirtualMachine();
-        String vmName = vmSpec.getName();
-
+        String vmInternalCSName = null;
+        String vmNameOnVcenter = null;
+        if (vmSpec.getHostName() != null) {
+            vmInternalCSName = vmSpec.getName();
+            if (_instanceNameFlag == true)
+                vmNameOnVcenter = vmSpec.getHostName();
+            else
+                vmNameOnVcenter = vmSpec.getName();
+        } else {
+            vmNameOnVcenter = vmInternalCSName = vmSpec.getName();
+        }
+        // Thus, vmInternalCSName always holds i-x-y, the cloudstack generated internal VM name.
         State state = State.Stopped;
         VmwareContext context = getServiceContext();
         try {
@@ -2575,12 +2586,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
 
             // mark VM as starting state so that sync() can know not to report stopped too early
             synchronized (_vms) {
-                _vms.put(vmName, State.Starting);
+                _vms.put(vmInternalCSName, State.Starting);
             }
 
             VirtualEthernetCardType nicDeviceType = VirtualEthernetCardType.valueOf(vmSpec.getDetails().get(VmDetailConstants.NIC_ADAPTER));
             if(s_logger.isDebugEnabled())
-                s_logger.debug("VM " + vmName + " will be started with NIC device type: " + nicDeviceType);
+                s_logger.debug("VM " + vmInternalCSName + " will be started with NIC device type: " + nicDeviceType);
 
             VmwareHypervisorHost hyperHost = getHyperHost(context);
             DiskTO[] disks = validateDisks(vmSpec.getDisks());
@@ -2594,9 +2605,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                 throw new Exception(msg);
             }
 
-            VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
+            VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmInternalCSName);
             if (vmMo != null) {
-                s_logger.info("VM " + vmName + " already exists, tear down devices for reconfiguration");
+                s_logger.info("VM " + vmInternalCSName + " already exists, tear down devices for reconfiguration");
                 if (getVmState(vmMo) != State.Stopped)
                     vmMo.safePowerOff(_shutdown_waitMs);
                 vmMo.tearDownDevices(new Class<?>[] { VirtualDisk.class, VirtualEthernetCard.class });
@@ -2605,13 +2616,13 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                 ManagedObjectReference morDc = hyperHost.getHyperHostDatacenter();
                 assert (morDc != null);
 
-                vmMo = hyperHost.findVmOnPeerHyperHost(vmName);
+                vmMo = hyperHost.findVmOnPeerHyperHost(vmInternalCSName);
                 if (vmMo != null) {
                     if (s_logger.isInfoEnabled()) {
-                        s_logger.info("Found vm " + vmName + " at other host, relocate to " + hyperHost.getHyperHostName());
+                        s_logger.info("Found vm " + vmInternalCSName + " at other host, relocate to " + hyperHost.getHyperHostName());
                     }
 
-                    takeVmFromOtherHyperHost(hyperHost, vmName);
+                    takeVmFromOtherHyperHost(hyperHost, vmInternalCSName);
 
                     if (getVmState(vmMo) != State.Stopped)
                         vmMo.safePowerOff(_shutdown_waitMs);
@@ -2628,16 +2639,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                     }
 
                     assert (vmSpec.getMinSpeed() != null) && (rootDiskDataStoreDetails != null);
-                    if (!hyperHost.createBlankVm(vmName, vmSpec.getCpus(), vmSpec.getMaxSpeed().intValue(),
+                    if (!hyperHost.createBlankVm(vmNameOnVcenter, vmInternalCSName, vmSpec.getCpus(), vmSpec.getMaxSpeed().intValue(),
                             vmSpec.getMinSpeed(), vmSpec.getLimitCpuUse(),(int)(vmSpec.getMaxRam()/(1024*1024)), ramMb,
                             translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value(), rootDiskDataStoreDetails.first(), false)) {
-                        throw new Exception("Failed to create VM. vmName: " + vmName);
+                        throw new Exception("Failed to create VM. vmName: " + vmInternalCSName);
                     }
                 }
 
-                vmMo = hyperHost.findVmOnHyperHost(vmName);
+                vmMo = hyperHost.findVmOnHyperHost(vmInternalCSName);
                 if (vmMo == null) {
-                    throw new Exception("Failed to find the newly create or relocated VM. vmName: " + vmName);
+                    throw new Exception("Failed to find the newly create or relocated VM. vmName: " + vmInternalCSName);
                 }
             }
 
@@ -2921,10 +2932,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             String keyboardLayout = null;
             if(vmSpec.getDetails() != null)
                 keyboardLayout = vmSpec.getDetails().get(VmDetailConstants.KEYBOARD);
-            vmConfigSpec.getExtraConfig().addAll(Arrays.asList(configureVnc(extraOptions.toArray(new OptionValue[0]), hyperHost, vmName, vmSpec.getVncPassword(), keyboardLayout)));
+            vmConfigSpec.getExtraConfig().addAll(Arrays.asList(configureVnc(extraOptions.toArray(new OptionValue[0]), hyperHost, vmInternalCSName, vmSpec.getVncPassword(), keyboardLayout)));
 
             if (!vmMo.configureVm(vmConfigSpec)) {
-                throw new Exception("Failed to configure VM before start. vmName: " + vmName);
+                throw new Exception("Failed to configure VM before start. vmName: " + vmInternalCSName);
             }
 
             vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, String.valueOf(nicMask));
@@ -3039,7 +3050,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             }
 
             if (!vmMo.powerOn()) {
-                throw new Exception("Failed to start VM. vmName: " + vmName);
+                throw new Exception("Failed to start VM. vmName: " + vmInternalCSName + " with hostname " + vmNameOnVcenter);
             }
 
             state = State.Running;
@@ -3056,9 +3067,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         } finally {
             synchronized (_vms) {
                 if (state != State.Stopped) {
-                    _vms.put(vmName, state);
+                    _vms.put(vmInternalCSName, state);
                 } else {
-                    _vms.remove(vmName);
+                    _vms.remove(vmInternalCSName);
                 }
             }
         }
@@ -3485,6 +3496,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         try {
             HashMap<String, State> newStates = getVmStates();
 
+            // getVmNames should return all i-x-y values.
             List<String> requestedVmNames = cmd.getVmNames();
             List<String> vmNames = new ArrayList<String>();
 
@@ -3542,6 +3554,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             s_logger.info("Executing resource StopCommand: " + _gson.toJson(cmd));
         }
 
+        // In the stop command, we're passed in the name of the VM as seen by cloudstack,
+        // i.e., i-x-y. This is the internal VM name.
         VmwareContext context = getServiceContext();
         VmwareHypervisorHost hyperHost = getHyperHost(context);
         try {
@@ -5368,7 +5382,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
 
                     ManagedObjectReference morPool = hyperHost.getHyperHostOwnerResourcePool();
                     ManagedObjectReference morCluster = hyperHost.getHyperHostCluster();
-                    //createVMLinkedClone(vmTemplate, dcMo, dsMo, vmdkName, morDatastore, morPool);
                     if (!_fullCloneFlag) {
                         createVMLinkedClone(vmTemplate, dcMo, dsMo, vmdkName, morDatastore, morPool);
                     } else {
@@ -5497,14 +5510,15 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                         for(ObjectContent oc : ocs) {
                             List<DynamicProperty> props = oc.getPropSet();
                             if(props != null) {
-                                String name = null;
+                                String vmName = null;
+                                String internalName = null;
                                 boolean template = false;
                                 VirtualMachinePowerState powerState = VirtualMachinePowerState.POWERED_OFF;
                                 GregorianCalendar bootTime = null;
 
                                 for(DynamicProperty prop : props) {
-                                    if(prop.getName().equals("name"))
-                                        name = prop.getVal().toString();
+                                    if (prop.getName().equals("name"))
+                                        vmName = prop.getVal().toString();
                                     else if(prop.getName().equals("config.template"))
                                         template = (Boolean)prop.getVal();
                                     else if(prop.getName().equals("runtime.powerState"))
@@ -5513,6 +5527,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                                         bootTime = (GregorianCalendar)prop.getVal();
                                 }
 
+                                VirtualMachineMO vmMo = new VirtualMachineMO(hyperHost.getContext(), oc.getObj());
+                                // Check if vmMo has the custom property CLOUD_VM_INTERNAL_NAME set.
+                                internalName =  vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+
+                                String name = null;
+                                if (internalName != null) {
+                                    name = internalName;
+                                } else {
+                                    name = vmName;
+                                }
                                 if(!template && name.matches("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")) {
                                     boolean recycle = false;
 
@@ -5525,7 +5549,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                                     if(recycle) {
                                         s_logger.info("Recycle pending worker VM: " + name);
 
-                                        VirtualMachineMO vmMo = new VirtualMachineMO(hyperHost.getContext(), oc.getObj());
                                         vmMo.powerOff();
                                         vmMo.destroy();
                                     }
@@ -5944,6 +5967,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
 
     private HashMap<String, State> getVmStates() throws Exception {
         VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
+        // CLOUD_VM_INTERNAL_NAME stores the internal CS generated vm name. This was earlier stored in name. Now, name can be either the hostname or
+        // the internal CS name, but the custom field CLOUD_VM_INTERNAL_NAME always stores the internal CS name.
         ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] { "name", "runtime.powerState", "config.template" });
 
         HashMap<String, State> newStates = new HashMap<String, State>();
@@ -5954,20 +5979,26 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
 
                     boolean isTemplate = false;
                     String name = null;
+                    String VMInternalCSName = null;
                     VirtualMachinePowerState powerState = VirtualMachinePowerState.POWERED_OFF;
                     for (DynamicProperty objProp : objProps) {
                         if (objProp.getName().equals("config.template")) {
                             if (objProp.getVal().toString().equalsIgnoreCase("true")) {
                                 isTemplate = true;
                             }
-                        } else if (objProp.getName().equals("name")) {
-                            name = (String) objProp.getVal();
                         } else if (objProp.getName().equals("runtime.powerState")) {
                             powerState = (VirtualMachinePowerState) objProp.getVal();
+                        } else if (objProp.getName().equals("name")) {
+                            name = (String) objProp.getVal();
                         } else {
                             assert (false);
                         }
                     }
+                    VirtualMachineMO vmMo = new VirtualMachineMO(hyperHost.getContext(), oc.getObj());
+                    // Check if vmMo has the custom property CLOUD_VM_INTERNAL_NAME set.
+                    VMInternalCSName =  vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+                    if (VMInternalCSName != null)
+                        name = VMInternalCSName;
 
                     if (!isTemplate) {
                         newStates.put(name, convertState(powerState));
@@ -6006,16 +6037,26 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                     String name = null;
                     String numberCPUs = null;
                     String maxCpuUsage = null;
-
+                    String vmNameOnVcenter = null;
+                    String vmInternalCSName = null;
                     for (DynamicProperty objProp : objProps) {
                         if (objProp.getName().equals("name")) {
-                            name = objProp.getVal().toString();
+                            vmNameOnVcenter = objProp.getVal().toString();
                         } else if (objProp.getName().equals("summary.config.numCpu")) {
                             numberCPUs = objProp.getVal().toString();
                         } else if (objProp.getName().equals("summary.quickStats.overallCpuUsage")) {
                             maxCpuUsage =  objProp.getVal().toString();
                         }
                     }
+                    VirtualMachineMO vmMo = new VirtualMachineMO(hyperHost.getContext(), oc.getObj());
+                    // Check if vmMo has the custom property CLOUD_VM_INTERNAL_NAME set.
+                    vmInternalCSName =  vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+
+                    if (vmInternalCSName != null) {
+                        name = vmInternalCSName;
+                    } else {
+                        name = vmNameOnVcenter;
+                    }
 
                     if (!vmNames.contains(name)) {
                         continue;
@@ -6324,6 +6365,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         } else {
             _fullCloneFlag = false;
         }
+
+        value = params.get("vm.instancename.flag").toString();
+        if (value != null && value.equalsIgnoreCase("true")) {
+            _instanceNameFlag = true;
+        } else {
+            _instanceNameFlag = false;
+        }
+
         value = (String)params.get("scripts.timeout");
         int timeout = NumbersUtil.parseInt(value, 1440) * 1000;
         VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index d1131f8..5f2d07f 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -11,7 +11,7 @@
 // Unless required by applicable law or agreed to in writing,
 // software distributed under the License is distributed on an
 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 package com.cloud.storage.resource;
@@ -27,6 +27,21 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+
+import com.google.gson.Gson;
+import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.VirtualDeviceConfigSpec;
+import com.vmware.vim25.VirtualDeviceConfigSpecOperation;
+import com.vmware.vim25.VirtualDisk;
+import com.vmware.vim25.VirtualEthernetCard;
+import com.vmware.vim25.VirtualLsiLogicController;
+import com.vmware.vim25.VirtualMachineConfigSpec;
+import com.vmware.vim25.VirtualMachineFileInfo;
+import com.vmware.vim25.VirtualMachineGuestOsIdentifier;
+import com.vmware.vim25.VirtualSCSISharing;
+
 import org.apache.cloudstack.storage.command.AttachAnswer;
 import org.apache.cloudstack.storage.command.AttachCommand;
 import org.apache.cloudstack.storage.command.CopyCmdAnswer;
@@ -39,8 +54,6 @@ import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
 import org.apache.cloudstack.storage.to.SnapshotObjectTO;
 import org.apache.cloudstack.storage.to.TemplateObjectTO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
@@ -97,11 +110,11 @@ public class VmwareStorageProcessor implements StorageProcessor {
                                   Integer shutdownWaitMs,
                                   PremiumSecondaryStorageResource storageResource) {
         this.hostService = hostService;
-        this._fullCloneFlag = fullCloneFlag;
+        _fullCloneFlag = fullCloneFlag;
         this.mountService = mountService;
-        this._timeout = timeout;
+        _timeout = timeout;
         this.resource = resource;
-        this._shutdown_waitMs = shutdownWaitMs;
+        _shutdown_waitMs = shutdownWaitMs;
         _gson = GsonHelper.getGsonLogger();
         this.storageResource = storageResource;
     }
@@ -311,8 +324,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
         PrimaryDataStoreTO srcStore = (PrimaryDataStoreTO)template.getDataStore();
 
         try {
-            VmwareContext context = this.hostService.getServiceContext(null);
-            VmwareHypervisorHost hyperHost = this.hostService.getHyperHost(context, null);
+            VmwareContext context = hostService.getServiceContext(null);
+            VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
             DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
             VirtualMachineMO vmMo = null;
             ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStore.getUuid());
@@ -389,7 +402,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
         } catch (Throwable e) {
             if (e instanceof RemoteException) {
                 s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
-                this.hostService.invalidateServiceContext(null);
+                hostService.invalidateServiceContext(null);
             }
 
             String msg = "CreateCommand failed due to " + VmwareHelper.getExceptionMessage(e);
@@ -1027,6 +1040,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                         workerVMName = hostService.getWorkerName(context, cmd, 0);
                         
                         vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName);
+
                         if (vmMo == null) {
                             throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
                         }
@@ -1046,7 +1060,6 @@ public class VmwareStorageProcessor implements StorageProcessor {
                         hostService.getWorkerName(context, cmd, 1));
 
                 success = (snapshotBackupUuid != null);
-
                 if (!success) {
                     details = "Failed to backUp the snapshot with uuid: " + snapshotUuid + " to secondary storage.";
                     return new CopyCmdAnswer(details);
@@ -1109,7 +1122,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
         VolumeObjectTO volumeTO = (VolumeObjectTO)disk.getData();
         PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)volumeTO.getDataStore();
         try {
-            VmwareHypervisorHost hyperHost = this.hostService.getHyperHost(this.hostService.getServiceContext(null), null);
+            VmwareHypervisorHost hyperHost = hostService.getHyperHost(hostService.getServiceContext(null), null);
             VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
             if (vmMo == null) {
                 String msg = "Unable to find the VM to execute AttachVolumeCommand, vmName: " + vmName;
@@ -1120,7 +1133,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
             ManagedObjectReference morDs = null;
 
             if (isAttach && isManaged) {
-                morDs = this.hostService.handleDatastoreAndVmdkAttach(cmd, iScsiName, storageHost, storagePort,
+                morDs = hostService.handleDatastoreAndVmdkAttach(cmd, iScsiName, storageHost, storagePort,
                         initiatorUsername, initiatorPassword, targetUsername, targetPassword);
             }
             else {
@@ -1146,7 +1159,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                 vmMo.detachDisk(datastoreVolumePath, false);
 
                 if (isManaged) {
-                    this.hostService.handleDatastoreAndVmdkDetach(iScsiName, storageHost, storagePort);
+                    hostService.handleDatastoreAndVmdkDetach(iScsiName, storageHost, storagePort);
                 }
             }
 
@@ -1154,7 +1167,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
         } catch (Throwable e) {
             if (e instanceof RemoteException) {
                 s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
-                this.hostService.invalidateServiceContext(null);
+                hostService.invalidateServiceContext(null);
             }
 
             String msg = "AttachVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e);
@@ -1171,7 +1184,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
         String storeName = getSecondaryDatastoreUUID(storeUrl);
         URI uri = new URI(storeUrl);
 
-        VmwareHypervisorHost hyperHost = this.hostService.getHyperHost(this.hostService.getServiceContext(null), null);
+        VmwareHypervisorHost hyperHost = hostService.getHyperHost(hostService.getServiceContext(null), null);
         ManagedObjectReference morDatastore = hyperHost.mountDatastore(false, uri.getHost(), 0, uri.getPath(), storeName.replace("-", ""));
 
         if (morDatastore == null)
@@ -1182,7 +1195,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
     
     private Answer attachIso(DiskTO disk, boolean isAttach, String vmName) {
         try {
-            VmwareHypervisorHost hyperHost = this.hostService.getHyperHost(this.hostService.getServiceContext(null), null);
+            VmwareHypervisorHost hyperHost = hostService.getHyperHost(hostService.getServiceContext(null), null);
             VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
             if (vmMo == null) {
                 String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + vmName;
@@ -1229,7 +1242,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
 
             // TODO, check if iso is already attached, or if there is a previous
             // attachment
-            DatastoreMO secondaryDsMo = new DatastoreMO(this.hostService.getServiceContext(null), morSecondaryDs);
+            DatastoreMO secondaryDsMo = new DatastoreMO(hostService.getServiceContext(null), morSecondaryDs);
             String storeName = secondaryDsMo.getName();
             String isoDatastorePath = String.format("[%s] %s%s", storeName, isoStorePathFromRoot, isoFileName);
 
@@ -1243,7 +1256,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
         } catch (Throwable e) {
             if (e instanceof RemoteException) {
                 s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
-                this.hostService.invalidateServiceContext(null);
+                hostService.invalidateServiceContext(null);
             }
 
             if(isAttach) {
@@ -1274,8 +1287,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
         PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)volume.getDataStore();
 
         try {
-            VmwareContext context = this.hostService.getServiceContext(null);
-            VmwareHypervisorHost hyperHost = this.hostService.getHyperHost(context, null);
+            VmwareContext context = hostService.getServiceContext(null);
+            VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
             DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
 
             ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStore.getUuid());
@@ -1286,8 +1299,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
             // create data volume
             VirtualMachineMO vmMo = null;
             String volumeUuid = UUID.randomUUID().toString().replace("-", "");
-            String volumeDatastorePath = dsMo.getDatastorePath(volumeUuid + ".vmdk");
 
+            String volumeDatastorePath = dsMo.getDatastorePath(volumeUuid + ".vmdk");
             String dummyVmName = this.hostService.getWorkerName(context, cmd, 0);
             try {
             	s_logger.info("Create worker VM " + dummyVmName);
@@ -1318,7 +1331,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
         } catch (Throwable e) {
             if (e instanceof RemoteException) {
                 s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
-                this.hostService.invalidateServiceContext(null);
+                hostService.invalidateServiceContext(null);
             }
 
             String msg = "CreateCommand failed due to " + VmwareHelper.getExceptionMessage(e);
@@ -1356,8 +1369,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
 		 */
 
         try {
-            VmwareContext context = this.hostService.getServiceContext(null);
-            VmwareHypervisorHost hyperHost = this.hostService.getHyperHost(context, null);
+            VmwareContext context = hostService.getServiceContext(null);
+            VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
             VolumeObjectTO vol = (VolumeObjectTO)cmd.getData();
             PrimaryDataStoreTO store = (PrimaryDataStoreTO)vol.getDataStore();
 
@@ -1387,7 +1400,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                         List<NetworkDetails> networks = vmMo.getNetworksWithDetails();
 
                         // tear down all devices first before we destroy the VM to avoid accidently delete disk backing files
-                        if (this.resource.getVmState(vmMo) != State.Stopped)
+                        if (resource.getVmState(vmMo) != State.Stopped)
                             vmMo.safePowerOff(_shutdown_waitMs);
                         vmMo.tearDownDevices(new Class<?>[] { VirtualDisk.class, VirtualEthernetCard.class });
                         vmMo.destroy();
@@ -1395,7 +1408,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                         for (NetworkDetails netDetails : networks) {
                             if (netDetails.getGCTag() != null && netDetails.getGCTag().equalsIgnoreCase("true")) {
                                 if (netDetails.getVMMorsOnNetwork() == null || netDetails.getVMMorsOnNetwork().length == 1) {
-                                    this.resource.cleanupNetwork(hostMo, netDetails);
+                                    resource.cleanupNetwork(hostMo, netDetails);
                                 }
                             }
                         }
@@ -1474,7 +1487,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
         } catch (Throwable e) {
             if (e instanceof RemoteException) {
                 s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
-                this.hostService.invalidateServiceContext(null);
+                hostService.invalidateServiceContext(null);
             }
 
             String msg = "DestroyCommand failed due to " + VmwareHelper.getExceptionMessage(e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index ad8e3aa..602020b 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -264,7 +264,8 @@ public enum Config {
     EnableEC2API("Advanced", ManagementServer.class, Boolean.class, "enable.ec2.api", "false", "enable EC2 API on CloudStack", null),
     EnableS3API("Advanced", ManagementServer.class, Boolean.class, "enable.s3.api", "false", "enable Amazon S3 API on CloudStack", null),
     RecreateSystemVmEnabled("Advanced", ManagementServer.class, Boolean.class, "recreate.systemvm.enabled", "false", "If true, will recreate system vm root disk whenever starting system vm", "true,false"),
-    SetVmInternalNameUsingDisplayName("Advanced", ManagementServer.class, Boolean.class, "vm.instancename.flag", "false", "If true, will append guest VM's display Name (if set) to its internal instance name", "true,false"),
+    SetVmInternalNameUsingDisplayName("Advanced", ManagementServer.class, Boolean.class, "vm.instancename.flag", "false",
+            "If set to true, will set guest VM's name as it appears on the hypervisor, to its hostname", "true,false"),
     IncorrectLoginAttemptsAllowed("Advanced", ManagementServer.class, Integer.class, "incorrect.login.attempts.allowed", "5", "Incorrect login attempts allowed before the user is disabled", null),
     // Ovm
     OvmPublicNetwork("Hidden", ManagementServer.class, String.class, "ovm.public.network.device", null, "Specify the public bridge on host for public network", null),
@@ -436,7 +437,7 @@ public enum Config {
     InternalLbVmServiceOfferingId("Advanced", ManagementServer.class, String.class, "internallbvm.service.offering", null, "Uuid of the service offering used by internal lb vm; if NULL - default system internal lb offering will be used", null),
     ExecuteInSequence("Advanced", ManagementServer.class, Boolean.class, "execute.in.sequence.hypervisor.commands", "false", "If set to true, StartCommand, StopCommand, CopyCommand will be synchronized on the agent side." +
     		" If set to false, these commands become asynchronous. Default value is false.", null),
-    ExecuteInSequenceNetworkElementCommands("Advanced", NetworkManager.class, Boolean.class, "execute.in.sequence.network.element.commands", "false", "If set to true, DhcpEntryCommand, SavePasswordCommand, UserDataCommand, VmDataCommand will be synchronized on the agent side." + 
+    ExecuteInSequenceNetworkElementCommands("Advanced", NetworkManager.class, Boolean.class, "execute.in.sequence.network.element.commands", "false", "If set to true, DhcpEntryCommand, SavePasswordCommand, UserDataCommand, VmDataCommand will be synchronized on the agent side." +
             " If set to false, these commands become asynchronous. Default value is false.", null),
 	
 	UCSSyncBladeInterval("Advanced", ManagementServer.class, Integer.class, "ucs.sync.blade.interval", "3600", "the interval cloudstack sync with UCS manager for available blades in case user remove blades from chassis without notifying CloudStack", null);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
index 25c5a04..061304e 100755
--- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -298,11 +298,6 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
             return;
         }
 
-        if(vm.getHypervisorType() == HypervisorType.VMware) {
-            s_logger.info("Skip HA for VMware VM " + vm.getInstanceName());
-            return;
-        }
-
         if (!investigate) {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("VM does not require investigation so I'm marking it as Stopped: " + vm.toString());
@@ -341,6 +336,11 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
             }        
         }
 
+        if(vm.getHypervisorType() == HypervisorType.VMware) {
+            s_logger.info("Skip HA for VMware VM " + vm.getInstanceName());
+            return;
+        }
+
         List<HaWorkVO> items = _haDao.findPreviousHA(vm.getId());
         int maxRetries = 0;
         for (HaWorkVO item : items) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
index e042eb8..73e04f8 100644
--- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
+++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
@@ -95,7 +95,6 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
 
 
     protected <T extends VirtualMachine> VirtualMachineTO  toVirtualMachineTO(VirtualMachineProfile<T> vmProfile) {
-
         ServiceOffering offering = vmProfile.getServiceOffering();
         VirtualMachine vm = vmProfile.getVirtualMachine();
         Long minMemory = (long) (offering.getRamSize() / vmProfile.getMemoryOvercommitRatio());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 4a222c4..10d21d7 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1547,14 +1547,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
                 new UserVmStateListener(_usageEventDao, _networkDao, _nicDao));
 
         value = _configDao.getValue(Config.SetVmInternalNameUsingDisplayName.key());
-
-        if(value == null) {
-            _instanceNameFlag = false;
-        }
-        else
-        {
-            _instanceNameFlag = Boolean.parseBoolean(value);
-        }
+        _instanceNameFlag = (value == null)?false:Boolean.parseBoolean(value);
 
        _scaleRetry = NumbersUtil.parseInt(configs.get(Config.ScaleRetry.key()), 2);
 
@@ -2729,58 +2722,59 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
 
         long id = _vmDao.getNextInSequence(Long.class, "id");
 
-        String instanceName;
-        if (_instanceNameFlag && displayName != null) {
-            // Check if the displayName conforms to RFC standards.
-            checkNameForRFCCompliance(displayName);
-            instanceName = VirtualMachineName.getVmName(id, owner.getId(), displayName);
-            if (instanceName.length() > MAX_VM_NAME_LEN) {
-                throw new InvalidParameterValueException("Specified display name " + displayName + " causes VM name to exceed 80 characters in length");
-            }
-            // Search whether there is already an instance with the same instance name
-            // that is not in the destroyed or expunging state.
-            VMInstanceVO vm = _vmInstanceDao.findVMByInstanceName(instanceName);
-            if (vm != null && vm.getState() != VirtualMachine.State.Expunging) {
-                throw new InvalidParameterValueException("There already exists a VM by the display name supplied");
-            }
-        } else {
-            instanceName = VirtualMachineName.getVmName(id, owner.getId(), _instance);
+        if (hostName != null) {
+            // Check is hostName is RFC compliant
+            checkNameForRFCCompliance(hostName);
         }
 
+        String instanceName = null;
         String uuidName = UUID.randomUUID().toString();
-
-        // verify hostname information
-        if (hostName == null) {
-            hostName = uuidName;
-        } else {
-            //1) check is hostName is RFC compliant
-            checkNameForRFCCompliance(hostName);
-            // 2) hostName has to be unique in the network domain
-            Map<String, List<Long>> ntwkDomains = new HashMap<String, List<Long>>();
-            for (NetworkVO network : networkList) {
-                String ntwkDomain = network.getNetworkDomain();
-                if (!ntwkDomains.containsKey(ntwkDomain)) {
-                    List<Long> ntwkIds = new ArrayList<Long>();
-                    ntwkIds.add(network.getId());
-                    ntwkDomains.put(ntwkDomain, ntwkIds);
+        if (_instanceNameFlag && hypervisor.equals(HypervisorType.VMware)) {
+            if (hostName == null) {
+                if (displayName != null) {
+                    hostName = displayName;
                 } else {
-                    List<Long> ntwkIds = ntwkDomains.get(ntwkDomain);
-                    ntwkIds.add(network.getId());
-                    ntwkDomains.put(ntwkDomain, ntwkIds);
+                    hostName = uuidName;
                 }
             }
+        } else {
+            if (hostName == null) {
+                hostName = uuidName;
+            }
+        }
 
-            for (String ntwkDomain : ntwkDomains.keySet()) {
-                for (Long ntwkId : ntwkDomains.get(ntwkDomain)) {
-                    // * get all vms hostNames in the network
-                    List<String> hostNames = _vmInstanceDao
-                            .listDistinctHostNames(ntwkId);
-                    // * verify that there are no duplicates
-                    if (hostNames.contains(hostName)) {
-                        throw new InvalidParameterValueException("The vm with hostName " + hostName
-                                + " already exists in the network domain: " + ntwkDomain + "; network="
-                                + _networkModel.getNetwork(ntwkId));
-                    }
+        instanceName = VirtualMachineName.getVmName(id, owner.getId(), _instance);
+
+        // Check if VM with instanceName already exists.
+        VMInstanceVO vmObj = _vmInstanceDao.findVMByInstanceName(instanceName);
+        if (vmObj != null && vmObj.getState() != VirtualMachine.State.Expunging) {
+            throw new InvalidParameterValueException("There already exists a VM by the display name supplied");
+        }
+
+        // Check that hostName is unique in the network domain
+        Map<String, List<Long>> ntwkDomains = new HashMap<String, List<Long>>();
+        for (NetworkVO network : networkList) {
+            String ntwkDomain = network.getNetworkDomain();
+            if (!ntwkDomains.containsKey(ntwkDomain)) {
+                List<Long> ntwkIds = new ArrayList<Long>();
+                ntwkIds.add(network.getId());
+                ntwkDomains.put(ntwkDomain, ntwkIds);
+            } else {
+                List<Long> ntwkIds = ntwkDomains.get(ntwkDomain);
+                ntwkIds.add(network.getId());
+                ntwkDomains.put(ntwkDomain, ntwkIds);
+            }
+        }
+
+        for (String ntwkDomain : ntwkDomains.keySet()) {
+            for (Long ntwkId : ntwkDomains.get(ntwkDomain)) {
+                // * get all vms hostNames in the network
+                List<String> hostNames = _vmInstanceDao.listDistinctHostNames(ntwkId);
+                // * verify that there are no duplicates
+                if (hostNames.contains(hostName)) {
+                    throw new InvalidParameterValueException("The vm with hostName " + hostName
+                        + " already exists in the network domain: " + ntwkDomain + "; network="
+                        + _networkModel.getNetwork(ntwkId));
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index b33ee49..d2a7dbe 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -944,7 +944,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
                     VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
 
                     cmds = new Commands(OnError.Stop);
-                    cmds.addCommand(new StartCommand(vmTO, dest.getHost(), _mgmtServer.getExecuteInSequence()));
+                    StartCommand strtcmd = new StartCommand(vmTO, dest.getHost(), _mgmtServer.getExecuteInSequence());
+
+                    cmds.addCommand(strtcmd);
 
                     vmGuru.finalizeDeployment(cmds, vmProfile, dest, ctx);
 
@@ -953,6 +955,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
                     if (work == null || work.getStep() != Step.Prepare) {
                         throw new ConcurrentOperationException("Work steps have been changed: " + work);
                     }
+
                     _workDao.updateStep(work, Step.Starting);
 
                     _agentMgr.send(destHostId, cmds);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index cd0d98b..8e2feda 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -290,7 +290,7 @@ CREATE TABLE `cloud`.`load_balancer_healthcheck_policies` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.instancename.flag', 'false', 'Append guest VM display Name (if set) to the internal name of the VM');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.instancename.flag', 'false', 'If set to true, will set guest VM\'s name as it appears on the hypervisor, to its hostname');
 
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (165, UUID(), 6, 'Windows 8 (32-bit)');
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (166, UUID(), 6, 'Windows 8 (64-bit)');

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
index 04ef0f8..d1a4530 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
@@ -270,7 +270,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	}
 
 	@Override
-	public boolean createBlankVm(String vmName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB,
+	public boolean createBlankVm(String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB,
 		String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
 
 	    if(s_logger.isTraceEnabled())
@@ -278,7 +278,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 				+ ", cpuSpeedMhz: " + cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB
 				+ ", guestOS: " + guestOsIdentifier + ", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
 
-		boolean result = HypervisorHostHelper.createBlankVm(this, vmName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse,
+		boolean result = HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse,
 			memoryMB, memoryReserveMB, guestOsIdentifier, morDs, snapshotDirToParent);
 
 		if(s_logger.isTraceEnabled())

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java
index 11bc157..139d377 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java
@@ -22,4 +22,5 @@ public interface CustomFieldConstants {
 	public final static String CLOUD_GC_DVP = "cloud.gc.dvp";	
 	public final static String CLOUD_NIC_MASK = "cloud.nic.mask";
     public final static String CLOUD_ZONE = "cloud.zone";
+    public final static String CLOUD_VM_INTERNAL_NAME = "cloud.vm.internal.name";
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
index 2735fb0..c6bb332 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
@@ -17,15 +17,19 @@
 package com.cloud.hypervisor.vmware.mo;
 
 import java.util.ArrayList;
+import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 
 import org.apache.log4j.Logger;
+import org.apache.xerces.impl.xs.identity.Selector.Matcher;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.hypervisor.vmware.util.VmwareHelper;
 import com.cloud.utils.Pair;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.google.gson.Gson;
 import com.vmware.vim25.AboutInfo;
 import com.vmware.vim25.AlreadyExistsFaultMsg;
@@ -57,6 +61,7 @@ import com.vmware.vim25.PropertyFilterSpec;
 import com.vmware.vim25.PropertySpec;
 import com.vmware.vim25.TraversalSpec;
 import com.vmware.vim25.VirtualMachineConfigSpec;
+import com.vmware.vim25.VirtualMachinePowerState;
 import com.vmware.vim25.VirtualNicManagerNetConfig;
 import com.vmware.vim25.NasDatastoreInfo;
 
@@ -65,6 +70,7 @@ import edu.emory.mathcs.backport.java.util.Arrays;
 public class HostMO extends BaseMO implements VmwareHypervisorHost {
     private static final Logger s_logger = Logger.getLogger(HostMO.class);
     Map<String, VirtualMachineMO> _vmCache = new HashMap<String, VirtualMachineMO>();
+    //Map<String, String> _vmInternalNameMapCache = new HashMap<String, String>();
 
 	public HostMO (VmwareContext context, ManagedObjectReference morHost) {
 		super(context, morHost);
@@ -465,19 +471,34 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	}
 
     @Override
-    public synchronized VirtualMachineMO findVmOnHyperHost(String name) throws Exception {
+    public synchronized VirtualMachineMO findVmOnHyperHost(String vmName) throws Exception {
     	if(s_logger.isDebugEnabled())
-    		s_logger.debug("find VM " + name + " on host");
+            s_logger.debug("find VM " + vmName + " on host");
 
-        VirtualMachineMO vmMo = _vmCache.get(name);
+        VirtualMachineMO vmMo = _vmCache.get(vmName);
         if(vmMo != null) {
         	if(s_logger.isDebugEnabled())
-        		s_logger.debug("VM " + name + " found in host cache");
+                s_logger.debug("VM " + vmName + " found in host cache");
             return vmMo;
         }
 
+        s_logger.info("VM " + vmName + " not found in host cache");
         loadVmCache();
-        return _vmCache.get(name);
+
+        return _vmCache.get(vmName);
+    }
+
+    private boolean isUserVMInternalCSName(String vmInternalCSName) {
+        // CS generated internal names for user VMs are always of the format i-x-y.
+
+        String internalCSUserVMNamingPattern = "^[i][-][0-9]+[-][0-9]+[-]";
+        Pattern p = Pattern.compile(internalCSUserVMNamingPattern);
+        java.util.regex.Matcher m = p.matcher(vmInternalCSName);
+        if (m.find()) {
+            return true;
+        } else {
+            return false;
+        }
     }
 
     private void loadVmCache() throws Exception {
@@ -486,15 +507,35 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 
         _vmCache.clear();
 
+        // name is the name of the VM as it appears in vCenter. The CLOUD_VM_INTERNAL_NAME custom
+        // field value contains the name of the VM as it is maintained internally by cloudstack (i-x-y).
         ObjectContent[] ocs = getVmPropertiesOnHyperHost(new String[] { "name" });
         if(ocs != null && ocs.length > 0) {
             for(ObjectContent oc : ocs) {
-                String vmName = oc.getPropSet().get(0).getVal().toString();
-
-                if(s_logger.isTraceEnabled())
-                	s_logger.trace("put " + vmName + " into host cache");
-
-                _vmCache.put(vmName, new VirtualMachineMO(_context, oc.getObj()));
+                List<DynamicProperty> props = oc.getPropSet();
+                if (props != null) {
+                    String vmVcenterName = null;
+                    String vmInternalCSName = null;
+                    for (DynamicProperty prop : props) {
+                        if (prop.getName().equals("name")) {
+                            vmVcenterName = prop.getVal().toString();
+                        }
+                    }
+                    VirtualMachineMO vmMo = new VirtualMachineMO(_context, oc.getObj());
+                    // Check if vmMo has the custom property CLOUD_VM_INTERNAL_NAME set.
+                    vmInternalCSName =  vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+                    String vmName = null;
+                    if (vmInternalCSName != null && isUserVMInternalCSName(vmInternalCSName)) {
+                        vmName = vmInternalCSName;
+                    } else {
+                        vmName = vmVcenterName;
+                    }
+
+                    if(s_logger.isTraceEnabled())
+                        s_logger.trace("put " + vmName + " into host cache");
+
+                    _vmCache.put(vmName, new VirtualMachineMO(_context, oc.getObj()));
+                }
             }
         }
     }
@@ -530,33 +571,38 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 		} else {
         	s_logger.error("VMware createVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
 		}
-
 		return false;
 	}
 
 	public HashMap<String, Integer> getVmVncPortsOnHost() throws Exception {
     	ObjectContent[] ocs = getVmPropertiesOnHyperHost(
-        		new String[] { "name", "config.extraConfig[\"RemoteDisplay.vnc.port\"]" }
-        	);
+            new String[] { "name", "config.extraConfig[\"RemoteDisplay.vnc.port\"]" }
+            );
 
         HashMap<String, Integer> portInfo = new HashMap<String, Integer>();
     	if(ocs != null && ocs.length > 0) {
     		for(ObjectContent oc : ocs) {
 		        List<DynamicProperty> objProps = oc.getPropSet();
 		        if(objProps != null) {
-		        	String name = null;
+		            String vmName = null;
 		        	String value = null;
+		            String vmInternalCSName = null;
 		        	for(DynamicProperty objProp : objProps) {
 		        		if(objProp.getName().equals("name")) {
-		        			name = (String)objProp.getVal();
-		        		} else {
-		        			OptionValue optValue = (OptionValue)objProp.getVal();
-		        			value = (String)optValue.getValue();
-		        		}
-		        	}
-
-		        	if(name != null && value != null) {
-		        		portInfo.put(name, Integer.parseInt(value));
+		                    vmName = (String)objProp.getVal();
+		                } else {
+		                    OptionValue optValue = (OptionValue)objProp.getVal();
+		                    value = (String)optValue.getValue();
+		                }
+		            }
+		            VirtualMachineMO vmMo = new VirtualMachineMO(_context, oc.getObj());
+                    // Check if vmMo has the custom property CLOUD_VM_INTERNAL_NAME set.
+                    vmInternalCSName =  vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+	                if (vmInternalCSName != null && isUserVMInternalCSName(vmInternalCSName))
+	                    vmName = vmInternalCSName;
+
+                    if(vmName != null && value != null) {
+		                portInfo.put(vmName, Integer.parseInt(value));
 		        	}
 		        }
     		}
@@ -689,7 +735,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	}
 
 	@Override
-	public boolean createBlankVm(String vmName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB,
+	public boolean createBlankVm(String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB,
 		String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
 
 		if(s_logger.isTraceEnabled())
@@ -697,7 +743,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 				+ ", cpuSpeedMhz: " + cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB
 				+ ", guestOS: " + guestOsIdentifier + ", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
 
-		boolean result = HypervisorHostHelper.createBlankVm(this, vmName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse,
+		boolean result = HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse,
 			memoryMB, memoryReserveMB, guestOsIdentifier, morDs, snapshotDirToParent);
 
 		if(s_logger.isTraceEnabled())

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
index d20eb6f..52748ad 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -61,6 +61,7 @@ import com.vmware.vim25.HttpNfcLeaseState;
 import com.vmware.vim25.LongPolicy;
 import com.vmware.vim25.ManagedObjectReference;
 import com.vmware.vim25.ObjectContent;
+import com.vmware.vim25.OptionValue;
 import com.vmware.vim25.OvfCreateImportSpecParams;
 import com.vmware.vim25.OvfCreateImportSpecResult;
 import com.vmware.vim25.OvfFileItem;
@@ -93,10 +94,27 @@ public class HypervisorHostHelper {
 
         if(ocs != null && ocs.length > 0) {
             for(ObjectContent oc : ocs) {
-                DynamicProperty prop = oc.getPropSet().get(0);
-                assert(prop != null);
-                if(prop.getVal().toString().equals(name))
-                    return new VirtualMachineMO(context, oc.getObj());
+                String vmNameInvCenter = null;
+                String vmInternalCSName = null;
+                List<DynamicProperty> objProps = oc.getPropSet();
+		        if(objProps != null) {
+		            for(DynamicProperty objProp : objProps) {
+		                if(objProp.getName().equals("name")) {
+		                    vmNameInvCenter = (String)objProp.getVal();
+		                }
+		                VirtualMachineMO vmMo = new VirtualMachineMO(context, oc.getObj());
+	                    // Check if vmMo has the custom property CLOUD_VM_INTERNAL_NAME set.
+		                try {
+		                    vmInternalCSName =  vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+		                } catch (Exception e) {
+		                    s_logger.error("Unable to retrieve custom field value for internal VM name");
+		                }
+                        if ( (vmNameInvCenter != null && name.equalsIgnoreCase(vmNameInvCenter))
+                                || (vmInternalCSName != null && name.equalsIgnoreCase(vmInternalCSName)) ) {
+                            return vmMo;
+                        }
+                    }
+                }
             }
         }
         return null;
@@ -1121,7 +1139,7 @@ public class HypervisorHostHelper {
         return morNetwork;
     }
 
-    public static boolean createBlankVm(VmwareHypervisorHost host, String vmName,
+    public static boolean createBlankVm(VmwareHypervisorHost host, String vmName, String vmInternalCSName,
             int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB, String guestOsIdentifier,
             ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
 
@@ -1131,6 +1149,9 @@ public class HypervisorHostHelper {
         // VM config basics
         VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
         vmConfig.setName(vmName);
+        if (vmInternalCSName == null)
+            vmInternalCSName = vmName;
+
         VmwareHelper.setBasicVmConfig(vmConfig, cpuCount, cpuSpeedMHz, cpuReservedMHz, memoryMB, memoryReserveMB, guestOsIdentifier, limitCpuUse);
 
         // Scsi controller
@@ -1158,23 +1179,32 @@ public class HypervisorHostHelper {
         vmConfig.getDeviceChange().add(scsiControllerSpec);
         vmConfig.getDeviceChange().add(videoDeviceSpec);
         if(host.createVm(vmConfig)) {
+            // Here, when attempting to find the VM, we need to use the name
+            // with which we created it. This is the only such place where
+            // we need to do this. At all other places, we always use the
+            // VM's internal cloudstack generated name. Here, we cannot use
+            // the internal name because we can set the internal name into the
+            // VM's custom field CLOUD_VM_INTERNAL_NAME only after we create
+            // the VM.
             VirtualMachineMO vmMo = host.findVmOnHyperHost(vmName);
             assert(vmMo != null);
 
+            vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_VM_INTERNAL_NAME, vmInternalCSName);
+
             int ideControllerKey = -1;
             while(ideControllerKey < 0) {
                 ideControllerKey = vmMo.tryGetIDEDeviceControllerKey();
                 if(ideControllerKey >= 0)
                     break;
 
-                s_logger.info("Waiting for IDE controller be ready in VM: " + vmName);
+                s_logger.info("Waiting for IDE controller be ready in VM: " + vmInternalCSName);
                 Thread.sleep(1000);
             }
 
             if(snapshotDirToParent) {
                 String snapshotDir = String.format("/vmfs/volumes/%s/", dsMo.getName());
 
-                s_logger.info("Switch snapshot working directory to " + snapshotDir + " for " + vmName);
+                s_logger.info("Switch snapshot working directory to " + snapshotDir + " for " + vmInternalCSName);
                 vmMo.setSnapshotDirectory(snapshotDir);
 
                 // Don't have a good way to test if the VM is really ready for use through normal API after configuration file manipulation,
@@ -1182,7 +1212,7 @@ public class HypervisorHostHelper {
                 Thread.sleep(3000);
             }
 
-            s_logger.info("Blank VM: " + vmName + " is ready for use");
+            s_logger.info("Blank VM: " + vmInternalCSName + " is ready for use");
             return true;
         }
         return false;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index cb97b26..350da93 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -1566,7 +1566,7 @@ public class VirtualMachineMO extends BaseMO {
 		HostMO hostMo = getRunningHost();
 		VirtualMachineConfigInfo vmConfigInfo = getConfigInfo();
 
-		if(!hostMo.createBlankVm(clonedVmName, 1, cpuSpeedMHz, 0, false, memoryMb, 0, vmConfigInfo.getGuestId(), morDs, false))
+		if(!hostMo.createBlankVm(clonedVmName, null, 1, cpuSpeedMHz, 0, false, memoryMb, 0, vmConfigInfo.getGuestId(), morDs, false))
 		    throw new Exception("Unable to create a blank VM");
 
 		VirtualMachineMO clonedVmMo = hostMo.findVmOnHyperHost(clonedVmName);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/059e4b2a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java
index ac14328..f7288f1 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VmwareHypervisorHost.java
@@ -46,7 +46,7 @@ public interface VmwareHypervisorHost {
 	VirtualMachineMO findVmOnPeerHyperHost(String name) throws Exception;
 	
 	boolean createVm(VirtualMachineConfigSpec vmSpec) throws Exception;
-	boolean createBlankVm(String vmName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB,
+	boolean createBlankVm(String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB,
 		String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception;
 	void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception;
 


Mime
View raw message