You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/07/03 02:46:52 UTC

[8/9] adding runbook and publican-cloudstack to docs

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ae274a4/docs/runbook/en-US/images/icon.svg
----------------------------------------------------------------------
diff --git a/docs/runbook/en-US/images/icon.svg b/docs/runbook/en-US/images/icon.svg
new file mode 100644
index 0000000..b2f16d0
--- /dev/null
+++ b/docs/runbook/en-US/images/icon.svg
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="32" height="32" id="svg3017">
+  <defs id="defs3019">
+    <linearGradient id="linearGradient2381">
+      <stop id="stop2383" style="stop-color:#ffffff;stop-opacity:1" offset="0"/>
+      <stop id="stop2385" style="stop-color:#ffffff;stop-opacity:0" offset="1"/>
+    </linearGradient>
+    <linearGradient x1="296.4996" y1="188.81061" x2="317.32471" y2="209.69398" id="linearGradient2371" xlink:href="#linearGradient2381" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.90776,0,0,0.90776,24.35648,49.24131)"/>
+  </defs>
+  <g transform="matrix(0.437808,-0.437808,0.437808,0.437808,-220.8237,43.55311)" id="g5089">
+    <path d="m 8.4382985,-6.28125 c -0.6073916,0 -4.3132985,5.94886271 -4.3132985,8.25 l 0,26.71875 c 0,0.846384 0.5818159,1.125 1.15625,1.125 l 25.5625,0 c 0.632342,0 1.125001,-0.492658 1.125,-1.125 l 0,-5.21875 0.28125,0 c 0.49684,0 0.906249,-0.409411 0.90625,-0.90625 l 0,-27.9375 c 0,-0.4968398 -0.40941,-0.90625 -0.90625,-0.90625 l -23.8117015,0 z" transform="translate(282.8327,227.1903)" id="path5091" style="fill:#5c5c4f;stroke:#000000;stroke-width:3.23021388;stroke-miterlimit:4;stroke-dasharray:none"/>
+    <rect width="27.85074" height="29.369793" rx="1.1414107" ry="1.1414107" x="286.96509" y="227.63805" id="rect5093" style="fill:#032c87"/>
+    <path d="m 288.43262,225.43675 25.2418,0 0,29.3698 -26.37615,0.0241 1.13435,-29.39394 z" id="rect5095" style="fill:#ffffff"/>
+    <path d="m 302.44536,251.73726 c 1.38691,7.85917 -0.69311,11.28365 -0.69311,11.28365 2.24384,-1.60762 3.96426,-3.47694 4.90522,-5.736 0.96708,2.19264 1.83294,4.42866 4.27443,5.98941 0,0 -1.59504,-7.2004 -1.71143,-11.53706 l -6.77511,0 z" id="path5097" style="fill:#a70000;fill-opacity:1;stroke-width:2"/>
+    <rect width="25.241802" height="29.736675" rx="0.89682275" ry="0.89682275" x="290.73544" y="220.92249" id="rect5099" style="fill:#809cc9"/>
+    <path d="m 576.47347,725.93939 6.37084,0.41502 0.4069,29.51809 c -1.89202,-1.31785 -6.85427,-3.7608 -8.26232,-1.68101 l 0,-26.76752 c 0,-0.82246 0.66212,-1.48458 1.48458,-1.48458 z" transform="matrix(0.499065,-0.866565,0,1,0,0)" id="rect5101" style="fill:#4573b3;fill-opacity:1"/>
+    <path d="m 293.2599,221.89363 20.73918,0 c 0.45101,0 0.8141,0.3631 0.8141,0.81411 0.21547,6.32836 -19.36824,21.7635 -22.36739,17.59717 l 0,-17.59717 c 0,-0.45101 0.3631,-0.81411 0.81411,-0.81411 z" id="path5103" style="opacity:0.65536726;fill:url(#linearGradient2371);fill-opacity:1"/>
+  </g>
+</svg>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ae274a4/docs/runbook/en-US/kvm.xml
----------------------------------------------------------------------
diff --git a/docs/runbook/en-US/kvm.xml b/docs/runbook/en-US/kvm.xml
new file mode 100644
index 0000000..61802a4
--- /dev/null
+++ b/docs/runbook/en-US/kvm.xml
@@ -0,0 +1,83 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % BOOK_ENTITIES SYSTEM "Runbook.ent">
+%BOOK_ENTITIES;
+]>
+<chapter id="chap-Runbook-KVM">
+  <title>KVM Setup and installation</title>
+  <para>
+    KVM is the hypervisor we'll be using - we will recover the initial setup
+    which has already been done on the hypervisor host and cover installation
+    of the agent software, you can use the same steps to add additional KVM 
+    nodes to your CloudStack environment. 
+  </para>
+  <section id="sect-Runbook-KVM-Prerequisites">
+    <title>Prerequisites</title>
+    <para>
+      We explicitly are using the management server as a compute node as well, 
+      which means that we have already performed many of the prerequisite steps
+      when setting up the management server, but we will list them here for
+      clarity. Those steps are:
+      <orderedlist>
+        <listitem>
+          <para>
+            <xref linkend="sect-Runbook-Environment-operatingsys-network" />
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            <xref linkend="sect-Runbook-Environment-operatingsys-hostname" />
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            <xref linkend="sect-Runbook-Environment-operatingsys-selinux" />
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            <xref linkend="sect-Runbook-Environment-operatingsys-ntp" />
+          </para>
+        </listitem>
+      </orderedlist>
+    </para>
+    <para>
+      You shouldn't need to do that for the management server, of course, but
+      any additional hosts will need for you to complete the above steps. 
+    </para>
+  </section>
+	
+  <section id="sect-Runbook-KVM-Installation">
+    <title>Installation</title>
+    <para>
+      You'll need to ensure that you are in the directory that was created when 
+      we extracted the the tarball. 
+      <xref linkend="sect-Runbook-Management-extraction" />
+    </para>
+    <para>
+      You'll be running <filename>./install.sh</filename> again and this time
+      choosing <option>A</option> which will install the software necessary for
+      managing a KVM node. 
+    </para>
+  </section>
+  <section id="sect-Runbook-KVM-Configuration">
+    <title>KVM Configuration</title>
+    <para>
+      KVM configuration is relatively simple at only a single item. We need to 
+      edit the QEMU VNC configuration. This is done by editing 
+      <filename>/etc/libvirt/qemu.conf</filename> and ensuring the following 
+      line is present and uncommented.
+      <screen>vnc_listen=0.0.0.0</screen>
+    </para>
+    <para>
+      You can now just restart the libvirt daemon by issuing the following command:
+      <screen><prompt># </prompt><userinput><command>service</command> libvirt restart</userinput></screen>
+    </para>
+    <para>
+      That concludes our installation and configuration of KVM, and we'll now move to using the CloudStack UI
+      for the actual configuration of our cloud. 
+    </para>
+  </section>
+
+</chapter>
+

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ae274a4/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
index 76c4e21..eb10e16 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package com.cloud.hypervisor.vmware.mo;
+package com.cloud.hypervisor.vmware.mo;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -37,64 +37,64 @@ import com.vmware.vim25.TraversalSpec;
 import com.vmware.vim25.VirtualDeviceBackingInfo;
 import com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo;
 import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo;
-
-public class DatacenterMO extends BaseMO {
-	
-	public DatacenterMO(VmwareContext context, ManagedObjectReference morDc) {
-		super(context, morDc);
-	}
-	
-	public DatacenterMO(VmwareContext context, String morType, String morValue) {
-		super(context, morType, morValue);
-	}
-	
-	public DatacenterMO(VmwareContext context, String dcName) throws Exception {
-		super(context, null);
-		
-		_mor = _context.getServiceUtil().getDecendentMoRef(_context.getRootFolder(), "Datacenter", dcName);
-		assert(_mor != null);
-	}
-	
-	public String getName() throws Exception {
-		return (String)_context.getServiceUtil().getDynamicProperty(_mor, "name");
-	}
-	
-	public void registerTemplate(ManagedObjectReference morHost, String datastoreName, 
-		String templateName, String templateFileName) throws Exception {
-		
-		ServiceUtil serviceUtil = _context.getServiceUtil();
-		
-		ManagedObjectReference morFolder = (ManagedObjectReference)serviceUtil.getDynamicProperty(
-			_mor, "vmFolder");
-		assert(morFolder != null);
-		
-		ManagedObjectReference morTask = _context.getService().registerVM_Task(
-    		 morFolder, 
-    		 String.format("[%s] %s/%s", datastoreName, templateName, templateFileName),
-    		 templateName, true, 
-    		 null, morHost);
-		
-		String result = serviceUtil.waitForTask(morTask);
-		if (!result.equalsIgnoreCase("Sucess")) {
-			throw new Exception("Unable to register template due to " + TaskMO.getTaskFailureInfo(_context, morTask));
-		} else {
-			_context.waitForTaskProgressDone(morTask);
-		}
-	}
-	
-	public VirtualMachineMO findVm(String vmName) throws Exception {
-		ObjectContent[] ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name" });
-		if(ocs != null && ocs.length > 0) {
-			for(ObjectContent oc : ocs) {
-				DynamicProperty[] props = oc.getPropSet();
-				if(props != null) {
-					for(DynamicProperty prop : props) {
-						if(prop.getVal().toString().equals(vmName))
-							return new VirtualMachineMO(_context, oc.getObj());
-					}
-				}
-			}
-		}
+
+public class DatacenterMO extends BaseMO {
+	
+	public DatacenterMO(VmwareContext context, ManagedObjectReference morDc) {
+		super(context, morDc);
+	}
+	
+	public DatacenterMO(VmwareContext context, String morType, String morValue) {
+		super(context, morType, morValue);
+	}
+	
+	public DatacenterMO(VmwareContext context, String dcName) throws Exception {
+		super(context, null);
+		
+		_mor = _context.getServiceUtil().getDecendentMoRef(_context.getRootFolder(), "Datacenter", dcName);
+		assert(_mor != null);
+	}
+	
+	public String getName() throws Exception {
+		return (String)_context.getServiceUtil().getDynamicProperty(_mor, "name");
+	}
+	
+	public void registerTemplate(ManagedObjectReference morHost, String datastoreName, 
+		String templateName, String templateFileName) throws Exception {
+		
+		ServiceUtil serviceUtil = _context.getServiceUtil();
+		
+		ManagedObjectReference morFolder = (ManagedObjectReference)serviceUtil.getDynamicProperty(
+			_mor, "vmFolder");
+		assert(morFolder != null);
+		
+		ManagedObjectReference morTask = _context.getService().registerVM_Task(
+    		 morFolder, 
+    		 String.format("[%s] %s/%s", datastoreName, templateName, templateFileName),
+    		 templateName, true, 
+    		 null, morHost);
+		
+		String result = serviceUtil.waitForTask(morTask);
+		if (!result.equalsIgnoreCase("Sucess")) {
+			throw new Exception("Unable to register template due to " + TaskMO.getTaskFailureInfo(_context, morTask));
+		} else {
+			_context.waitForTaskProgressDone(morTask);
+		}
+	}
+	
+	public VirtualMachineMO findVm(String vmName) throws Exception {
+		ObjectContent[] ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name" });
+		if(ocs != null && ocs.length > 0) {
+			for(ObjectContent oc : ocs) {
+				DynamicProperty[] props = oc.getPropSet();
+				if(props != null) {
+					for(DynamicProperty prop : props) {
+						if(prop.getVal().toString().equals(vmName))
+							return new VirtualMachineMO(_context, oc.getObj());
+					}
+				}
+			}
+		}
 		return null;
 	}
 	
@@ -132,183 +132,183 @@ public class DatacenterMO extends BaseMO {
 		}
 		return list;
 	}
-
-	public List<Pair<ManagedObjectReference, String>> getAllVmsOnDatacenter() throws Exception {
-	    List<Pair<ManagedObjectReference, String>> vms = new ArrayList<Pair<ManagedObjectReference, String>>();
-	    
-	    ObjectContent[] ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name" });
-	    if(ocs != null) {
-	        for(ObjectContent oc : ocs) {
-	            String vmName = oc.getPropSet(0).getVal().toString();
-	            vms.add(new Pair<ManagedObjectReference, String>(oc.getObj(), vmName));
-	        }
-	    }
-	    
-	    return vms;
-	}	
-	
-	public ManagedObjectReference findDatastore(String name) throws Exception {
-		assert(name != null);
-		
-		ObjectContent[] ocs = getDatastorePropertiesOnDatacenter(new String[] { "name" });
-		if(ocs != null) {
-			for(ObjectContent oc : ocs) {
-				if(oc.getPropSet(0).getVal().toString().equals(name)) {
-					return oc.getObj();
-				}
-			}
-		}
-		return null;
-	}
-	
-	public ManagedObjectReference findHost(String name) throws Exception {
-		ObjectContent[] ocs= getHostPropertiesOnDatacenterHostFolder(new String[] { "name" });
-		
-		if(ocs != null) {
-			for(ObjectContent oc : ocs) {
-				if(oc.getPropSet(0).getVal().toString().equals(name)) {
-					return oc.getObj();
-				}
-			}
-		}
-		return null;
-	}
-	
-	public ManagedObjectReference getVmFolder() throws Exception {
-		return (ManagedObjectReference)_context.getServiceUtil().getDynamicProperty(_mor, "vmFolder");
-	}
-	
-	public ObjectContent[] getHostPropertiesOnDatacenterHostFolder(String[] propertyPaths) throws Exception {
-		PropertySpec pSpec = new PropertySpec();
-		pSpec.setType("HostSystem");
-		pSpec.setPathSet(propertyPaths);
-		
-	    TraversalSpec computeResource2HostTraversal = new TraversalSpec();
-	    computeResource2HostTraversal.setType("ComputeResource");
-	    computeResource2HostTraversal.setPath("host");
-	    computeResource2HostTraversal.setName("computeResource2HostTraversal");
-		
-	    SelectionSpec recurseFolders = new SelectionSpec();
-	    recurseFolders.setName("folder2childEntity");
-	      
-	    TraversalSpec folder2childEntity = new TraversalSpec();
-	    folder2childEntity.setType("Folder");
-	    folder2childEntity.setPath("childEntity");
-	    folder2childEntity.setName(recurseFolders.getName());
-	    folder2childEntity.setSelectSet(new SelectionSpec[] { recurseFolders, computeResource2HostTraversal });
-	    
-	    TraversalSpec dc2HostFolderTraversal = new TraversalSpec();
-	    dc2HostFolderTraversal.setType("Datacenter");
-	    dc2HostFolderTraversal.setPath("hostFolder");
-	    dc2HostFolderTraversal.setName("dc2HostFolderTraversal");
-	    dc2HostFolderTraversal.setSelectSet(new SelectionSpec[] { folder2childEntity } );
-	    
-	    ObjectSpec oSpec = new ObjectSpec();
-	    oSpec.setObj(_mor);
-	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.setSelectSet(new SelectionSpec[] { dc2HostFolderTraversal });
-
-	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
-	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
-	    
-	    return _context.getService().retrieveProperties(
-	    	_context.getServiceContent().getPropertyCollector(), 
-	    	new PropertyFilterSpec[] { pfSpec }); 
-	}
-	
-	public ObjectContent[] getDatastorePropertiesOnDatacenter(String[] propertyPaths) throws Exception {
-		
-		PropertySpec pSpec = new PropertySpec();
-		pSpec.setType("Datastore");
-		pSpec.setPathSet(propertyPaths);
-		
-	    TraversalSpec dc2DatastoreTraversal = new TraversalSpec();
-	    dc2DatastoreTraversal.setType("Datacenter");
-	    dc2DatastoreTraversal.setPath("datastore");
-	    dc2DatastoreTraversal.setName("dc2DatastoreTraversal");
-	    
-	    ObjectSpec oSpec = new ObjectSpec();
-	    oSpec.setObj(_mor);
-	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.setSelectSet(new SelectionSpec[] { dc2DatastoreTraversal });
-
-	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
-	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
-	    
-	    return _context.getService().retrieveProperties(
-	    	_context.getServiceContent().getPropertyCollector(), 
-	    	new PropertyFilterSpec[] { pfSpec }); 
-	}
-	
-	public ObjectContent[] getVmPropertiesOnDatacenterVmFolder(String[] propertyPaths) throws Exception {
-		PropertySpec pSpec = new PropertySpec();
-		pSpec.setType("VirtualMachine");
-		pSpec.setPathSet(propertyPaths);
-		
-	    TraversalSpec dc2VmFolderTraversal = new TraversalSpec();
-	    dc2VmFolderTraversal.setType("Datacenter");
-	    dc2VmFolderTraversal.setPath("vmFolder");
-	    dc2VmFolderTraversal.setName("dc2VmFolderTraversal");
-	    
-	    SelectionSpec recurseFolders = new SelectionSpec();
-	    recurseFolders.setName("folder2childEntity");
-	      
-	    TraversalSpec folder2childEntity = new TraversalSpec();
-	    folder2childEntity.setType("Folder");
-	    folder2childEntity.setPath("childEntity");
-	    folder2childEntity.setName(recurseFolders.getName());
-	    folder2childEntity.setSelectSet(new SelectionSpec[] { recurseFolders });
-	    dc2VmFolderTraversal.setSelectSet(new SelectionSpec[] { folder2childEntity } );
-
-	    ObjectSpec oSpec = new ObjectSpec();
-	    oSpec.setObj(_mor);
-	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.setSelectSet(new SelectionSpec[] { dc2VmFolderTraversal });
-
-	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
-	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
-	    
-	    return _context.getService().retrieveProperties(
-	    	_context.getServiceContent().getPropertyCollector(), 
-	    	new PropertyFilterSpec[] { pfSpec }); 
-	}
-	
-	public static Pair<DatacenterMO, String> getOwnerDatacenter(VmwareContext context, 
-		ManagedObjectReference morEntity) throws Exception {
-		
-		PropertySpec pSpec = new PropertySpec();
-		pSpec.setType("Datacenter");
-		pSpec.setPathSet(new String[] { "name" });
-		
-	    TraversalSpec entityParentTraversal = new TraversalSpec();
-	    entityParentTraversal.setType("ManagedEntity");
-	    entityParentTraversal.setPath("parent");
-	    entityParentTraversal.setName("entityParentTraversal");
-	    entityParentTraversal.setSelectSet(new SelectionSpec[] { new SelectionSpec(null, null, "entityParentTraversal") });
-
-	    ObjectSpec oSpec = new ObjectSpec();
-	    oSpec.setObj(morEntity);
-	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.setSelectSet(new SelectionSpec[] { entityParentTraversal });
-
-	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
-	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
-	    
-	    ObjectContent[] ocs = context.getService().retrieveProperties(
-	    	context.getServiceContent().getPropertyCollector(), 
-	    	new PropertyFilterSpec[] { pfSpec });
-	    
-	    assert(ocs != null);
-	    assert(ocs[0].getObj() != null);
-	    assert(ocs[0].getPropSet(0) != null);
-	    assert(ocs[0].getPropSet(0).getVal() != null);
-	    
-	    String dcName = ocs[0].getPropSet(0).getVal().toString(); 
-	    return new Pair<DatacenterMO, String>(new DatacenterMO(context, ocs[0].getObj()), dcName); 
+
+	public List<Pair<ManagedObjectReference, String>> getAllVmsOnDatacenter() throws Exception {
+	    List<Pair<ManagedObjectReference, String>> vms = new ArrayList<Pair<ManagedObjectReference, String>>();
+	    
+	    ObjectContent[] ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name" });
+	    if(ocs != null) {
+	        for(ObjectContent oc : ocs) {
+	            String vmName = oc.getPropSet(0).getVal().toString();
+	            vms.add(new Pair<ManagedObjectReference, String>(oc.getObj(), vmName));
+	        }
+	    }
+	    
+	    return vms;
+	}	
+	
+	public ManagedObjectReference findDatastore(String name) throws Exception {
+		assert(name != null);
+		
+		ObjectContent[] ocs = getDatastorePropertiesOnDatacenter(new String[] { "name" });
+		if(ocs != null) {
+			for(ObjectContent oc : ocs) {
+				if(oc.getPropSet(0).getVal().toString().equals(name)) {
+					return oc.getObj();
+				}
+			}
+		}
+		return null;
+	}
+	
+	public ManagedObjectReference findHost(String name) throws Exception {
+		ObjectContent[] ocs= getHostPropertiesOnDatacenterHostFolder(new String[] { "name" });
+		
+		if(ocs != null) {
+			for(ObjectContent oc : ocs) {
+				if(oc.getPropSet(0).getVal().toString().equals(name)) {
+					return oc.getObj();
+				}
+			}
+		}
+		return null;
+	}
+	
+	public ManagedObjectReference getVmFolder() throws Exception {
+		return (ManagedObjectReference)_context.getServiceUtil().getDynamicProperty(_mor, "vmFolder");
+	}
+	
+	public ObjectContent[] getHostPropertiesOnDatacenterHostFolder(String[] propertyPaths) throws Exception {
+		PropertySpec pSpec = new PropertySpec();
+		pSpec.setType("HostSystem");
+		pSpec.setPathSet(propertyPaths);
+		
+	    TraversalSpec computeResource2HostTraversal = new TraversalSpec();
+	    computeResource2HostTraversal.setType("ComputeResource");
+	    computeResource2HostTraversal.setPath("host");
+	    computeResource2HostTraversal.setName("computeResource2HostTraversal");
+		
+	    SelectionSpec recurseFolders = new SelectionSpec();
+	    recurseFolders.setName("folder2childEntity");
+	      
+	    TraversalSpec folder2childEntity = new TraversalSpec();
+	    folder2childEntity.setType("Folder");
+	    folder2childEntity.setPath("childEntity");
+	    folder2childEntity.setName(recurseFolders.getName());
+	    folder2childEntity.setSelectSet(new SelectionSpec[] { recurseFolders, computeResource2HostTraversal });
+	    
+	    TraversalSpec dc2HostFolderTraversal = new TraversalSpec();
+	    dc2HostFolderTraversal.setType("Datacenter");
+	    dc2HostFolderTraversal.setPath("hostFolder");
+	    dc2HostFolderTraversal.setName("dc2HostFolderTraversal");
+	    dc2HostFolderTraversal.setSelectSet(new SelectionSpec[] { folder2childEntity } );
+	    
+	    ObjectSpec oSpec = new ObjectSpec();
+	    oSpec.setObj(_mor);
+	    oSpec.setSkip(Boolean.TRUE);
+	    oSpec.setSelectSet(new SelectionSpec[] { dc2HostFolderTraversal });
+
+	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
+	    
+	    return _context.getService().retrieveProperties(
+	    	_context.getServiceContent().getPropertyCollector(), 
+	    	new PropertyFilterSpec[] { pfSpec }); 
+	}
+	
+	public ObjectContent[] getDatastorePropertiesOnDatacenter(String[] propertyPaths) throws Exception {
+		
+		PropertySpec pSpec = new PropertySpec();
+		pSpec.setType("Datastore");
+		pSpec.setPathSet(propertyPaths);
+		
+	    TraversalSpec dc2DatastoreTraversal = new TraversalSpec();
+	    dc2DatastoreTraversal.setType("Datacenter");
+	    dc2DatastoreTraversal.setPath("datastore");
+	    dc2DatastoreTraversal.setName("dc2DatastoreTraversal");
+	    
+	    ObjectSpec oSpec = new ObjectSpec();
+	    oSpec.setObj(_mor);
+	    oSpec.setSkip(Boolean.TRUE);
+	    oSpec.setSelectSet(new SelectionSpec[] { dc2DatastoreTraversal });
+
+	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
+	    
+	    return _context.getService().retrieveProperties(
+	    	_context.getServiceContent().getPropertyCollector(), 
+	    	new PropertyFilterSpec[] { pfSpec }); 
+	}
+	
+	public ObjectContent[] getVmPropertiesOnDatacenterVmFolder(String[] propertyPaths) throws Exception {
+		PropertySpec pSpec = new PropertySpec();
+		pSpec.setType("VirtualMachine");
+		pSpec.setPathSet(propertyPaths);
+		
+	    TraversalSpec dc2VmFolderTraversal = new TraversalSpec();
+	    dc2VmFolderTraversal.setType("Datacenter");
+	    dc2VmFolderTraversal.setPath("vmFolder");
+	    dc2VmFolderTraversal.setName("dc2VmFolderTraversal");
+	    
+	    SelectionSpec recurseFolders = new SelectionSpec();
+	    recurseFolders.setName("folder2childEntity");
+	      
+	    TraversalSpec folder2childEntity = new TraversalSpec();
+	    folder2childEntity.setType("Folder");
+	    folder2childEntity.setPath("childEntity");
+	    folder2childEntity.setName(recurseFolders.getName());
+	    folder2childEntity.setSelectSet(new SelectionSpec[] { recurseFolders });
+	    dc2VmFolderTraversal.setSelectSet(new SelectionSpec[] { folder2childEntity } );
+
+	    ObjectSpec oSpec = new ObjectSpec();
+	    oSpec.setObj(_mor);
+	    oSpec.setSkip(Boolean.TRUE);
+	    oSpec.setSelectSet(new SelectionSpec[] { dc2VmFolderTraversal });
+
+	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
+	    
+	    return _context.getService().retrieveProperties(
+	    	_context.getServiceContent().getPropertyCollector(), 
+	    	new PropertyFilterSpec[] { pfSpec }); 
+	}
+	
+	public static Pair<DatacenterMO, String> getOwnerDatacenter(VmwareContext context, 
+		ManagedObjectReference morEntity) throws Exception {
+		
+		PropertySpec pSpec = new PropertySpec();
+		pSpec.setType("Datacenter");
+		pSpec.setPathSet(new String[] { "name" });
+		
+	    TraversalSpec entityParentTraversal = new TraversalSpec();
+	    entityParentTraversal.setType("ManagedEntity");
+	    entityParentTraversal.setPath("parent");
+	    entityParentTraversal.setName("entityParentTraversal");
+	    entityParentTraversal.setSelectSet(new SelectionSpec[] { new SelectionSpec(null, null, "entityParentTraversal") });
+
+	    ObjectSpec oSpec = new ObjectSpec();
+	    oSpec.setObj(morEntity);
+	    oSpec.setSkip(Boolean.TRUE);
+	    oSpec.setSelectSet(new SelectionSpec[] { entityParentTraversal });
+
+	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
+	    
+	    ObjectContent[] ocs = context.getService().retrieveProperties(
+	    	context.getServiceContent().getPropertyCollector(), 
+	    	new PropertyFilterSpec[] { pfSpec });
+	    
+	    assert(ocs != null);
+	    assert(ocs[0].getObj() != null);
+	    assert(ocs[0].getPropSet(0) != null);
+	    assert(ocs[0].getPropSet(0).getVal() != null);
+	    
+	    String dcName = ocs[0].getPropSet(0).getVal().toString(); 
+	    return new Pair<DatacenterMO, String>(new DatacenterMO(context, ocs[0].getObj()), dcName); 
 	}
 	
 
@@ -469,5 +469,5 @@ public class DatacenterMO extends BaseMO {
         System.out.println("Plugging NIC device into network " + networkInfo.second() + " backed by dvSwitch: "
                 + dvSwitchUuid);
         return dvPortBacking;
-    }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ae274a4/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 4ee85cb..c8e0ca1 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
@@ -889,12 +889,12 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	    if(s_logger.isTraceEnabled())
 			s_logger.trace("vCenter API trace - getHyperHostHardwareSummary() done");
 	    
-		return resourceSummary;
-	}
-	
-	@Override
-	public boolean isHyperHostConnected() throws Exception {
-    	HostRuntimeInfo runtimeInfo = (HostRuntimeInfo)_context.getServiceUtil().getDynamicProperty(_mor, "runtime");
-    	return runtimeInfo.getConnectionState() == HostSystemConnectionState.connected;
+		return resourceSummary;
+	}
+	
+	@Override
+	public boolean isHyperHostConnected() throws Exception {
+    	HostRuntimeInfo runtimeInfo = (HostRuntimeInfo)_context.getServiceUtil().getDynamicProperty(_mor, "runtime");
+    	return runtimeInfo.getConnectionState() == HostSystemConnectionState.connected;
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ae274a4/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 e475907..944d66c 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -14,8 +14,8 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-package com.cloud.hypervisor.vmware.mo;
-
+package com.cloud.hypervisor.vmware.mo;
+
 import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -62,29 +62,29 @@ import com.vmware.vim25.VirtualMachineConfigSpec;
 import com.vmware.vim25.VirtualMachineFileInfo;
 import com.vmware.vim25.VirtualMachineVideoCard;
 import com.vmware.vim25.VirtualSCSISharing;
-
-public class HypervisorHostHelper {
-    private static final Logger s_logger = Logger.getLogger(HypervisorHostHelper.class);
+
+public class HypervisorHostHelper {
+    private static final Logger s_logger = Logger.getLogger(HypervisorHostHelper.class);
     private static final int DEFAULT_LOCK_TIMEOUT_SECONDS = 600;
-    private static final String s_policyNamePrefix = "cloud.policy.";
-    
-    // make vmware-base loosely coupled with cloud-specific stuff, duplicate VLAN.UNTAGGED constant here
-    private static final String UNTAGGED_VLAN_NAME = "untagged";
-	
-	public static VirtualMachineMO findVmFromObjectContent(VmwareContext context, 
-		ObjectContent[] ocs, String name) {
-		
-		if(ocs != null && ocs.length > 0) {
-			for(ObjectContent oc : ocs) {
-				DynamicProperty prop = oc.getPropSet(0);
-				assert(prop != null);
-				if(prop.getVal().toString().equals(name))
-					return new VirtualMachineMO(context, oc.getObj());
-			}
-		}
-		return null;
+    private static final String s_policyNamePrefix = "cloud.policy.";
+    
+    // make vmware-base loosely coupled with cloud-specific stuff, duplicate VLAN.UNTAGGED constant here
+    private static final String UNTAGGED_VLAN_NAME = "untagged";
+	
+	public static VirtualMachineMO findVmFromObjectContent(VmwareContext context, 
+		ObjectContent[] ocs, String name) {
+		
+		if(ocs != null && ocs.length > 0) {
+			for(ObjectContent oc : ocs) {
+				DynamicProperty prop = oc.getPropSet(0);
+				assert(prop != null);
+				if(prop.getVal().toString().equals(name))
+					return new VirtualMachineMO(context, oc.getObj());
+			}
+		}
+		return null;
 	}
-	
+	
 	public static ManagedObjectReference findDatastoreWithBackwardsCompatibility(VmwareHypervisorHost hyperHost, String uuidName) throws Exception {
 	    ManagedObjectReference morDs = hyperHost.findDatastore(uuidName.replace("-", ""));
 	    if(morDs == null)
@@ -92,21 +92,21 @@ public class HypervisorHostHelper {
 	    
 	    return morDs;
 	}
-	
-	public static DatastoreMO getHyperHostDatastoreMO(VmwareHypervisorHost hyperHost, String datastoreName) throws Exception {
-		ObjectContent[] ocs = hyperHost.getDatastorePropertiesOnHyperHost(new String[] { "name"} );
-		if(ocs != null && ocs.length > 0) {
-    		for(ObjectContent oc : ocs) {
-		        DynamicProperty[] objProps = oc.getPropSet();
-		        if(objProps != null) {
-		        	for(DynamicProperty objProp : objProps) {
-		        		if(objProp.getVal().toString().equals(datastoreName))
-		        			return new DatastoreMO(hyperHost.getContext(), oc.getObj());
-		        	}
-		        }
-    		}
-		}
-		return null;
+	
+	public static DatastoreMO getHyperHostDatastoreMO(VmwareHypervisorHost hyperHost, String datastoreName) throws Exception {
+		ObjectContent[] ocs = hyperHost.getDatastorePropertiesOnHyperHost(new String[] { "name"} );
+		if(ocs != null && ocs.length > 0) {
+    		for(ObjectContent oc : ocs) {
+		        DynamicProperty[] objProps = oc.getPropSet();
+		        if(objProps != null) {
+		        	for(DynamicProperty objProp : objProps) {
+		        		if(objProp.getVal().toString().equals(datastoreName))
+		        			return new DatastoreMO(hyperHost.getContext(), oc.getObj());
+		        	}
+		        }
+    		}
+		}
+		return null;
 	}
 	
 	public static String getPublicNetworkNamePrefix(String vlanId) {
@@ -116,7 +116,7 @@ public class HypervisorHostHelper {
 	        return "cloud.public." + vlanId;
 	    }
 	}
-	
+	
 	public static String composeCloudNetworkName(String prefix, String vlanId, Integer networkRateMbps, String vSwitchName) {
 		StringBuffer sb = new StringBuffer(prefix);
 		if(vlanId == null || UNTAGGED_VLAN_NAME.equalsIgnoreCase(vlanId))
@@ -684,222 +684,222 @@ public class HypervisorHostHelper {
 		
 		return true;
 	}
-	
-	public static ManagedObjectReference waitForNetworkReady(HostMO hostMo,
-			String networkName, long timeOutMs) throws Exception {
-
-		ManagedObjectReference morNetwork = null;
-
-		// if portGroup is just created, getNetwork may fail to retrieve it, we
-		// need to retry
-		long startTick = System.currentTimeMillis();
-		while (System.currentTimeMillis() - startTick <= timeOutMs) {
-			morNetwork = hostMo.getNetworkMor(networkName);
-			if (morNetwork != null) {
-				break;
-			}
-
-			s_logger.info("Waiting for network " + networkName + " to be ready");
-			Thread.sleep(1000);
-		}
-
-		return morNetwork;
-	}
-	
-	public static boolean createBlankVm(VmwareHypervisorHost host, String vmName, 
-		int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB, String guestOsIdentifier, 
-		ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
-		
-		if(s_logger.isInfoEnabled())
-			s_logger.info("Create blank VM. cpuCount: " + cpuCount + ", cpuSpeed(MHz): " + cpuSpeedMHz + ", mem(Mb): " + memoryMB);
-		
-		// VM config basics
-		VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
-		vmConfig.setName(vmName);
-		VmwareHelper.setBasicVmConfig(vmConfig, cpuCount, cpuSpeedMHz, cpuReservedMHz, memoryMB, memoryReserveMB, guestOsIdentifier, limitCpuUse);
-
-		// Scsi controller
-		VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
-		scsiController.setSharedBus(VirtualSCSISharing.noSharing);
-		scsiController.setBusNumber(0);
-		scsiController.setKey(1);
-		VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
-		scsiControllerSpec.setDevice(scsiController);
-		scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
-
-		VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
-		DatastoreMO dsMo = new DatastoreMO(host.getContext(), morDs);
-		fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
-		vmConfig.setFiles(fileInfo);
-		
-		VirtualMachineVideoCard videoCard = new VirtualMachineVideoCard();
-		videoCard.setControllerKey(100);
-		videoCard.setUseAutoDetect(true);
-		
-		VirtualDeviceConfigSpec videoDeviceSpec = new VirtualDeviceConfigSpec();
-		videoDeviceSpec.setDevice(videoCard);
-		videoDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
-		
-		vmConfig.setDeviceChange(new VirtualDeviceConfigSpec[] { scsiControllerSpec, videoDeviceSpec });
-		if(host.createVm(vmConfig)) {
-			VirtualMachineMO vmMo = host.findVmOnHyperHost(vmName);
-			assert(vmMo != null);
-			
-			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);
-				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);
-				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,
-				// delay 3 seconds
-				Thread.sleep(3000);
-			}
-			
-			s_logger.info("Blank VM: " + vmName + " is ready for use");
-			return true;
-		}
-		return false;
-	}
-	
-	public static String resolveHostNameInUrl(DatacenterMO dcMo, String url) {
-		
-		s_logger.info("Resolving host name in url through vCenter, url: " + url);
-		
-		URI uri;
-		try {
-			uri = new URI(url);
-		} catch (URISyntaxException e) {
-			s_logger.warn("URISyntaxException on url " + url);
-			return url;
-		}
-		
-		String host = uri.getHost();
-		if(NetUtils.isValidIp(host)) {
-			s_logger.info("host name in url is already in IP address, url: " + url);
-			return url;
-		}
-		
-		try {
-			ManagedObjectReference morHost = dcMo.findHost(host);
-			if(morHost != null) {
+	
+	public static ManagedObjectReference waitForNetworkReady(HostMO hostMo,
+			String networkName, long timeOutMs) throws Exception {
+
+		ManagedObjectReference morNetwork = null;
+
+		// if portGroup is just created, getNetwork may fail to retrieve it, we
+		// need to retry
+		long startTick = System.currentTimeMillis();
+		while (System.currentTimeMillis() - startTick <= timeOutMs) {
+			morNetwork = hostMo.getNetworkMor(networkName);
+			if (morNetwork != null) {
+				break;
+			}
+
+			s_logger.info("Waiting for network " + networkName + " to be ready");
+			Thread.sleep(1000);
+		}
+
+		return morNetwork;
+	}
+	
+	public static boolean createBlankVm(VmwareHypervisorHost host, String vmName, 
+		int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB, String guestOsIdentifier, 
+		ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
+		
+		if(s_logger.isInfoEnabled())
+			s_logger.info("Create blank VM. cpuCount: " + cpuCount + ", cpuSpeed(MHz): " + cpuSpeedMHz + ", mem(Mb): " + memoryMB);
+		
+		// VM config basics
+		VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
+		vmConfig.setName(vmName);
+		VmwareHelper.setBasicVmConfig(vmConfig, cpuCount, cpuSpeedMHz, cpuReservedMHz, memoryMB, memoryReserveMB, guestOsIdentifier, limitCpuUse);
+
+		// Scsi controller
+		VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
+		scsiController.setSharedBus(VirtualSCSISharing.noSharing);
+		scsiController.setBusNumber(0);
+		scsiController.setKey(1);
+		VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
+		scsiControllerSpec.setDevice(scsiController);
+		scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
+
+		VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
+		DatastoreMO dsMo = new DatastoreMO(host.getContext(), morDs);
+		fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
+		vmConfig.setFiles(fileInfo);
+		
+		VirtualMachineVideoCard videoCard = new VirtualMachineVideoCard();
+		videoCard.setControllerKey(100);
+		videoCard.setUseAutoDetect(true);
+		
+		VirtualDeviceConfigSpec videoDeviceSpec = new VirtualDeviceConfigSpec();
+		videoDeviceSpec.setDevice(videoCard);
+		videoDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
+		
+		vmConfig.setDeviceChange(new VirtualDeviceConfigSpec[] { scsiControllerSpec, videoDeviceSpec });
+		if(host.createVm(vmConfig)) {
+			VirtualMachineMO vmMo = host.findVmOnHyperHost(vmName);
+			assert(vmMo != null);
+			
+			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);
+				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);
+				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,
+				// delay 3 seconds
+				Thread.sleep(3000);
+			}
+			
+			s_logger.info("Blank VM: " + vmName + " is ready for use");
+			return true;
+		}
+		return false;
+	}
+	
+	public static String resolveHostNameInUrl(DatacenterMO dcMo, String url) {
+		
+		s_logger.info("Resolving host name in url through vCenter, url: " + url);
+		
+		URI uri;
+		try {
+			uri = new URI(url);
+		} catch (URISyntaxException e) {
+			s_logger.warn("URISyntaxException on url " + url);
+			return url;
+		}
+		
+		String host = uri.getHost();
+		if(NetUtils.isValidIp(host)) {
+			s_logger.info("host name in url is already in IP address, url: " + url);
+			return url;
+		}
+		
+		try {
+			ManagedObjectReference morHost = dcMo.findHost(host);
+			if(morHost != null) {
 				HostMO hostMo = new HostMO(dcMo.getContext(), morHost);
 				String managementPortGroupName;
 				if(hostMo.getHostType() == VmwareHostType.ESXi)
 					managementPortGroupName = (String)dcMo.getContext().getStockObject("manageportgroup");
 				else
 					managementPortGroupName = (String)dcMo.getContext().getStockObject("serviceconsole");
-				
-				VmwareHypervisorHostNetworkSummary summary = hostMo.getHyperHostNetworkSummary(managementPortGroupName);
-				if(summary == null) {
-					s_logger.warn("Unable to resolve host name in url through vSphere, url: " + url);
-					return url;
-				}
-				
-				String hostIp = summary.getHostIp();
-				
-				try {
-					URI resolvedUri = new URI(uri.getScheme(), uri.getUserInfo(), hostIp, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
-					
-					s_logger.info("url " + url + " is resolved to " + resolvedUri.toString() + " through vCenter");
-					return resolvedUri.toString();
-				} catch (URISyntaxException e) {
-					assert(false);
-					return url;
-				}
-			}
-		} catch(Exception e) {
-			s_logger.warn("Unexpected exception ", e);
-		}
-		
-		return url;
-	}
-	
-	public static void importVmFromOVF(VmwareHypervisorHost host, String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption, 
-		ManagedObjectReference morRp, ManagedObjectReference morHost) throws Exception {
-		
-		assert(morRp != null);
-		
-		OvfCreateImportSpecParams importSpecParams = new OvfCreateImportSpecParams();  
-		importSpecParams.setHostSystem(morHost);  
-		importSpecParams.setLocale("US");  
-		importSpecParams.setEntityName(vmName);  
-		importSpecParams.setDeploymentOption("");
-		importSpecParams.setDiskProvisioning(diskOption); // diskOption: thin, thick, etc
-		importSpecParams.setPropertyMapping(null);
-		
-		String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
-		VmwareContext context = host.getContext();
-		OvfCreateImportSpecResult ovfImportResult = context.getService().createImportSpec(
-			context.getServiceContent().getOvfManager(), ovfDescriptor, morRp, 
-			dsMo.getMor(), importSpecParams);
-		
-		if(ovfImportResult == null) {
-			String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: " 
-				+ vmName + ", diskOption: " + diskOption;
-			s_logger.error(msg);
-			throw new Exception(msg);
-		}
-		
-		DatacenterMO dcMo = new DatacenterMO(context, host.getHyperHostDatacenter());
-		ManagedObjectReference morLease = context.getService().importVApp(morRp, 
-			ovfImportResult.getImportSpec(), dcMo.getVmFolder(), morHost);
-		if(morLease == null) {
-			String msg = "importVApp() failed. ovfFilePath: " + ovfFilePath + ", vmName: " 
-				+ vmName + ", diskOption: " + diskOption;
-			s_logger.error(msg);
-			throw new Exception(msg);
-		}
-		final HttpNfcLeaseMO leaseMo = new HttpNfcLeaseMO(context, morLease);
-		HttpNfcLeaseState state = leaseMo.waitState(
-			new HttpNfcLeaseState[] { HttpNfcLeaseState.ready, HttpNfcLeaseState.error });
-		try {
-			if(state == HttpNfcLeaseState.ready) {
-				final long totalBytes = HttpNfcLeaseMO.calcTotalBytes(ovfImportResult);
-				File ovfFile = new File(ovfFilePath); 
-				
-				HttpNfcLeaseInfo httpNfcLeaseInfo = leaseMo.getLeaseInfo();
-		        HttpNfcLeaseDeviceUrl[] deviceUrls = httpNfcLeaseInfo.getDeviceUrl();  
-		        long bytesAlreadyWritten = 0;
-		        
-		        final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter();
-		        try {
-			        for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) {
-			        	String deviceKey = deviceUrl.getImportKey();  
-			        	for (OvfFileItem ovfFileItem : ovfImportResult.getFileItem()) {
-			        		if (deviceKey.equals(ovfFileItem.getDeviceId())) {  
-			        			String absoluteFile = ovfFile.getParent() + File.separator + ovfFileItem.getPath();
-			        			String urlToPost = deviceUrl.getUrl();
-			        			urlToPost = resolveHostNameInUrl(dcMo, urlToPost);
-			        			
-		        			  	context.uploadVmdkFile(ovfFileItem.isCreate() ? "PUT" : "POST", urlToPost, absoluteFile, 
-		    			  			bytesAlreadyWritten, new ActionDelegate<Long> () {
-									public void action(Long param) {
-										progressReporter.reportProgress((int)(param * 100 / totalBytes));
-									}
-		    			  		});  
-		        			  	
-		        			  	bytesAlreadyWritten += ovfFileItem.getSize();
-		        			 }  
-			        	 }  
-			        }
-		        } finally {
-		        	progressReporter.close();
-		        }
-		        leaseMo.updateLeaseProgress(100);
-			}
-		} finally {
-			leaseMo.completeLease();
-		}
-	}
-}
+				
+				VmwareHypervisorHostNetworkSummary summary = hostMo.getHyperHostNetworkSummary(managementPortGroupName);
+				if(summary == null) {
+					s_logger.warn("Unable to resolve host name in url through vSphere, url: " + url);
+					return url;
+				}
+				
+				String hostIp = summary.getHostIp();
+				
+				try {
+					URI resolvedUri = new URI(uri.getScheme(), uri.getUserInfo(), hostIp, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
+					
+					s_logger.info("url " + url + " is resolved to " + resolvedUri.toString() + " through vCenter");
+					return resolvedUri.toString();
+				} catch (URISyntaxException e) {
+					assert(false);
+					return url;
+				}
+			}
+		} catch(Exception e) {
+			s_logger.warn("Unexpected exception ", e);
+		}
+		
+		return url;
+	}
+	
+	public static void importVmFromOVF(VmwareHypervisorHost host, String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption, 
+		ManagedObjectReference morRp, ManagedObjectReference morHost) throws Exception {
+		
+		assert(morRp != null);
+		
+		OvfCreateImportSpecParams importSpecParams = new OvfCreateImportSpecParams();  
+		importSpecParams.setHostSystem(morHost);  
+		importSpecParams.setLocale("US");  
+		importSpecParams.setEntityName(vmName);  
+		importSpecParams.setDeploymentOption("");
+		importSpecParams.setDiskProvisioning(diskOption); // diskOption: thin, thick, etc
+		importSpecParams.setPropertyMapping(null);
+		
+		String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
+		VmwareContext context = host.getContext();
+		OvfCreateImportSpecResult ovfImportResult = context.getService().createImportSpec(
+			context.getServiceContent().getOvfManager(), ovfDescriptor, morRp, 
+			dsMo.getMor(), importSpecParams);
+		
+		if(ovfImportResult == null) {
+			String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: " 
+				+ vmName + ", diskOption: " + diskOption;
+			s_logger.error(msg);
+			throw new Exception(msg);
+		}
+		
+		DatacenterMO dcMo = new DatacenterMO(context, host.getHyperHostDatacenter());
+		ManagedObjectReference morLease = context.getService().importVApp(morRp, 
+			ovfImportResult.getImportSpec(), dcMo.getVmFolder(), morHost);
+		if(morLease == null) {
+			String msg = "importVApp() failed. ovfFilePath: " + ovfFilePath + ", vmName: " 
+				+ vmName + ", diskOption: " + diskOption;
+			s_logger.error(msg);
+			throw new Exception(msg);
+		}
+		final HttpNfcLeaseMO leaseMo = new HttpNfcLeaseMO(context, morLease);
+		HttpNfcLeaseState state = leaseMo.waitState(
+			new HttpNfcLeaseState[] { HttpNfcLeaseState.ready, HttpNfcLeaseState.error });
+		try {
+			if(state == HttpNfcLeaseState.ready) {
+				final long totalBytes = HttpNfcLeaseMO.calcTotalBytes(ovfImportResult);
+				File ovfFile = new File(ovfFilePath); 
+				
+				HttpNfcLeaseInfo httpNfcLeaseInfo = leaseMo.getLeaseInfo();
+		        HttpNfcLeaseDeviceUrl[] deviceUrls = httpNfcLeaseInfo.getDeviceUrl();  
+		        long bytesAlreadyWritten = 0;
+		        
+		        final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter();
+		        try {
+			        for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) {
+			        	String deviceKey = deviceUrl.getImportKey();  
+			        	for (OvfFileItem ovfFileItem : ovfImportResult.getFileItem()) {
+			        		if (deviceKey.equals(ovfFileItem.getDeviceId())) {  
+			        			String absoluteFile = ovfFile.getParent() + File.separator + ovfFileItem.getPath();
+			        			String urlToPost = deviceUrl.getUrl();
+			        			urlToPost = resolveHostNameInUrl(dcMo, urlToPost);
+			        			
+		        			  	context.uploadVmdkFile(ovfFileItem.isCreate() ? "PUT" : "POST", urlToPost, absoluteFile, 
+		    			  			bytesAlreadyWritten, new ActionDelegate<Long> () {
+									public void action(Long param) {
+										progressReporter.reportProgress((int)(param * 100 / totalBytes));
+									}
+		    			  		});  
+		        			  	
+		        			  	bytesAlreadyWritten += ovfFileItem.getSize();
+		        			 }  
+			        	 }  
+			        }
+		        } finally {
+		        	progressReporter.close();
+		        }
+		        leaseMo.updateLeaseProgress(100);
+			}
+		} finally {
+			leaseMo.completeLease();
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ae274a4/vmware-base/src/com/cloud/hypervisor/vmware/mo/SnapshotDescriptor.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/SnapshotDescriptor.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/SnapshotDescriptor.java
index 97237ba..49747d2 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/SnapshotDescriptor.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/SnapshotDescriptor.java
@@ -204,53 +204,53 @@ public class SnapshotDescriptor {
 				info.setDisks(disks);
 				info.setDisplayName(_properties.getProperty(String.format("snapshot%d.displayName", id)));
 				l.add(info);
-			}
-			
-			current = _properties.getProperty(String.format("snapshot%d.parent", id));
-		}
-		
-		return l.toArray(new SnapshotInfo[0]);
-	}
-
-	public static class SnapshotInfo {
-		private int _id;
-		private String _displayName;
-		private int _numOfDisks;  
-		private DiskInfo[] _disks;
-		
-		public SnapshotInfo() {
-		}
-		
-		public void setId(int id) {
-			_id = id;
-		}
-		
-		public int getId() {
-			return _id;
-		}
-		
-		public void setDisplayName(String name) {
-			_displayName = name;
-		}
-		
-		public String getDisplayName() {
-			return _displayName;
-		}
-		
-		public void setNumOfDisks(int numOfDisks) {
-			_numOfDisks = numOfDisks;
-		}
-		
-		public int getNumOfDisks() {
-			return _numOfDisks;
-		}
-		
-		public void setDisks(DiskInfo[] disks) {
-			_disks = disks;
-		}
-		
-		public DiskInfo[] getDisks() {
-			return _disks;
+			}
+			
+			current = _properties.getProperty(String.format("snapshot%d.parent", id));
+		}
+		
+		return l.toArray(new SnapshotInfo[0]);
+	}
+
+	public static class SnapshotInfo {
+		private int _id;
+		private String _displayName;
+		private int _numOfDisks;  
+		private DiskInfo[] _disks;
+		
+		public SnapshotInfo() {
+		}
+		
+		public void setId(int id) {
+			_id = id;
+		}
+		
+		public int getId() {
+			return _id;
+		}
+		
+		public void setDisplayName(String name) {
+			_displayName = name;
+		}
+		
+		public String getDisplayName() {
+			return _displayName;
+		}
+		
+		public void setNumOfDisks(int numOfDisks) {
+			_numOfDisks = numOfDisks;
+		}
+		
+		public int getNumOfDisks() {
+			return _numOfDisks;
+		}
+		
+		public void setDisks(DiskInfo[] disks) {
+			_disks = disks;
+		}
+		
+		public DiskInfo[] getDisks() {
+			return _disks;
 		}
 		
 		@Override
@@ -273,29 +273,29 @@ public class SnapshotDescriptor {
 			sb.append("]}");
 			
 			return sb.toString();
-		}
-	}
-	
-	public static class DiskInfo {
-		private String _diskFileName;
-		private String _deviceName;
-		
-		public DiskInfo(String diskFileName, String deviceName) {
-			_diskFileName = diskFileName;
-			_deviceName = deviceName;
-		}
-		
-		public String getDiskFileName() {
-			return _diskFileName; 
-		}
-		
-		public String getDeviceName() {
-			return _deviceName;
+		}
+	}
+	
+	public static class DiskInfo {
+		private String _diskFileName;
+		private String _deviceName;
+		
+		public DiskInfo(String diskFileName, String deviceName) {
+			_diskFileName = diskFileName;
+			_deviceName = deviceName;
+		}
+		
+		public String getDiskFileName() {
+			return _diskFileName; 
+		}
+		
+		public String getDeviceName() {
+			return _deviceName;
 		}
 	
 		@Override
 		public String toString() {
 			return "DiskInfo: { device: " + _deviceName + ", file: " + _diskFileName + " }";
-		}
-	}
-}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ae274a4/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 a03fa54..cd54127 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -988,8 +988,8 @@ public class VirtualMachineMO extends BaseMO {
 		if(s_logger.isTraceEnabled())
 			s_logger.trace("vCenter API trace - attachDisk() done(successfully)"); 
 	}
-	
-	// vmdkDatastorePath: [datastore name] vmdkFilePath
+	
+	// vmdkDatastorePath: [datastore name] vmdkFilePath
 	public List<Pair<String, ManagedObjectReference>> detachDisk(String vmdkDatastorePath, boolean deleteBackingFile) throws Exception {
 		
 		if(s_logger.isTraceEnabled())
@@ -1701,315 +1701,315 @@ public class VirtualMachineMO extends BaseMO {
 			}
 		}
 	}
-	
-	// return pair of VirtualDisk and disk device bus name(ide0:0, etc)
-	public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean matchExactly) throws Exception {
-		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().getDynamicProperty(_mor, "config.hardware.device");
-		
-		s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath);
-		DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
-		String srcBaseName = dsSrcFile.getFileBaseName();
-		
-		if(devices != null && devices.length > 0) {
-			for(VirtualDevice device : devices) {
-				if(device instanceof VirtualDisk) {
-					s_logger.info("Test against disk device, controller key: " + device.getControllerKey() + ", unit number: " + device.getUnitNumber());
-					
-					VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
-					if(backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
-						VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
-						do {
-							s_logger.info("Test against disk backing : " + diskBackingInfo.getFileName());
-							
-							DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
-							String backingBaseName = dsBackingFile.getFileBaseName();
-							if(matchExactly) {
-								if(backingBaseName .equalsIgnoreCase(srcBaseName)) {
-									String deviceNumbering = getDeviceBusName(devices, device);
-									
-									s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
-									return new Pair<VirtualDisk, String>((VirtualDisk)device, deviceNumbering);
-								} 
-							} else {
-								if(backingBaseName.contains(srcBaseName)) {
-									String deviceNumbering = getDeviceBusName(devices, device);
-
-									s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
-									return new Pair<VirtualDisk, String>((VirtualDisk)device, deviceNumbering);
-								} 
-							}
-							
-							diskBackingInfo = diskBackingInfo.getParent();
-						} while(diskBackingInfo != null);
-					} 
-				}
-			}
-		}
-			
-		return null;
-	}
-	
-	@Deprecated
-	public List<Pair<String, ManagedObjectReference>> getDiskDatastorePathChain(VirtualDisk disk, boolean followChain) throws Exception {
-		VirtualDeviceBackingInfo backingInfo = disk.getBacking();
-		if(!(backingInfo instanceof VirtualDiskFlatVer2BackingInfo)) {
-            throw new Exception("Unsupported VirtualDeviceBackingInfo");
-        }
-
-		List<Pair<String, ManagedObjectReference>> pathList = new ArrayList<Pair<String, ManagedObjectReference>>();
-		VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
-
-		if(!followChain) {
-			pathList.add(new Pair<String, ManagedObjectReference>(diskBackingInfo.getFileName(), diskBackingInfo.getDatastore()));
-			return pathList;
-		}
-		
-		Pair<DatacenterMO, String> dcPair = getOwnerDatacenter();
-		VirtualMachineFileInfo vmFilesInfo = getFileInfo();
-		DatastoreFile snapshotDirFile = new DatastoreFile(vmFilesInfo.getSnapshotDirectory());
-		DatastoreFile vmxDirFile = new DatastoreFile(vmFilesInfo.getVmPathName());
-		
-		do {
-			if(diskBackingInfo.getParent() != null) {
-				pathList.add(new Pair<String, ManagedObjectReference>(diskBackingInfo.getFileName(), diskBackingInfo.getDatastore()));
-				diskBackingInfo = diskBackingInfo.getParent();
-			} else {
-				// try getting parent info from VMDK file itself 
-				byte[] content = null;
-				try {
-					String url = getContext().composeDatastoreBrowseUrl(dcPair.second(), diskBackingInfo.getFileName());
-					content = getContext().getResourceContent(url);
-					if(content == null || content.length == 0) {
-                        break;
-                    }
-					
-					pathList.add(new Pair<String, ManagedObjectReference>(diskBackingInfo.getFileName(), diskBackingInfo.getDatastore()));
-				} catch(Exception e) {
-					// if snapshot directory has been changed to place other than default. VMware has a bug
-					// that its corresponding disk backing info is not updated correctly. therefore, we will try search
-					// in snapshot directory one more time
-					DatastoreFile currentFile = new DatastoreFile(diskBackingInfo.getFileName());
-					String vmdkFullDsPath = snapshotDirFile.getCompanionPath(currentFile.getFileName());
-					
-					String url = getContext().composeDatastoreBrowseUrl(dcPair.second(), vmdkFullDsPath);
-					content = getContext().getResourceContent(url);
-					if(content == null || content.length == 0) {
-                        break;
-                    }
-					
-					pathList.add(new Pair<String, ManagedObjectReference>(vmdkFullDsPath, diskBackingInfo.getDatastore()));
-				}
-					
-				VmdkFileDescriptor descriptor = new VmdkFileDescriptor();
-				descriptor.parse(content);
-				if(descriptor.getParentFileName() != null && !descriptor.getParentFileName().isEmpty()) {
-					// create a fake one
-					VirtualDiskFlatVer2BackingInfo parentDiskBackingInfo = new VirtualDiskFlatVer2BackingInfo();
-					parentDiskBackingInfo.setDatastore(diskBackingInfo.getDatastore());
-					
-					String parentFileName = descriptor.getParentFileName();
-					if(parentFileName.startsWith("/")) {
-						int fileNameStartPos = parentFileName.lastIndexOf("/");
-						parentFileName = parentFileName.substring(fileNameStartPos + 1);
-						parentDiskBackingInfo.setFileName(vmxDirFile.getCompanionPath(parentFileName));
-					} else {
-						parentDiskBackingInfo.setFileName(snapshotDirFile.getCompanionPath(parentFileName));
-					}
-					diskBackingInfo = parentDiskBackingInfo;  
-				} else {
-					break;
-				}
-			}
-		} while(diskBackingInfo != null);
-		
-		return pathList;
-	}
-	
-	private String getDeviceBusName(VirtualDevice[] allDevices, VirtualDevice theDevice) throws Exception {
-		for(VirtualDevice device : allDevices) {
-			if(device.getKey() == theDevice.getControllerKey().intValue()) {
-				if(device instanceof VirtualIDEController) {
-					return String.format("ide%d:%d", ((VirtualIDEController)device).getBusNumber(), theDevice.getUnitNumber());
-				} else if(device instanceof VirtualSCSIController) {
-					return String.format("scsi%d:%d", ((VirtualSCSIController)device).getBusNumber(), theDevice.getUnitNumber());
-				} else {
-					throw new Exception("Device controller is not supported yet");
-				}
-			}
-		}
-		throw new Exception("Unable to find device controller");
-	}
-	
-	public VirtualDisk[] getAllDiskDevice() throws Exception {
-		List<VirtualDisk> deviceList = new ArrayList<VirtualDisk>();
-		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().getDynamicProperty(_mor, "config.hardware.device");
-		if(devices != null && devices.length > 0) {
-			for(VirtualDevice device : devices) {
-				if(device instanceof VirtualDisk) {
-					deviceList.add((VirtualDisk)device);
-				}
-			}
-		}
-		
-		return deviceList.toArray(new VirtualDisk[0]);
-	}
-
-	public VirtualDisk[] getAllIndependentDiskDevice() throws Exception {
-		List<VirtualDisk> independentDisks = new ArrayList<VirtualDisk>();
-		VirtualDisk[] allDisks = getAllDiskDevice();
-		if(allDisks.length > 0) {
-			for(VirtualDisk disk : allDisks) {
-	            String diskMode = "";
-	            if(disk.getBacking() instanceof VirtualDiskFlatVer1BackingInfo) {
-	            	diskMode = ((VirtualDiskFlatVer1BackingInfo)disk.getBacking()).getDiskMode();
-				} else if(disk.getBacking() instanceof VirtualDiskFlatVer2BackingInfo) {
-					diskMode = ((VirtualDiskFlatVer2BackingInfo)disk.getBacking()).getDiskMode();
-				} else if(disk.getBacking() instanceof VirtualDiskRawDiskMappingVer1BackingInfo) {
-					diskMode = ((VirtualDiskRawDiskMappingVer1BackingInfo)disk.getBacking()).getDiskMode();
-				} else if(disk.getBacking() instanceof VirtualDiskSparseVer1BackingInfo) {
-					diskMode = ((VirtualDiskSparseVer1BackingInfo)disk.getBacking()).getDiskMode();
-				} else if(disk.getBacking() instanceof VirtualDiskSparseVer2BackingInfo) {
-					diskMode = ((VirtualDiskSparseVer2BackingInfo)disk.getBacking()).getDiskMode();
-				}
-	            
-				if(diskMode.indexOf("independent") != -1) {
-					independentDisks.add(disk);
-				}
-			}
-		}
-		
-		return independentDisks.toArray(new VirtualDisk[0]);
-	}
-	
-	public int tryGetIDEDeviceControllerKey() throws Exception {
-	    VirtualDevice[] devices = (VirtualDevice [])_context.getServiceUtil().
-    		getDynamicProperty(_mor, "config.hardware.device");
-	
-	    if(devices != null && devices.length > 0) {
-	    	for(VirtualDevice device : devices) {
-	    		if(device instanceof VirtualIDEController) {
-	    			return ((VirtualIDEController)device).getKey();
-	    		}
-	    	}
-	    }
-	    
-		return -1;
-	}
-	
-	public int getIDEDeviceControllerKey() throws Exception {
-	    VirtualDevice[] devices = (VirtualDevice [])_context.getServiceUtil().
-	    	getDynamicProperty(_mor, "config.hardware.device");
-		
-	    if(devices != null && devices.length > 0) {
-	    	for(VirtualDevice device : devices) {
-	    		if(device instanceof VirtualIDEController) {
-	    			return ((VirtualIDEController)device).getKey();
-	    		}
-	    	}
-	    }
-	
-	    assert(false);
-	    throw new Exception("IDE Controller Not Found");
-	}
-	
-	public int getNextIDEDeviceNumber() throws Exception {
-		int controllerKey = getIDEDeviceControllerKey();
-		return getNextDeviceNumber(controllerKey);
-	}
-	
-	public VirtualDevice getIsoDevice() throws Exception {
-		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
-			getDynamicProperty(_mor, "config.hardware.device");
-		if(devices != null && devices.length > 0) {
-			for(VirtualDevice device : devices) {
-				if(device instanceof VirtualCdrom) {
-					return device;
-				}
-			}
-		}
-		return null;
-	}
-	
-	public int getPCIDeviceControllerKey() throws Exception {
-	    VirtualDevice[] devices = (VirtualDevice [])_context.getServiceUtil().
-	        getDynamicProperty(_mor, "config.hardware.device");
-	
-	    if(devices != null && devices.length > 0) {
-	    	for(VirtualDevice device : devices) {
-	    		if(device instanceof VirtualPCIController) {
-	    			return ((VirtualPCIController)device).getKey();
-	    		}
-	    	}
-	    }
-	    
-	    assert(false);
-	    throw new Exception("PCI Controller Not Found");
-	}
-	
-	public int getNextPCIDeviceNumber() throws Exception {
-		int controllerKey = getPCIDeviceControllerKey();
-		return getNextDeviceNumber(controllerKey);
-	}
-	
-	public int getNextDeviceNumber(int controllerKey) throws Exception {
-		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
-			getDynamicProperty(_mor, "config.hardware.device");
-		
-		int deviceNumber = -1;
-		if(devices != null && devices.length > 0) {
-			for(VirtualDevice device : devices) {
-				if(device.getControllerKey() != null && device.getControllerKey().intValue() == controllerKey) {
-					if(device.getUnitNumber() != null && device.getUnitNumber().intValue() > deviceNumber) {
-                        deviceNumber = device.getUnitNumber().intValue();
-                    }
-				}
-			}
-		}
-		return ++deviceNumber;
-	}
-	
-	public VirtualDevice[] getNicDevices() throws Exception {
-		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
-			getDynamicProperty(_mor, "config.hardware.device");
-		
-		List<VirtualDevice> nics = new ArrayList<VirtualDevice>();
-		if(devices != null) {
-			for(VirtualDevice device : devices) {
-				if(device instanceof VirtualEthernetCard) {
-                    nics.add(device);
-                }
-			}
-		}
-		
-		return nics.toArray(new VirtualDevice[0]);
-	}
-	
-	public Pair<Integer, VirtualDevice> getNicDeviceIndex(String networkNamePrefix) throws Exception {
-        VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
-        getDynamicProperty(_mor, "config.hardware.device");
-        
-        List<VirtualDevice> nics = new ArrayList<VirtualDevice>();
-        if(devices != null) {
-            for(VirtualDevice device : devices) {
-                if(device instanceof VirtualEthernetCard) {
-                    nics.add(device);
-                }
-            }
-        }
-        
-        Collections.sort(nics, new Comparator<VirtualDevice>() {
-            @Override
-            public int compare(VirtualDevice arg0, VirtualDevice arg1) {
-                int unitNumber0 = arg0.getUnitNumber() != null ? arg0.getUnitNumber().intValue() : -1;
-                int unitNumber1 = arg1.getUnitNumber() != null ? arg1.getUnitNumber().intValue() : -1;
-                if(unitNumber0 < unitNumber1)
-                    return -1;
-                else if(unitNumber0 > unitNumber1)
-                    return 1;
-                return 0;
-            }
+	
+	// return pair of VirtualDisk and disk device bus name(ide0:0, etc)
+	public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean matchExactly) throws Exception {
+		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().getDynamicProperty(_mor, "config.hardware.device");
+		
+		s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath);
+		DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
+		String srcBaseName = dsSrcFile.getFileBaseName();
+		
+		if(devices != null && devices.length > 0) {
+			for(VirtualDevice device : devices) {
+				if(device instanceof VirtualDisk) {
+					s_logger.info("Test against disk device, controller key: " + device.getControllerKey() + ", unit number: " + device.getUnitNumber());
+					
+					VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
+					if(backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
+						VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
+						do {
+							s_logger.info("Test against disk backing : " + diskBackingInfo.getFileName());
+							
+							DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
+							String backingBaseName = dsBackingFile.getFileBaseName();
+							if(matchExactly) {
+								if(backingBaseName .equalsIgnoreCase(srcBaseName)) {
+									String deviceNumbering = getDeviceBusName(devices, device);
+									
+									s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
+									return new Pair<VirtualDisk, String>((VirtualDisk)device, deviceNumbering);
+								} 
+							} else {
+								if(backingBaseName.contains(srcBaseName)) {
+									String deviceNumbering = getDeviceBusName(devices, device);
+
+									s_logger.info("Disk backing : " + diskBackingInfo.getFileName() + " matches ==> " + deviceNumbering);
+									return new Pair<VirtualDisk, String>((VirtualDisk)device, deviceNumbering);
+								} 
+							}
+							
+							diskBackingInfo = diskBackingInfo.getParent();
+						} while(diskBackingInfo != null);
+					} 
+				}
+			}
+		}
+			
+		return null;
+	}
+	
+	@Deprecated
+	public List<Pair<String, ManagedObjectReference>> getDiskDatastorePathChain(VirtualDisk disk, boolean followChain) throws Exception {
+		VirtualDeviceBackingInfo backingInfo = disk.getBacking();
+		if(!(backingInfo instanceof VirtualDiskFlatVer2BackingInfo)) {
+            throw new Exception("Unsupported VirtualDeviceBackingInfo");
+        }
+
+		List<Pair<String, ManagedObjectReference>> pathList = new ArrayList<Pair<String, ManagedObjectReference>>();
+		VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
+
+		if(!followChain) {
+			pathList.add(new Pair<String, ManagedObjectReference>(diskBackingInfo.getFileName(), diskBackingInfo.getDatastore()));
+			return pathList;
+		}
+		
+		Pair<DatacenterMO, String> dcPair = getOwnerDatacenter();
+		VirtualMachineFileInfo vmFilesInfo = getFileInfo();
+		DatastoreFile snapshotDirFile = new DatastoreFile(vmFilesInfo.getSnapshotDirectory());
+		DatastoreFile vmxDirFile = new DatastoreFile(vmFilesInfo.getVmPathName());
+		
+		do {
+			if(diskBackingInfo.getParent() != null) {
+				pathList.add(new Pair<String, ManagedObjectReference>(diskBackingInfo.getFileName(), diskBackingInfo.getDatastore()));
+				diskBackingInfo = diskBackingInfo.getParent();
+			} else {
+				// try getting parent info from VMDK file itself 
+				byte[] content = null;
+				try {
+					String url = getContext().composeDatastoreBrowseUrl(dcPair.second(), diskBackingInfo.getFileName());
+					content = getContext().getResourceContent(url);
+					if(content == null || content.length == 0) {
+                        break;
+                    }
+					
+					pathList.add(new Pair<String, ManagedObjectReference>(diskBackingInfo.getFileName(), diskBackingInfo.getDatastore()));
+				} catch(Exception e) {
+					// if snapshot directory has been changed to place other than default. VMware has a bug
+					// that its corresponding disk backing info is not updated correctly. therefore, we will try search
+					// in snapshot directory one more time
+					DatastoreFile currentFile = new DatastoreFile(diskBackingInfo.getFileName());
+					String vmdkFullDsPath = snapshotDirFile.getCompanionPath(currentFile.getFileName());
+					
+					String url = getContext().composeDatastoreBrowseUrl(dcPair.second(), vmdkFullDsPath);
+					content = getContext().getResourceContent(url);
+					if(content == null || content.length == 0) {
+                        break;
+                    }
+					
+					pathList.add(new Pair<String, ManagedObjectReference>(vmdkFullDsPath, diskBackingInfo.getDatastore()));
+				}
+					
+				VmdkFileDescriptor descriptor = new VmdkFileDescriptor();
+				descriptor.parse(content);
+				if(descriptor.getParentFileName() != null && !descriptor.getParentFileName().isEmpty()) {
+					// create a fake one
+					VirtualDiskFlatVer2BackingInfo parentDiskBackingInfo = new VirtualDiskFlatVer2BackingInfo();
+					parentDiskBackingInfo.setDatastore(diskBackingInfo.getDatastore());
+					
+					String parentFileName = descriptor.getParentFileName();
+					if(parentFileName.startsWith("/")) {
+						int fileNameStartPos = parentFileName.lastIndexOf("/");
+						parentFileName = parentFileName.substring(fileNameStartPos + 1);
+						parentDiskBackingInfo.setFileName(vmxDirFile.getCompanionPath(parentFileName));
+					} else {
+						parentDiskBackingInfo.setFileName(snapshotDirFile.getCompanionPath(parentFileName));
+					}
+					diskBackingInfo = parentDiskBackingInfo;  
+				} else {
+					break;
+				}
+			}
+		} while(diskBackingInfo != null);
+		
+		return pathList;
+	}
+	
+	private String getDeviceBusName(VirtualDevice[] allDevices, VirtualDevice theDevice) throws Exception {
+		for(VirtualDevice device : allDevices) {
+			if(device.getKey() == theDevice.getControllerKey().intValue()) {
+				if(device instanceof VirtualIDEController) {
+					return String.format("ide%d:%d", ((VirtualIDEController)device).getBusNumber(), theDevice.getUnitNumber());
+				} else if(device instanceof VirtualSCSIController) {
+					return String.format("scsi%d:%d", ((VirtualSCSIController)device).getBusNumber(), theDevice.getUnitNumber());
+				} else {
+					throw new Exception("Device controller is not supported yet");
+				}
+			}
+		}
+		throw new Exception("Unable to find device controller");
+	}
+	
+	public VirtualDisk[] getAllDiskDevice() throws Exception {
+		List<VirtualDisk> deviceList = new ArrayList<VirtualDisk>();
+		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().getDynamicProperty(_mor, "config.hardware.device");
+		if(devices != null && devices.length > 0) {
+			for(VirtualDevice device : devices) {
+				if(device instanceof VirtualDisk) {
+					deviceList.add((VirtualDisk)device);
+				}
+			}
+		}
+		
+		return deviceList.toArray(new VirtualDisk[0]);
+	}
+
+	public VirtualDisk[] getAllIndependentDiskDevice() throws Exception {
+		List<VirtualDisk> independentDisks = new ArrayList<VirtualDisk>();
+		VirtualDisk[] allDisks = getAllDiskDevice();
+		if(allDisks.length > 0) {
+			for(VirtualDisk disk : allDisks) {
+	            String diskMode = "";
+	            if(disk.getBacking() instanceof VirtualDiskFlatVer1BackingInfo) {
+	            	diskMode = ((VirtualDiskFlatVer1BackingInfo)disk.getBacking()).getDiskMode();
+				} else if(disk.getBacking() instanceof VirtualDiskFlatVer2BackingInfo) {
+					diskMode = ((VirtualDiskFlatVer2BackingInfo)disk.getBacking()).getDiskMode();
+				} else if(disk.getBacking() instanceof VirtualDiskRawDiskMappingVer1BackingInfo) {
+					diskMode = ((VirtualDiskRawDiskMappingVer1BackingInfo)disk.getBacking()).getDiskMode();
+				} else if(disk.getBacking() instanceof VirtualDiskSparseVer1BackingInfo) {
+					diskMode = ((VirtualDiskSparseVer1BackingInfo)disk.getBacking()).getDiskMode();
+				} else if(disk.getBacking() instanceof VirtualDiskSparseVer2BackingInfo) {
+					diskMode = ((VirtualDiskSparseVer2BackingInfo)disk.getBacking()).getDiskMode();
+				}
+	            
+				if(diskMode.indexOf("independent") != -1) {
+					independentDisks.add(disk);
+				}
+			}
+		}
+		
+		return independentDisks.toArray(new VirtualDisk[0]);
+	}
+	
+	public int tryGetIDEDeviceControllerKey() throws Exception {
+	    VirtualDevice[] devices = (VirtualDevice [])_context.getServiceUtil().
+    		getDynamicProperty(_mor, "config.hardware.device");
+	
+	    if(devices != null && devices.length > 0) {
+	    	for(VirtualDevice device : devices) {
+	    		if(device instanceof VirtualIDEController) {
+	    			return ((VirtualIDEController)device).getKey();
+	    		}
+	    	}
+	    }
+	    
+		return -1;
+	}
+	
+	public int getIDEDeviceControllerKey() throws Exception {
+	    VirtualDevice[] devices = (VirtualDevice [])_context.getServiceUtil().
+	    	getDynamicProperty(_mor, "config.hardware.device");
+		
+	    if(devices != null && devices.length > 0) {
+	    	for(VirtualDevice device : devices) {
+	    		if(device instanceof VirtualIDEController) {
+	    			return ((VirtualIDEController)device).getKey();
+	    		}
+	    	}
+	    }
+	
+	    assert(false);
+	    throw new Exception("IDE Controller Not Found");
+	}
+	
+	public int getNextIDEDeviceNumber() throws Exception {
+		int controllerKey = getIDEDeviceControllerKey();
+		return getNextDeviceNumber(controllerKey);
+	}
+	
+	public VirtualDevice getIsoDevice() throws Exception {
+		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
+			getDynamicProperty(_mor, "config.hardware.device");
+		if(devices != null && devices.length > 0) {
+			for(VirtualDevice device : devices) {
+				if(device instanceof VirtualCdrom) {
+					return device;
+				}
+			}
+		}
+		return null;
+	}
+	
+	public int getPCIDeviceControllerKey() throws Exception {
+	    VirtualDevice[] devices = (VirtualDevice [])_context.getServiceUtil().
+	        getDynamicProperty(_mor, "config.hardware.device");
+	
+	    if(devices != null && devices.length > 0) {
+	    	for(VirtualDevice device : devices) {
+	    		if(device instanceof VirtualPCIController) {
+	    			return ((VirtualPCIController)device).getKey();
+	    		}
+	    	}
+	    }
+	    
+	    assert(false);
+	    throw new Exception("PCI Controller Not Found");
+	}
+	
+	public int getNextPCIDeviceNumber() throws Exception {
+		int controllerKey = getPCIDeviceControllerKey();
+		return getNextDeviceNumber(controllerKey);
+	}
+	
+	public int getNextDeviceNumber(int controllerKey) throws Exception {
+		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
+			getDynamicProperty(_mor, "config.hardware.device");
+		
+		int deviceNumber = -1;
+		if(devices != null && devices.length > 0) {
+			for(VirtualDevice device : devices) {
+				if(device.getControllerKey() != null && device.getControllerKey().intValue() == controllerKey) {
+					if(device.getUnitNumber() != null && device.getUnitNumber().intValue() > deviceNumber) {
+                        deviceNumber = device.getUnitNumber().intValue();
+                    }
+				}
+			}
+		}
+		return ++deviceNumber;
+	}
+	
+	public VirtualDevice[] getNicDevices() throws Exception {
+		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
+			getDynamicProperty(_mor, "config.hardware.device");
+		
+		List<VirtualDevice> nics = new ArrayList<VirtualDevice>();
+		if(devices != null) {
+			for(VirtualDevice device : devices) {
+				if(device instanceof VirtualEthernetCard) {
+                    nics.add(device);
+                }
+			}
+		}
+		
+		return nics.toArray(new VirtualDevice[0]);
+	}
+	
+	public Pair<Integer, VirtualDevice> getNicDeviceIndex(String networkNamePrefix) throws Exception {
+        VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
+        getDynamicProperty(_mor, "config.hardware.device");
+        
+        List<VirtualDevice> nics = new ArrayList<VirtualDevice>();
+        if(devices != null) {
+            for(VirtualDevice device : devices) {
+                if(device instanceof VirtualEthernetCard) {
+                    nics.add(device);
+                }
+            }
+        }
+        
+        Collections.sort(nics, new Comparator<VirtualDevice>() {
+            @Override
+            public int compare(VirtualDevice arg0, VirtualDevice arg1) {
+                int unitNumber0 = arg0.getUnitNumber() != null ? arg0.getUnitNumber().intValue() : -1;
+                int unitNumber1 = arg1.getUnitNumber() != null ? arg1.getUnitNumber().intValue() : -1;
+                if(unitNumber0 < unitNumber1)
+                    return -1;
+                else if(unitNumber0 > unitNumber1)
+                    return 1;
+                return 0;
+            }
         });
-        
+        
         int index = 0;
         String attachedNetworkSummary;
         String dvPortGroupName;
@@ -2039,38 +2039,38 @@ public class VirtualMachineMO extends BaseMO {
         dvPortGroupMor.setType("DistributedVirtualPortgroup");
         return (String) _context.getServiceUtil().getDynamicProperty(dvPortGroupMor, "name");
     }
-
-	public VirtualDevice[] getMatchedDevices(Class<?>[] deviceClasses) throws Exception {
-		assert(deviceClasses != null);
-		
-		List<VirtualDevice> returnList = new ArrayList<VirtualDevice>();
-		
-		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
-			getDynamicProperty(_mor, "config.hardware.device");
-		
-		if(devices != null) {
-			for(VirtualDevice device : devices) {
-				for(Class<?> clz : deviceClasses) {
-					if(clz.isInstance(device)) {
-						returnList.add(device);
-						break;
-					}
-				}
-			}
-		}
-	
-		return returnList.toArray(new VirtualDevice[0]);
-	}
-	
-	public void mountToolsInstaller() throws Exception {
-		_context.getService().mountToolsInstaller(_mor);
-	}
-	
-	public void unmountToolsInstaller() throws Exception {
-		_context.getService().unmountToolsInstaller(_mor);
-	}
-	
-	public void redoRegistration(ManagedObjectReference morHost) throws Exception {
+
+	public VirtualDevice[] getMatchedDevices(Class<?>[] deviceClasses) throws Exception {
+		assert(deviceClasses != null);
+		
+		List<VirtualDevice> returnList = new ArrayList<VirtualDevice>();
+		
+		VirtualDevice[] devices = (VirtualDevice[])_context.getServiceUtil().
+			getDynamicProperty(_mor, "config.hardware.device");
+		
+		if(devices != null) {
+			for(VirtualDevice device : devices) {
+				for(Class<?> clz : deviceClasses) {
+					if(clz.isInstance(device)) {
+						returnList.add(device);
+						break;
+					}
+				}
+			}
+		}
+	
+		return returnList.toArray(new VirtualDevice[0]);
+	}
+	
+	public void mountToolsInstaller() throws Exception {
+		_context.getService().mountToolsInstaller(_mor);
+	}
+	
+	public void unmountToolsInstaller() throws Exception {
+		_context.getService().unmountToolsInstaller(_mor);
+	}
+	
+	public void redoRegistration(ManagedObjectReference morHost) throws Exception {
 		String vmName = getVmName();
 		VirtualMachineFileInfo vmFileInfo = getFileInfo();
 		boolean isTemplate = isTemplate();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3ae274a4/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualSwitchType.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualSwitchType.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualSwitchType.java
index 2290f7c..d6226ff 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualSwitchType.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualSwitchType.java
@@ -14,11 +14,11 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-
-package com.cloud.hypervisor.vmware.mo;
-
-public enum VirtualSwitchType {
-	StandardVirtualSwitch,
-	VMwareDistributedVirtualSwitch,
-	NexusDistributedVirtualSwitch,
-}
+
+package com.cloud.hypervisor.vmware.mo;
+
+public enum VirtualSwitchType {
+	StandardVirtualSwitch,
+	VMwareDistributedVirtualSwitch,
+	NexusDistributedVirtualSwitch,
+}