You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ek...@apache.org on 2015/09/09 14:08:39 UTC

[1/2] git commit: updated refs/heads/master to 2d90f18

Repository: cloudstack
Updated Branches:
  refs/heads/master 28d18dce0 -> 2d90f18b8


CLOUDSTACK-8814 - Refactoring the configuration of Routers and VPC routers nics


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

Branch: refs/heads/master
Commit: 5e9e9b84fb1a4ca029c32e5b1c305124bfa4d4af
Parents: 5da7083
Author: wilderrodrigues <wr...@schubergphilis.com>
Authored: Tue Sep 8 14:33:25 2015 +0200
Committer: wilderrodrigues <wr...@schubergphilis.com>
Committed: Tue Sep 8 15:34:29 2015 +0200

----------------------------------------------------------------------
 .../cloud/network/router/NetworkHelperImpl.java | 48 ++++++++++++++------
 .../network/router/VpcNetworkHelperImpl.java    | 21 +++++++++
 2 files changed, 55 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5e9e9b84/server/src/com/cloud/network/router/NetworkHelperImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NetworkHelperImpl.java b/server/src/com/cloud/network/router/NetworkHelperImpl.java
index 62dd789..01c4891 100644
--- a/server/src/com/cloud/network/router/NetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/NetworkHelperImpl.java
@@ -109,7 +109,7 @@ public class NetworkHelperImpl implements NetworkHelper {
     @Inject
     protected NicDao _nicDao;
     @Inject
-    private NetworkDao _networkDao;
+    protected NetworkDao _networkDao;
     @Inject
     protected DomainRouterDao _routerDao;
     @Inject
@@ -137,8 +137,6 @@ public class NetworkHelperImpl implements NetworkHelper {
     @Inject
     private UserIpv6AddressDao _ipv6Dao;
     @Inject
-    private RouterControlHelper _routerControlHelper;
-    @Inject
     protected NetworkOrchestrationService _networkMgr;
     @Inject
     private UserDao _userDao;
@@ -610,20 +608,22 @@ public class NetworkHelperImpl implements NetworkHelper {
         throw new CloudRuntimeException(errMsg);
     }
 
-    @Override
-    public LinkedHashMap<Network, List<? extends NicProfile>> configureDefaultNics(final RouterDeploymentDefinition routerDeploymentDefinition) throws ConcurrentOperationException, InsufficientAddressCapacityException {
-
-        final LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<Network, List<? extends NicProfile>>(3);
+    protected LinkedHashMap<Network, List<? extends NicProfile>> configureControlNic(final RouterDeploymentDefinition routerDeploymentDefinition) {
+        final LinkedHashMap<Network, List<? extends NicProfile>> controlConfig = new LinkedHashMap<Network, List<? extends NicProfile>>(3);
 
-        // 1) Control network
         s_logger.debug("Adding nic for Virtual Router in Control network ");
         final List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork);
         final NetworkOffering controlOffering = offerings.get(0);
-        final Network controlConfig = _networkMgr.setupNetwork(s_systemAccount, controlOffering, routerDeploymentDefinition.getPlan(), null, null, false).get(0);
+        final Network controlNic = _networkMgr.setupNetwork(s_systemAccount, controlOffering, routerDeploymentDefinition.getPlan(), null, null, false).get(0);
 
-        networks.put(controlConfig, new ArrayList<NicProfile>());
+        controlConfig.put(controlNic, new ArrayList<NicProfile>());
+
+        return controlConfig;
+    }
+
+    protected LinkedHashMap<Network, List<? extends NicProfile>> configurePublicNic(final RouterDeploymentDefinition routerDeploymentDefinition, final boolean hasGuestNic) {
+        final LinkedHashMap<Network, List<? extends NicProfile>> publicConfig = new LinkedHashMap<Network, List<? extends NicProfile>>(3);
 
-        // 2) Public network
         if (routerDeploymentDefinition.isPublicNetwork()) {
             s_logger.debug("Adding nic for Virtual Router in Public network ");
             // if source nat service is supported by the network, get the source
@@ -647,6 +647,11 @@ public class NetworkHelperImpl implements NetworkHelper {
                 defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp.getVlanTag()));
             }
 
+            //If guest nic has already been added we will have 2 devices in the list.
+            if (hasGuestNic) {
+                defaultNic.setDeviceId(2);
+            }
+
             final NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
             final List<? extends Network> publicNetworks = _networkMgr.setupNetwork(s_systemAccount, publicOffering, routerDeploymentDefinition.getPlan(), null, null, false);
             final String publicIp = defaultNic.getIPv4Address();
@@ -657,14 +662,29 @@ public class NetworkHelperImpl implements NetworkHelper {
                 s_logger.info("Use same MAC as previous RvR, the MAC is " + peerNic.getMacAddress());
                 defaultNic.setMacAddress(peerNic.getMacAddress());
             }
-            networks.put(publicNetworks.get(0), new ArrayList<NicProfile>(Arrays.asList(defaultNic)));
+            publicConfig.put(publicNetworks.get(0), new ArrayList<NicProfile>(Arrays.asList(defaultNic)));
         }
 
-        // 3) Guest Network
+        return publicConfig;
+    }
+
+    @Override
+    public LinkedHashMap<Network, List<? extends NicProfile>> configureDefaultNics(final RouterDeploymentDefinition routerDeploymentDefinition) throws ConcurrentOperationException, InsufficientAddressCapacityException {
+
+        final LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<Network, List<? extends NicProfile>>(3);
+
+        // 1) Guest Network
         final LinkedHashMap<Network, List<? extends NicProfile>> guestNic = configureGuestNic(routerDeploymentDefinition);
-        // The guest nic has to be added after the Control and Public nics.
         networks.putAll(guestNic);
 
+        // 2) Control network
+        final LinkedHashMap<Network, List<? extends NicProfile>> controlNic = configureControlNic(routerDeploymentDefinition);
+        networks.putAll(controlNic);
+
+        // 3) Public network
+        final LinkedHashMap<Network, List<? extends NicProfile>> publicNic = configurePublicNic(routerDeploymentDefinition, networks.size() > 1);
+        networks.putAll(publicNic);
+
         return networks;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5e9e9b84/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
index f6f9ec4..2b008bd 100644
--- a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
@@ -32,6 +32,7 @@ import org.cloud.network.router.deployment.RouterDeploymentDefinition;
 
 import com.cloud.dc.dao.VlanDao;
 import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.IpAddress;
@@ -153,4 +154,24 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl {
 
         _itMgr.allocate(router.getInstanceName(), template, routerOffering, networks, vpcRouterDeploymentDefinition.getPlan(), hType);
     }
+
+    @Override
+    public LinkedHashMap<Network, List<? extends NicProfile>> configureDefaultNics(final RouterDeploymentDefinition routerDeploymentDefinition) throws ConcurrentOperationException, InsufficientAddressCapacityException {
+
+        final LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<Network, List<? extends NicProfile>>(3);
+
+        // 1) Control network
+        final LinkedHashMap<Network, List<? extends NicProfile>> controlNic = configureControlNic(routerDeploymentDefinition);
+        networks.putAll(controlNic);
+
+        // 2) Public network
+        final LinkedHashMap<Network, List<? extends NicProfile>> publicNic = configurePublicNic(routerDeploymentDefinition, false);
+        networks.putAll(publicNic);
+
+        // 3) Guest Network
+        final LinkedHashMap<Network, List<? extends NicProfile>> guestNic = configureGuestNic(routerDeploymentDefinition);
+        networks.putAll(guestNic);
+
+        return networks;
+    }
 }
\ No newline at end of file


[2/2] git commit: updated refs/heads/master to 2d90f18

Posted by ek...@apache.org.
Merge pull request #788 from ekholabs/fix/iso_net-CLOUDSTACK-8814

CLOUDSTACK-8814 - Refactoring the configuration of Routers and VPC routers nicsHi there,

I refactored the configureDefaultNics() method in order to split the implementations for Routers and VPC Routers.

The following tests were executed:

* test_vm_life_cycle
* test_routers
* test_vpc_router_nics
* test_vpc_routers
* test_vpc_offerings

@remibergsma @bhaisaab @koushik-das @miguelaferreira @DaanHoogland @karuturi , could you please have a look/test this PR?

Thanks in advance.

Cheers,
Wilder

* pr/788:
  CLOUDSTACK-8814 - Refactoring the configuration of Routers and VPC routers nics

Signed-off-by: wilderrodrigues <wr...@schubergphilis.com>


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

Branch: refs/heads/master
Commit: 2d90f18b82a0c52fdfc815e0f8efb565f96788e3
Parents: 28d18dc 5e9e9b8
Author: wilderrodrigues <wr...@schubergphilis.com>
Authored: Wed Sep 9 14:08:15 2015 +0200
Committer: wilderrodrigues <wr...@schubergphilis.com>
Committed: Wed Sep 9 14:08:15 2015 +0200

----------------------------------------------------------------------
 .../cloud/network/router/NetworkHelperImpl.java | 48 ++++++++++++++------
 .../network/router/VpcNetworkHelperImpl.java    | 21 +++++++++
 2 files changed, 55 insertions(+), 14 deletions(-)
----------------------------------------------------------------------