cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke4...@apache.org
Subject [48/50] git commit: CS-9919 Support for Nexus Swiches (Cisco Vswitches)
Date Sun, 27 May 2012 22:30:44 GMT
CS-9919 Support for Nexus Swiches (Cisco Vswitches)

Description:

	Moved dvSwitch specific functionality over datacenter.

Conflicts:

	vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
	vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java


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

Branch: refs/heads/master
Commit: aa1f26cb00d2fe1f994b481bb70c5f2d8267c6d9
Parents: 04898a0
Author: Sateesh Chodapuneedi <sateesh.chodapuneedi@citrix.com>
Authored: Thu May 10 18:35:44 2012 +0530
Committer: Vijayendra Bhamidipati <vijayendra.bhamidipati@citrix.com>
Committed: Fri May 25 17:35:50 2012 -0700

----------------------------------------------------------------------
 .../cloud/hypervisor/vmware/mo/DatacenterMO.java   |  508 +++++++++------
 .../src/com/cloud/hypervisor/vmware/mo/HostMO.java |   93 ---
 .../hypervisor/vmware/mo/HypervisorHostHelper.java |   20 +-
 3 files changed, 313 insertions(+), 308 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/aa1f26cb/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 7c57350..30d5b1d 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
@@ -10,7 +10,8 @@
 // limitations under the License.
 // 
 // Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.hypervisor.vmware.mo;
+
+package com.cloud.hypervisor.vmware.mo;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -19,6 +20,7 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.utils.Pair;
 import com.vmware.apputils.vim25.ServiceUtil;
 import com.vmware.vim25.CustomFieldStringValue;
+import com.vmware.vim25.DVPortgroupConfigInfo;
 import com.vmware.vim25.DynamicProperty;
 import com.vmware.vim25.ManagedObjectReference;
 import com.vmware.vim25.ObjectContent;
@@ -27,64 +29,64 @@ import com.vmware.vim25.PropertyFilterSpec;
 import com.vmware.vim25.PropertySpec;
 import com.vmware.vim25.SelectionSpec;
 import com.vmware.vim25.TraversalSpec;
-
-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;
 	}
 	
@@ -122,182 +124,274 @@ 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 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 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);
+
+	public ManagedObjectReference getDvPortGroupMor(String dvPortGroupName) throws Exception
{
+    		PropertySpec pSpec = new PropertySpec();
+		pSpec.setType("DistributedVirtualPortgroup");
+		pSpec.setPathSet(new String[] {"name"});
 		
-	    TraversalSpec computeResource2HostTraversal = new TraversalSpec();
-	    computeResource2HostTraversal.setType("ComputeResource");
-	    computeResource2HostTraversal.setPath("host");
-	    computeResource2HostTraversal.setName("computeResource2HostTraversal");
+		TraversalSpec datacenter2DvPortGroupTraversal = new TraversalSpec();
+		datacenter2DvPortGroupTraversal.setType("Datacenter");
+		datacenter2DvPortGroupTraversal.setPath("network");
+		datacenter2DvPortGroupTraversal.setName("datacenter2DvPortgroupTraversal");
 		
-	    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();
+		ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.setSelectSet(new SelectionSpec[] { dc2HostFolderTraversal });
+	    oSpec.setSelectSet(new SelectionSpec[] { datacenter2DvPortGroupTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
 	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
 	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    
-	    return _context.getService().retrieveProperties(
+	    ObjectContent[] ocs = _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");
+	    	new PropertyFilterSpec[] { pfSpec });
 	    
-	    ObjectSpec oSpec = new ObjectSpec();
-	    oSpec.setObj(_mor);
-	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.setSelectSet(new SelectionSpec[] { dc2DatastoreTraversal });
+	    if(ocs != null) {
+	    	for(ObjectContent oc : ocs) {
+	    		DynamicProperty[] props = oc.getPropSet();
+	    		if(props != null) {
+	    			for(DynamicProperty prop : props) {
+	    				if(prop.getVal().equals(dvPortGroupName))
+	    					return oc.getObj();
+	    			}
+	    		}
+	    	}
+	    }
+	    return null;
+	}	
 
-	    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 boolean hasDvPortGroup(String dvPortGroupName) throws Exception {
+		ManagedObjectReference morNetwork = getDvPortGroupMor(dvPortGroupName);
+		if(morNetwork != null)
+			return true;
+		return false;		
 	}
 	
-	public ObjectContent[] getVmPropertiesOnDatacenterVmFolder(String[] propertyPaths) throws
Exception {
+	public DVPortgroupConfigInfo getDvPortGroupSpec(String dvPortGroupName) throws Exception
{
+		DVPortgroupConfigInfo configSpec = null;
+		String nameProperty = null;
 		PropertySpec pSpec = new PropertySpec();
-		pSpec.setType("VirtualMachine");
-		pSpec.setPathSet(propertyPaths);
+		pSpec.setType("DistributedVirtualPortgroup");
+		pSpec.setPathSet(new String[] {"name", "config"});
 		
-	    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 } );
+	    TraversalSpec datacenter2DvPortGroupTraversal = new TraversalSpec();
+	    datacenter2DvPortGroupTraversal.setType("Datacenter");
+	    datacenter2DvPortGroupTraversal.setPath("network");
+	    datacenter2DvPortGroupTraversal.setName("datacenter2DvPortgroupTraversal");
 
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.setSelectSet(new SelectionSpec[] { dc2VmFolderTraversal });
+	    oSpec.setSelectSet(new SelectionSpec[] { datacenter2DvPortGroupTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
 	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
 	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    
-	    return _context.getService().retrieveProperties(
+	    ObjectContent[] ocs = _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); 
-	}
+	    if(ocs != null) {
+	    	for(ObjectContent oc : ocs) {
+	    		DynamicProperty[] props = oc.getPropSet();
+	    		if(props != null) {
+	    			assert(props.length == 2);
+	    			for(DynamicProperty prop : props) {
+	    				if(prop.getName().equals("config")) {
+	    					  configSpec = (DVPortgroupConfigInfo) prop.getVal();
+	    				}
+	    				else {
+	    					nameProperty = prop.getVal().toString();
+	    				}
+	    			}
+	    			if(nameProperty.equalsIgnoreCase(dvPortGroupName)) {
+	    				return configSpec;	    			
+	    			}
+	    		}
+	    	}
+	    }
+	    return null;
+	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/aa1f26cb/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 8ea4c5f..03293e2 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
@@ -27,9 +27,7 @@ import com.vmware.apputils.vim25.ServiceUtil;
 import com.vmware.vim25.AboutInfo;
 import com.vmware.vim25.ClusterDasConfigInfo;
 import com.vmware.vim25.ComputeResourceSummary;
-import com.vmware.vim25.DVPortgroupConfigSpec;
 import com.vmware.vim25.DatastoreSummary;
-import com.vmware.vim25.DistributedVirtualSwitchInfo;
 import com.vmware.vim25.DynamicProperty;
 import com.vmware.vim25.HostConfigManager;
 import com.vmware.vim25.HostConnectInfo;
@@ -895,95 +893,4 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
     	HostRuntimeInfo runtimeInfo = (HostRuntimeInfo)_context.getServiceUtil().getDynamicProperty(_mor,
"runtime");
     	return runtimeInfo.getConnectionState() == HostSystemConnectionState.connected;
 	}
-	
-	public DVPortgroupConfigSpec getDvPortGroupSpec(String dvPortGroupName) throws Exception
{
-		DVPortgroupConfigSpec configSpec = null;
-		String nameProperty = null;
-		PropertySpec pSpec = new PropertySpec();
-		pSpec.setType("DistributedVirtualPortgroup");
-		pSpec.setPathSet(new String[] {"summary.name", "config"});
-		
-	    TraversalSpec host2DvPortGroupTraversal = new TraversalSpec();
-	    host2DvPortGroupTraversal.setType("HostSystem");
-	    host2DvPortGroupTraversal.setPath("network");
-	    host2DvPortGroupTraversal.setName("host2DvPortgroupTraversal");
-
-	    ObjectSpec oSpec = new ObjectSpec();
-	    oSpec.setObj(_mor);
-	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.setSelectSet(new SelectionSpec[] { host2DvPortGroupTraversal });
-
-	    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 });
-	    
-	    if(ocs != null) {
-	    	for(ObjectContent oc : ocs) {
-	    		DynamicProperty[] props = oc.getPropSet();
-	    		if(props != null) {
-	    			assert(props.length == 2);
-	    			for(DynamicProperty prop : props) {
-	    				if(prop.getName().equals("config")) {
-	    					  configSpec = (DVPortgroupConfigSpec) prop.getVal();
-	    				}
-	    				else {
-	    					nameProperty = prop.getVal().toString();
-	    				}
-	    				if(nameProperty.equalsIgnoreCase(dvPortGroupName)) {
-	    					return configSpec;
-	    				}
-	    			}
-	    		}
-	    	}
-	    }
-	    return null;
-	}
-	
-	public ManagedObjectReference getDvPortGroupMor(String dvPortGroupName) throws Exception
{
-		PropertySpec pSpec = new PropertySpec();
-		pSpec.setType("DistributedVirtualPortgroup");
-		pSpec.setPathSet(new String[] {"summary.name"});
-		
-	    TraversalSpec host2DvPortGroupTraversal = new TraversalSpec();
-	    host2DvPortGroupTraversal.setType("HostSystem");
-	    host2DvPortGroupTraversal.setPath("network");
-	    host2DvPortGroupTraversal.setName("host2DvPortgroupTraversal");
-
-	    ObjectSpec oSpec = new ObjectSpec();
-	    oSpec.setObj(_mor);
-	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.setSelectSet(new SelectionSpec[] { host2DvPortGroupTraversal });
-
-	    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 });
-	    
-	    if(ocs != null) {
-	    	for(ObjectContent oc : ocs) {
-	    		DynamicProperty[] props = oc.getPropSet();
-	    		if(props != null) {
-	    			for(DynamicProperty prop : props) {
-	    				if(prop.getVal().equals(dvPortGroupName))
-	    					return oc.getObj();
-	    			}
-	    		}
-	    	}
-	    }
-	    return null;
-	}
-	
-	public boolean hasDvPortGroup(String dvPortGroupName) throws Exception {
-		ManagedObjectReference morNetwork = getDvPortGroupMor(dvPortGroupName);
-		if(morNetwork != null)
-			return true;
-		return false;		
-	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/aa1f26cb/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 6adb302..f44ed1c 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -38,6 +38,7 @@ import com.vmware.vim25.BoolPolicy;
 import com.vmware.vim25.DVPortgroupConfigSpec;
 import com.vmware.vim25.DVSTrafficShapingPolicy;
 //import com.vmware.vim25.DistributedVirtualSwitchKeyedOpaqueBlob;
+import com.vmware.vim25.DVPortgroupConfigInfo;
 import com.vmware.vim25.DynamicProperty;
 import com.vmware.vim25.HostNetworkTrafficShapingPolicy;
 import com.vmware.vim25.HostPortGroupSpec;
@@ -220,8 +221,10 @@ public class HypervisorHostHelper {
             long timeOutMs) throws Exception, CloudRuntimeException {		
 		ManagedObjectReference morNetwork = null;
 		VmwareContext context = hostMo.getContext();
+		ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
+		DatacenterMO dataCenterMo = new DatacenterMO(context, dcMor);
 
-		ManagedObjectReference morEthernetPortProfile = hostMo.getDvPortGroupMor(ethPortProfileName);
+		ManagedObjectReference morEthernetPortProfile = dataCenterMo.getDvPortGroupMor(ethPortProfileName);
 
         if (morEthernetPortProfile == null) {
             String msg = "Unable to find Ethernet port profile " + ethPortProfileName;
@@ -261,12 +264,13 @@ public class HypervisorHostHelper {
 			shapingPolicy.setPeakBandwidth(peakBandwidth);
 			shapingPolicy.setBurstSize(burstSize);
 		}
+		
 		boolean bWaitPortGroupReady = false;
-        if (!hostMo.hasDvPortGroup(networkName)) {
+        if (!dataCenterMo.hasDvPortGroup(networkName)) {
             createPortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps);
             bWaitPortGroupReady = true;
         } else {
-        	DVPortgroupConfigSpec spec = hostMo.getDvPortGroupSpec(networkName);        	
+        	DVPortgroupConfigInfo spec = dataCenterMo.getDvPortGroupSpec(networkName);     
  	
             if(!isSpecMatch(spec, vid, shapingPolicy)) {
                 updatePortProfile(context, ethPortProfileName, vid, networkRateMbps);   
            
                 bWaitPortGroupReady = true;
@@ -274,9 +278,9 @@ public class HypervisorHostHelper {
         }
 		//Wait for dvPortGroup on vCenter		
         if(bWaitPortGroupReady) 
-            morNetwork = waitForDvPortGroupReady(hostMo, networkName, timeOutMs);
+            morNetwork = waitForDvPortGroupReady(dataCenterMo, networkName, timeOutMs);
         else
-            morNetwork = hostMo.getDvPortGroupMor(networkName);
+            morNetwork = dataCenterMo.getDvPortGroupMor(networkName);
         if (morNetwork == null) {
             String msg = "Failed to create guest network " + networkName;
             s_logger.error(msg);
@@ -292,14 +296,14 @@ public class HypervisorHostHelper {
 	}
 	
     private static ManagedObjectReference waitForDvPortGroupReady(
-			HostMO hostMo, String dvPortGroupName, long timeOutMs) throws Exception {
+			DatacenterMO dataCenterMo, String dvPortGroupName, long timeOutMs) throws Exception {
 		ManagedObjectReference morDvPortGroup = null;
 
 		// if DvPortGroup is just created, we may fail to retrieve it, we
 		// need to retry
 		long startTick = System.currentTimeMillis();
 		while (System.currentTimeMillis() - startTick <= timeOutMs) {
-			morDvPortGroup = hostMo.getDvPortGroupMor(dvPortGroupName);
+			morDvPortGroup = dataCenterMo.getDvPortGroupMor(dvPortGroupName);
 			if (morDvPortGroup != null) {
 				break;
 			}
@@ -310,7 +314,7 @@ public class HypervisorHostHelper {
 		return morDvPortGroup;
 	}
 
-	private static boolean isSpecMatch(DVPortgroupConfigSpec spec, Integer vid,
+	private static boolean isSpecMatch(DVPortgroupConfigInfo spec, Integer vid,
 			DVSTrafficShapingPolicy shapingPolicy) {
 		DVSTrafficShapingPolicy currentTrafficShapingPolicy;
 		currentTrafficShapingPolicy = spec.getDefaultPortConfig().getInShapingPolicy();


Mime
View raw message