cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke4...@apache.org
Subject [38/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:

	Discover dvSwitch UUID for dvPort configuration.

Conflicts:

	vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.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/7838b3fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7838b3fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7838b3fe

Branch: refs/heads/master
Commit: 7838b3fed6c8dd38a887640cded7107c3193e6f0
Parents: f774ef7
Author: Sateesh Chodapuneedi <sateesh.chodapuneedi@citrix.com>
Authored: Tue May 15 04:27:10 2012 +0530
Committer: Vijayendra Bhamidipati <vijayendra.bhamidipati@citrix.com>
Committed: Fri May 25 17:47:58 2012 -0700

----------------------------------------------------------------------
 .../cloud/hypervisor/vmware/mo/DatacenterMO.java   |   79 ++++++++++++++-
 1 files changed, 78 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7838b3fe/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 30d5b1d..91cff67 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
@@ -393,5 +393,82 @@ public class DatacenterMO extends BaseMO {
 	    	}
 	    }
 	    return null;
-	}
+	}
+
+    public ManagedObjectReference getDvSwitchMor(ManagedObjectReference morDatacenter, ManagedObjectReference
dvPortGroupMor) throws Exception {
+        String dvPortGroupKey = null;
+        ManagedObjectReference dvSwitchMor = null;
+        PropertySpec pSpec = new PropertySpec();
+        pSpec.setType("DistributedVirtualPortgroup");
+        pSpec.setPathSet(new String[] { "key", "config.distributedVirtualSwitch" });
+
+        TraversalSpec datacenter2DvPortGroupTraversal = new TraversalSpec();
+        datacenter2DvPortGroupTraversal.setType("Datacenter");
+        datacenter2DvPortGroupTraversal.setPath("network");
+        datacenter2DvPortGroupTraversal.setName("datacenter2DvPortgroupTraversal");
+
+        ObjectSpec oSpec = new ObjectSpec();
+        oSpec.setObj(morDatacenter);
+        oSpec.setSkip(Boolean.TRUE);
+        oSpec.setSelectSet(new SelectionSpec[] { datacenter2DvPortGroupTraversal });
+
+        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("key")) {
+                            dvPortGroupKey = (String) prop.getVal();
+                        }
+                        else {
+                            dvSwitchMor = (ManagedObjectReference) prop.getVal();
+                        }
+                    }
+                    if ((dvPortGroupKey != null) && dvPortGroupKey.equals(dvPortGroupMor.get_value()))
{
+                        return dvSwitchMor;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    public String getDvSwitchUuid(ManagedObjectReference dvSwitchMor) throws Exception {
+        assert (dvSwitchMor != null);
+        PropertySpec pSpec = new PropertySpec();
+        pSpec.setType("DistributedVirtualSwitch");
+        pSpec.setPathSet(new String[] { "uuid" });
+
+        ObjectSpec oSpec = new ObjectSpec();
+        oSpec.setObj(dvSwitchMor);
+        oSpec.setSkip(Boolean.FALSE);
+        oSpec.setSelectSet(new SelectionSpec[] {});
+
+        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) {
+                    return (String) props[0].getVal();
+                }
+            }
+        }
+        return null;
+    }
 }


Mime
View raw message