cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: updated refs/heads/4.3-forward to d38a503
Date Wed, 29 Jan 2014 17:20:25 GMT
Updated Branches:
  refs/heads/4.3-forward b1ec82cde -> d38a50343


check for BroadcastDomainTypes on sourceNatIp(cherry picked from commit
6d0dbf59683e1878533c8c985f26f18a1d69e1c1)

Conflicts:
	plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java


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

Branch: refs/heads/4.3-forward
Commit: d38a50343130f6f147e2c9c7b2e32a43f31c7e6b
Parents: b1ec82c
Author: Daan Hoogland <daan@onecht.net>
Authored: Wed Jan 29 18:20:16 2014 +0100
Committer: Daan Hoogland <dhoogland@schubergphilis.com>
Committed: Wed Jan 29 18:20:16 2014 +0100

----------------------------------------------------------------------
 api/test/com/cloud/network/NetworksTest.java    | 15 +++++++
 .../cloud/network/element/NiciraNvpElement.java | 43 +++++++++++---------
 2 files changed, 39 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d38a5034/api/test/com/cloud/network/NetworksTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/network/NetworksTest.java b/api/test/com/cloud/network/NetworksTest.java
index 87f69d6..860cff5 100644
--- a/api/test/com/cloud/network/NetworksTest.java
+++ b/api/test/com/cloud/network/NetworksTest.java
@@ -23,6 +23,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.cloud.dc.Vlan;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.IsolationType;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -60,6 +61,20 @@ public class NetworksTest {
     }
 
     @Test
+    public void vlanValueTest() throws URISyntaxException {
+        String uri1 = "vlan://1";
+        String uri2 = "1";
+        String vtag = BroadcastDomainType.Vlan.getValueFrom(BroadcastDomainType.fromString(uri1));
+        Assert.assertEquals("vtag should be \"1\"", "1", vtag);
+        BroadcastDomainType tiep1 = BroadcastDomainType.getTypeOf(uri1);
+        Assert.assertEquals("the type of uri1 should be 'Vlan'", BroadcastDomainType.Vlan,
tiep1);
+        BroadcastDomainType tiep2 = BroadcastDomainType.getTypeOf(uri2);
+        Assert.assertEquals("the type of uri1 should be 'Undecided'", BroadcastDomainType.UnDecided,
tiep2);
+        BroadcastDomainType tiep3 = BroadcastDomainType.getTypeOf(Vlan.UNTAGGED);
+        Assert.assertEquals("the type of uri1 should be 'vlan'", BroadcastDomainType.Native,
tiep3);
+    }
+
+    @Test
     public void vlanIsolationTypeTest() throws URISyntaxException {
         String uri1 = "vlan://1";
         Long value2 = 2L;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d38a5034/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
index 3e9e16a..bcbcc82 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.network.element;
 
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -253,25 +254,29 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
                 network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
             s_logger.debug("Apparently we are supposed to provide SourceNat on this network");
 
-            PublicIp sourceNatIp = _ipAddrMgr
-                    .assignSourceNatIpAddressToGuestNetwork(owner, network);
-            String publicCidr = sourceNatIp.getAddress().addr() + "/"
-                    + NetUtils.getCidrSize(sourceNatIp.getVlanNetmask());
-            String internalCidr = network.getGateway() + "/"
-                    + network.getCidr().split("/")[1];
-            long vlanid = (Vlan.UNTAGGED.equals(sourceNatIp.getVlanTag())) ? 0
-                    : Long.parseLong(sourceNatIp.getVlanTag());
-
-            CreateLogicalRouterCommand cmd = new CreateLogicalRouterCommand(
-                    niciraNvpHost.getDetail("l3gatewayserviceuuid"), vlanid,
-                    BroadcastDomainType.getValue(network.getBroadcastUri()),
-                    "router-" + network.getDisplayText(), publicCidr,
-                    sourceNatIp.getGateway(), internalCidr, context
-                    .getDomain().getName()
-                    + "-"
-                    + context.getAccount().getAccountName());
-            CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer)_agentMgr
-                    .easySend(niciraNvpHost.getId(), cmd);
+            PublicIp sourceNatIp = _ipAddrMgr.assignSourceNatIpAddressToGuestNetwork(owner,
network);
+            String publicCidr = sourceNatIp.getAddress().addr() + "/" + NetUtils.getCidrSize(sourceNatIp.getVlanNetmask());
+            String internalCidr = network.getGateway() + "/" + network.getCidr().split("/")[1];
+            // assuming a vlan:
+            String vtag = sourceNatIp.getVlanTag();
+            BroadcastDomainType tiep = null;
+            try {
+                tiep = BroadcastDomainType.getTypeOf(vtag);
+            } catch (URISyntaxException use) {
+                throw new CloudRuntimeException("vlantag for sourceNatIp is not valid: "
+ vtag, use);
+            }
+            if (tiep == BroadcastDomainType.Vlan) {
+                vtag = BroadcastDomainType.Vlan.getValueFrom(BroadcastDomainType.fromString(vtag));
+            } else if (!(tiep == BroadcastDomainType.UnDecided || tiep == BroadcastDomainType.Native))
{
+                throw new CloudRuntimeException("only vlans are supported for sourceNatIp,
at this moment: " + vtag);
+            }
+            long vlanid = (Vlan.UNTAGGED.equals(vtag)) ? 0 : Long.parseLong(vtag);
+
+            CreateLogicalRouterCommand cmd =
+                new CreateLogicalRouterCommand(niciraNvpHost.getDetail("l3gatewayserviceuuid"),
vlanid, BroadcastDomainType.getValue(network.getBroadcastUri()),
+                    "router-" + network.getDisplayText(), publicCidr, sourceNatIp.getGateway(),
internalCidr, context.getDomain().getName() + "-" +
+                        context.getAccount().getAccountName());
+            CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer)_agentMgr.easySend(niciraNvpHost.getId(),
cmd);
             if (answer.getResult() == false) {
                 s_logger.error("Failed to create Logical Router for network "
                         + network.getDisplayText());


Mime
View raw message