cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [49/50] [abbrv] git commit: updated refs/heads/opendaylight to 858fb69
Date Fri, 03 Jan 2014 10:18:22 GMT
Set unique gre key for every network.

Set interface id to nic uuid when creating the vif.


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

Branch: refs/heads/opendaylight
Commit: a422bfb99b6c3207a4ff0563723f8a8e70a99489
Parents: 9da4ddf
Author: Hugo Trippaers <htrippaers@schubergphilis.com>
Authored: Fri Jan 3 10:49:03 2014 +0100
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Fri Jan 3 11:10:44 2014 +0100

----------------------------------------------------------------------
 .../hypervisor/kvm/resource/OvsVifDriver.java   |  2 +-
 .../agent/OpenDaylightControllerResource.java   | 25 +++++++++++++++++++-
 .../NeutronNetworksNorthboundAction.java        | 12 ++++++----
 3 files changed, 32 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a422bfb9/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java
index 79606b3..c64a472 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java
@@ -83,7 +83,7 @@ public class OvsVifDriver extends VifDriverBase {
                     intf.defBridgeNet(_pifs.get("private"), null, nic.getMac(), getGuestNicModel(guestOsType),
networkRateKBps);
                     intf.setVlanTag(Integer.parseInt(vlanId));
                 }
-            } else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
+            } else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch ||
nic.getBroadcastType() == Networks.BroadcastDomainType.OpenDaylight) {
                 s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch "
+ logicalSwitchUuid);
                 intf.setVirtualPortInterfaceId(nic.getUuid());
                 String brName = (trafficLabel != null && !trafficLabel.isEmpty())
? _pifs.get(trafficLabel) : _pifs.get("private");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a422bfb9/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResource.java
b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResource.java
index 5c1e1e4..c2b7a67 100644
--- a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResource.java
+++ b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/agent/OpenDaylightControllerResource.java
@@ -26,6 +26,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Random;
 import java.util.UUID;
 
 import javax.naming.ConfigurationException;
@@ -46,6 +47,7 @@ import org.apache.cloudstack.network.opendaylight.agent.responses.DestroyPortAns
 import org.apache.cloudstack.network.opendaylight.api.NeutronRestApiException;
 import org.apache.cloudstack.network.opendaylight.api.model.NeutronNetwork;
 import org.apache.cloudstack.network.opendaylight.api.model.NeutronNetworkWrapper;
+import org.apache.cloudstack.network.opendaylight.api.model.NeutronNetworksList;
 import org.apache.cloudstack.network.opendaylight.api.model.NeutronNode;
 import org.apache.cloudstack.network.opendaylight.api.model.NeutronNodeWrapper;
 import org.apache.cloudstack.network.opendaylight.api.model.NeutronNodesList;
@@ -206,6 +208,27 @@ public class OpenDaylightControllerResource implements ServerResource
{
 
     private Answer executeRequest(ConfigureNetworkCommand cmd) {
         NeutronNetworksNorthboundAction configureNetwork = new NeutronNetworksNorthboundAction(controllerUrl,
controllerUsername, controllerPassword);
+
+        // Find free gre key
+        int gre_key = -1;
+        Random keyGenerator = new Random(System.currentTimeMillis());
+        try {
+            NeutronNetworksList<NeutronNetwork> networks = configureNetwork.listAllNetworks();
+            while (true) {
+                int i = keyGenerator.nextInt();
+                for (NeutronNetwork network : networks.getNetworks()) {
+                    if (network.getSegmentationId() == i) {
+                        continue;
+                    }
+                }
+                gre_key = i;
+                break;
+            }
+        } catch (NeutronRestApiException e) {
+            s_logger.error("Failed to list existing networks on the ODL Controller", e);
+            return new ConfigureNetworkAnswer(cmd, e);
+        }
+
         NeutronNetwork newNetwork = new NeutronNetwork();
 
         // Configuration from the command
@@ -215,7 +238,7 @@ public class OpenDaylightControllerResource implements ServerResource
{
         // Static configuation
         newNetwork.setNetworkType("gre");
         newNetwork.setShared(false);
-        newNetwork.setSegmentationId(100);
+        newNetwork.setSegmentationId(gre_key);
         newNetwork.setId(UUID.randomUUID());
 
         NeutronNetworkWrapper wrapper = new NeutronNetworkWrapper();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a422bfb9/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/resources/NeutronNetworksNorthboundAction.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/resources/NeutronNetworksNorthboundAction.java
b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/resources/NeutronNetworksNorthboundAction.java
index 2d4f7c9..3a8c187 100644
--- a/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/resources/NeutronNetworksNorthboundAction.java
+++ b/plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/resources/NeutronNetworksNorthboundAction.java
@@ -25,10 +25,6 @@ import java.net.URL;
 import java.text.MessageFormat;
 import java.util.Collections;
 
-import org.apache.cloudstack.network.opendaylight.api.NeutronRestApiException;
-import org.apache.cloudstack.network.opendaylight.api.enums.NeutronNorthboundEnum;
-import org.apache.cloudstack.network.opendaylight.api.model.NeutronNetworkWrapper;
-import org.apache.cloudstack.network.opendaylight.api.model.NeutronNetworksList;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 
 import com.google.gson.FieldNamingPolicy;
@@ -36,6 +32,12 @@ import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.reflect.TypeToken;
 
+import org.apache.cloudstack.network.opendaylight.api.NeutronRestApiException;
+import org.apache.cloudstack.network.opendaylight.api.enums.NeutronNorthboundEnum;
+import org.apache.cloudstack.network.opendaylight.api.model.NeutronNetwork;
+import org.apache.cloudstack.network.opendaylight.api.model.NeutronNetworkWrapper;
+import org.apache.cloudstack.network.opendaylight.api.model.NeutronNetworksList;
+
 public class NeutronNetworksNorthboundAction extends Action {
 
     private final Gson gsonNeutronNetwork;
@@ -50,7 +52,7 @@ public class NeutronNetworksNorthboundAction extends Action {
         String uri = NeutronNorthboundEnum.NETWORKS_URI.getUri();
         String bodystring = executeGet(uri, Collections.<String, String> emptyMap());
 
-        Type returnType = new TypeToken<NeutronNetworksList<NeutronNetworkWrapper>>()
{
+        Type returnType = new TypeToken<NeutronNetworksList<NeutronNetwork>>()
{
         }.getType();
 
         T returnValue = (T) gsonNeutronNetwork.fromJson(bodystring, returnType);


Mime
View raw message