cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [22/50] [abbrv] git commit: updated refs/heads/master to 771d052
Date Tue, 14 Oct 2014 18:15:40 GMT
DeployRouter includes nw creation following TellDontAsk principle

Also factor out NicProfile specific methods and fix some DI config.

Conflicts:
	server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
	server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java


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

Branch: refs/heads/master
Commit: 3d4ddb72519e2d1347d7238d7bb35581c25e6a37
Parents: adebaf2
Author: Antonio Fornie <afornie@schubergphilis.com>
Authored: Wed Aug 20 04:21:53 2014 -0500
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Tue Oct 14 15:02:13 2014 +0200

----------------------------------------------------------------------
 .../spring-server-core-managers-context.xml     |  10 +-
 .../com/cloud/network/router/NetworkHelper.java |  16 ---
 .../cloud/network/router/NetworkHelperImpl.java |  21 +---
 .../cloud/network/router/NicProfileHelper.java  |  15 +++
 .../network/router/NicProfileHelperImpl.java    | 110 +++++++++++++++++++
 .../cloud/network/router/VpcNetworkHelper.java  |  15 ---
 .../network/router/VpcNetworkHelperImpl.java    |  87 +--------------
 .../VpcVirtualNetworkApplianceManagerImpl.java  |   2 +-
 .../deployment/RouterDeploymentDefinition.java  |   8 +-
 .../RouterDeploymentDefinitionBuilder.java      |   4 +-
 .../VpcRouterDeploymentDefinition.java          |   9 +-
 .../RouterDeploymentDefinitionTest.java         |   3 +-
 .../VpcRouterDeploymentDefinitionTest.java      |   4 +-
 13 files changed, 150 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
----------------------------------------------------------------------
diff --git a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
index 5cfc802..2b46ca3 100644
--- a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
+++ b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
@@ -200,12 +200,18 @@
     <bean id="routerControlHelper"
         class="com.cloud.network.router.RouterControlHelper" />
         
-    <bean id="networkGeneralHelper"
-        class="com.cloud.network.router.NetworkGeneralHelper" />
+    <bean id="networkHelper"
+        class="com.cloud.network.router.NetworkHelperImpl" />
+        
+    <bean id="vpcNetworkHelper"
+        class="com.cloud.network.router.VpcNetworkHelperImpl" />
         
     <bean id="vpcVirtualNetworkHelper"
         class="com.cloud.network.router.VpcVirtualNetworkHelperImpl" />
         
+    <bean id="nicProfileHelper"
+        class="com.cloud.network.router.NicProfileHelperImpl" />
+        
     <bean id="routerDeploymentDefinitionBuilder"
         class="org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder" />
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/src/com/cloud/network/router/NetworkHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NetworkHelper.java b/server/src/com/cloud/network/router/NetworkHelper.java
index 8bc76ea..01beb91 100644
--- a/server/src/com/cloud/network/router/NetworkHelper.java
+++ b/server/src/com/cloud/network/router/NetworkHelper.java
@@ -1,6 +1,5 @@
 package com.cloud.network.router;
 
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -16,11 +15,9 @@ import com.cloud.exception.InsufficientServerCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.exception.StorageUnavailableException;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.Network;
 import com.cloud.user.Account;
 import com.cloud.user.User;
 import com.cloud.vm.DomainRouterVO;
-import com.cloud.vm.NicProfile;
 import com.cloud.vm.VirtualMachineProfile.Param;
 
 public interface NetworkHelper {
@@ -29,7 +26,6 @@ public interface NetworkHelper {
 
     public abstract String getRouterIpInNetwork(long networkId, long instanceId);
 
-    //    @Override
     public abstract boolean sendCommandsToRouter(VirtualRouter router,
             Commands cmds) throws AgentUnavailableException;
 
@@ -40,11 +36,9 @@ public interface NetworkHelper {
 
     public abstract int getRealPriority(DomainRouterVO router);
 
-    //    @Override
     public abstract NicTO getNicTO(VirtualRouter router, Long networkId,
             String broadcastUri);
 
-    //    @Override
     public abstract VirtualRouter destroyRouter(long routerId, Account caller,
             Long callerUserId) throws ResourceUnavailableException,
             ConcurrentOperationException;
@@ -55,33 +49,23 @@ public interface NetworkHelper {
      * @param router
      * @return
      */
-    //    @Override
     public abstract boolean checkRouterVersion(VirtualRouter router);
 
-    //    @Override
     public abstract List<DomainRouterVO> startRouters(
             RouterDeploymentDefinition routerDeploymentDefinition)
             throws StorageUnavailableException, InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException;
 
-    //    @Override
     public abstract DomainRouterVO startVirtualRouter(DomainRouterVO router,
             User user, Account caller, Map<Param, Object> params)
             throws StorageUnavailableException, InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException;
 
-    //    @Override
     public abstract DomainRouterVO deployRouter(
             RouterDeploymentDefinition routerDeploymentDefinition,
-            LinkedHashMap<Network, List<? extends NicProfile>> networks,
             boolean startRouter, List<HypervisorType> supportedHypervisors)
             throws InsufficientAddressCapacityException,
             InsufficientServerCapacityException, InsufficientCapacityException,
             StorageUnavailableException, ResourceUnavailableException;
 
-    public abstract LinkedHashMap<Network, List<? extends NicProfile>> createRouterNetworks(
-            RouterDeploymentDefinition routerDeploymentDefinition)
-            throws ConcurrentOperationException,
-            InsufficientAddressCapacityException;
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/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 bf4c7af..ece0c0f 100644
--- a/server/src/com/cloud/network/router/NetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/NetworkHelperImpl.java
@@ -29,7 +29,6 @@ import javax.inject.Inject;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 import org.apache.log4j.Logger;
 import org.cloud.network.router.deployment.RouterDeploymentDefinition;
-import org.springframework.stereotype.Component;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
@@ -99,9 +98,7 @@ import com.cloud.vm.VirtualMachineProfile.Param;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
 
-@Component
-//This will not be a public service anymore, but a helper for the only public service
-@Local(value = {NetworkHelperImpl.class})
+@Local(value = {NetworkHelper.class})
 public class NetworkHelperImpl implements NetworkHelper {
 
     private static final Logger s_logger = Logger.getLogger(NetworkHelperImpl.class);
@@ -506,19 +503,8 @@ public class NetworkHelperImpl implements NetworkHelper {
         return result;
     }
 
-    //    @Override
-//    public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploymentDefinition)
{
-//        routerDeploymentDefinition.createNetwork();
-//        doDeployRouter
-//    }
-
-    //    @Override
-    /* (non-Javadoc)
-     * @see com.cloud.network.router.NetworkHelper#deployRouter(org.cloud.network.router.deployment.RouterDeploymentDefinition,
java.util.LinkedHashMap, boolean, java.util.List)
-     */
     @Override
     public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploymentDefinition,
-            final LinkedHashMap<Network, List<? extends NicProfile>> networks,
             final boolean startRouter, final List<HypervisorType> supportedHypervisors)
                     throws InsufficientAddressCapacityException,
                     InsufficientServerCapacityException, InsufficientCapacityException,
@@ -587,6 +573,7 @@ public class NetworkHelperImpl implements NetworkHelper {
                 router.setDynamicallyScalable(template.isDynamicallyScalable());
                 router.setRole(Role.VIRTUAL_ROUTER);
                 router = _routerDao.persist(router);
+                LinkedHashMap<Network, List<? extends NicProfile>> networks =
this.createRouterNetworks(routerDeploymentDefinition);
                 _itMgr.allocate(router.getInstanceName(), template, routerOffering, networks,
routerDeploymentDefinition.getPlan(), null);
                 router = _routerDao.findById(router.getId());
             } catch (final InsufficientCapacityException ex) {
@@ -701,10 +688,6 @@ public class NetworkHelperImpl implements NetworkHelper {
     }
 
 
-    /* (non-Javadoc)
-     * @see com.cloud.network.router.NetworkHelper#createRouterNetworks(org.cloud.network.router.deployment.RouterDeploymentDefinition)
-     */
-    @Override
     public LinkedHashMap<Network, List<? extends NicProfile>> createRouterNetworks(
             final RouterDeploymentDefinition routerDeploymentDefinition)
                     throws ConcurrentOperationException, InsufficientAddressCapacityException
{

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/src/com/cloud/network/router/NicProfileHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NicProfileHelper.java b/server/src/com/cloud/network/router/NicProfileHelper.java
new file mode 100644
index 0000000..e75fa9a
--- /dev/null
+++ b/server/src/com/cloud/network/router/NicProfileHelper.java
@@ -0,0 +1,15 @@
+package com.cloud.network.router;
+
+import com.cloud.network.Network;
+import com.cloud.network.vpc.VpcGateway;
+import com.cloud.vm.NicProfile;
+
+public interface NicProfileHelper {
+
+    public abstract NicProfile createPrivateNicProfileForGateway(
+            VpcGateway privateGateway);
+
+    public abstract NicProfile createGuestNicProfileForVpcRouter(
+            Network guestNetwork);
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/src/com/cloud/network/router/NicProfileHelperImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NicProfileHelperImpl.java b/server/src/com/cloud/network/router/NicProfileHelperImpl.java
new file mode 100644
index 0000000..a06dbff
--- /dev/null
+++ b/server/src/com/cloud/network/router/NicProfileHelperImpl.java
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.router;
+
+
+import java.net.URI;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import com.cloud.network.Network;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.Networks.AddressFormat;
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.network.vpc.PrivateIpAddress;
+import com.cloud.network.vpc.PrivateIpVO;
+import com.cloud.network.vpc.VpcGateway;
+import com.cloud.network.vpc.VpcManager;
+import com.cloud.network.vpc.dao.PrivateIpDao;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.net.NetUtils;
+import com.cloud.vm.Nic;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.VMInstanceDao;
+
+
+@Local(value = {NicProfileHelper.class})
+public class NicProfileHelperImpl implements NicProfileHelper {
+
+    @Inject
+    private VMInstanceDao _vmDao;
+    @Inject
+    private PrivateIpDao _privateIpDao;
+    @Inject
+    protected NetworkModel _networkModel;
+    @Inject
+    protected VpcManager _vpcMgr;
+    @Inject
+    protected NicDao _nicDao;
+
+
+    @Override
+    @DB
+    public NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
+        Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
+        PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(),
privateNetwork.getId(), privateGateway.getIp4Address());
+        Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());
+
+        NicProfile privateNicProfile = new NicProfile();
+
+        if (privateNic != null) {
+            VirtualMachine vm = _vmDao.findById(privateNic.getInstanceId());
+            privateNicProfile =
+                new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(),
privateNic.getIsolationUri(), _networkModel.getNetworkRate(
+                    privateNetwork.getId(), vm.getId()), _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
_networkModel.getNetworkTag(
+                    vm.getHypervisorType(), privateNetwork));
+        } else {
+            String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
+            PrivateIpAddress ip =
+                new PrivateIpAddress(ipVO, privateNetwork.getBroadcastUri().toString(), privateNetwork.getGateway(),
netmask,
+                    NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));
+
+            URI netUri = BroadcastDomainType.fromString(ip.getBroadcastUri());
+            privateNicProfile.setIp4Address(ip.getIpAddress());
+            privateNicProfile.setGateway(ip.getGateway());
+            privateNicProfile.setNetmask(ip.getNetmask());
+            privateNicProfile.setIsolationUri(netUri);
+            privateNicProfile.setBroadcastUri(netUri);
+            // can we solve this in setBroadcastUri()???
+            // or more plugable construct is desirable
+            privateNicProfile.setBroadcastType(BroadcastDomainType.getSchemeValue(netUri));
+            privateNicProfile.setFormat(AddressFormat.Ip4);
+            privateNicProfile.setReservationId(String.valueOf(ip.getBroadcastUri()));
+            privateNicProfile.setMacAddress(ip.getMacAddress());
+        }
+
+        return privateNicProfile;
+    }
+
+    @Override
+    public NicProfile createGuestNicProfileForVpcRouter(final Network guestNetwork) {
+        NicProfile guestNic = new NicProfile();
+        guestNic.setIp4Address(guestNetwork.getGateway());
+        guestNic.setBroadcastUri(guestNetwork.getBroadcastUri());
+        guestNic.setBroadcastType(guestNetwork.getBroadcastDomainType());
+        guestNic.setIsolationUri(guestNetwork.getBroadcastUri());
+        guestNic.setMode(guestNetwork.getMode());
+        String gatewayCidr = guestNetwork.getCidr();
+        guestNic.setNetmask(NetUtils.getCidrNetmask(gatewayCidr));
+
+        return guestNic;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/src/com/cloud/network/router/VpcNetworkHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcNetworkHelper.java b/server/src/com/cloud/network/router/VpcNetworkHelper.java
deleted file mode 100644
index fb26883..0000000
--- a/server/src/com/cloud/network/router/VpcNetworkHelper.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.cloud.network.router;
-
-import com.cloud.network.Network;
-import com.cloud.network.vpc.VpcGateway;
-import com.cloud.vm.NicProfile;
-
-public interface VpcNetworkHelper extends NetworkHelper {
-
-    public abstract NicProfile createPrivateNicProfileForGateway(
-            VpcGateway privateGateway);
-
-    public abstract NicProfile createGuestNicProfileForVpcRouter(
-            Network guestNetwork);
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/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 64ee2b0..c6c3785 100644
--- a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
@@ -17,121 +17,45 @@
 package com.cloud.network.router;
 
 
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.TreeSet;
 
-import javax.ejb.Local;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.cloud.network.router.deployment.RouterDeploymentDefinition;
-import org.springframework.stereotype.Component;
 
 import com.cloud.dc.dao.VlanDao;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
-import com.cloud.network.Networks.AddressFormat;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.IsolationType;
 import com.cloud.network.addr.PublicIp;
 import com.cloud.network.dao.IPAddressVO;
 import com.cloud.network.vpc.PrivateGateway;
-import com.cloud.network.vpc.PrivateIpAddress;
-import com.cloud.network.vpc.PrivateIpVO;
-import com.cloud.network.vpc.VpcGateway;
 import com.cloud.network.vpc.VpcManager;
-import com.cloud.network.vpc.dao.PrivateIpDao;
 import com.cloud.offering.NetworkOffering;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.net.NetUtils;
-import com.cloud.vm.Nic;
 import com.cloud.vm.NicProfile;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.dao.VMInstanceDao;
 
 
-@Component
-// This will not be a public service anymore, but a helper for the only public service
-@Local(value = {VpcNetworkHelperImpl.class})
-public class VpcNetworkHelperImpl extends NetworkHelperImpl implements VpcNetworkHelper {
+public class VpcNetworkHelperImpl extends NetworkHelperImpl {
 
     private static final Logger s_logger = Logger.getLogger(VpcNetworkHelperImpl.class);
 
     @Inject
-    private VMInstanceDao _vmDao;
-    @Inject
-    private PrivateIpDao _privateIpDao;
-    @Inject
     private VlanDao _vlanDao;
     @Inject
     protected VpcManager _vpcMgr;
+    @Inject
+    protected NicProfileHelper nicProfileHelper;
 
 
     @Override
-    @DB
-    public NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
-        Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
-        PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(),
privateNetwork.getId(), privateGateway.getIp4Address());
-        Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());
-
-        NicProfile privateNicProfile = new NicProfile();
-
-        if (privateNic != null) {
-            VirtualMachine vm = _vmDao.findById(privateNic.getInstanceId());
-            privateNicProfile =
-                new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(),
privateNic.getIsolationUri(), _networkModel.getNetworkRate(
-                    privateNetwork.getId(), vm.getId()), _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
_networkModel.getNetworkTag(
-                    vm.getHypervisorType(), privateNetwork));
-        } else {
-            String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
-            PrivateIpAddress ip =
-                new PrivateIpAddress(ipVO, privateNetwork.getBroadcastUri().toString(), privateNetwork.getGateway(),
netmask,
-                    NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));
-
-            URI netUri = BroadcastDomainType.fromString(ip.getBroadcastUri());
-            privateNicProfile.setIp4Address(ip.getIpAddress());
-            privateNicProfile.setGateway(ip.getGateway());
-            privateNicProfile.setNetmask(ip.getNetmask());
-            privateNicProfile.setIsolationUri(netUri);
-            privateNicProfile.setBroadcastUri(netUri);
-            // can we solve this in setBroadcastUri()???
-            // or more plugable construct is desirable
-            privateNicProfile.setBroadcastType(BroadcastDomainType.getSchemeValue(netUri));
-            privateNicProfile.setFormat(AddressFormat.Ip4);
-            privateNicProfile.setReservationId(String.valueOf(ip.getBroadcastUri()));
-            privateNicProfile.setMacAddress(ip.getMacAddress());
-        }
-
-        return privateNicProfile;
-    }
-
-    /* (non-Javadoc)
-     * @see com.cloud.network.router.VpcNetworkHelper#createGuestNicProfileForVpcRouter(com.cloud.network.Network)
-     */
-    @Override
-    public NicProfile createGuestNicProfileForVpcRouter(final Network guestNetwork) {
-        NicProfile guestNic = new NicProfile();
-        guestNic.setIp4Address(guestNetwork.getGateway());
-        guestNic.setBroadcastUri(guestNetwork.getBroadcastUri());
-        guestNic.setBroadcastType(guestNetwork.getBroadcastDomainType());
-        guestNic.setIsolationUri(guestNetwork.getBroadcastUri());
-        guestNic.setMode(guestNetwork.getMode());
-        String gatewayCidr = guestNetwork.getCidr();
-        guestNic.setNetmask(NetUtils.getCidrNetmask(gatewayCidr));
-
-        return guestNic;
-    }
-
-    /* (non-Javadoc)
-     * @see com.cloud.network.router.VpcNetworkHelper#createVpcRouterNetworks(org.cloud.network.router.deployment.VpcRouterDeploymentDefinition)
-     */
-    @Override
     public LinkedHashMap<Network, List<? extends NicProfile>> createRouterNetworks(
             final RouterDeploymentDefinition vpcRouterDeploymentDefinition)
                     throws ConcurrentOperationException, InsufficientAddressCapacityException
{
@@ -149,7 +73,7 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl implements
VpcNetwor
         final List<PrivateGateway> privateGateways = this._vpcMgr.getVpcPrivateGateways(vpcId);
         if (privateGateways != null && !privateGateways.isEmpty()) {
             for (PrivateGateway privateGateway : privateGateways) {
-                NicProfile privateNic = this.createPrivateNicProfileForGateway(privateGateway);
+                NicProfile privateNic = this.nicProfileHelper.createPrivateNicProfileForGateway(privateGateway);
                 Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
                 networks.put(privateNetwork, new ArrayList<NicProfile>(Arrays.asList(privateNic)));
             }
@@ -162,7 +86,7 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl implements
VpcNetwor
                 continue;
             }
             if (guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState()
== Network.State.Setup) {
-                NicProfile guestNic = createGuestNicProfileForVpcRouter(guestNetwork);
+                NicProfile guestNic = this.nicProfileHelper.createGuestNicProfileForVpcRouter(guestNetwork);
                 networks.put(guestNetwork, new ArrayList<NicProfile>(Arrays.asList(guestNic)));
             }
         }
@@ -197,6 +121,7 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl implements
VpcNetwor
         }
         if (publicNetwork != null) {
             if (networks.get(publicNetwork) != null) {
+                @SuppressWarnings("unchecked")
                 List<NicProfile> publicNicProfiles = (List<NicProfile>)networks.get(publicNetwork);
                 publicNicProfiles.addAll(publicNics);
                 networks.put(publicNetwork, publicNicProfiles);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index b358cd2..dfdb4cc 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -135,7 +135,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     private EntityManager _entityMgr;
 
     @Inject
-    private VpcNetworkHelper vpcHelper;
+    private NicProfileHelper vpcHelper;
 
     @Override
     public boolean configure(final String name, final Map<String, Object> params) throws
ConfigurationException {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
----------------------------------------------------------------------
diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
index 77c7f33..1867a22 100644
--- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
+++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
@@ -17,7 +17,6 @@
 package org.cloud.network.router.deployment;
 
 import java.util.ArrayList;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -64,7 +63,6 @@ import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.DomainRouterVO;
-import com.cloud.vm.NicProfile;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile.Param;
@@ -398,10 +396,8 @@ public class RouterDeploymentDefinition {
 
         int routersToDeploy = this.getNumberOfRoutersToDeploy();
         for(int i = 0; i < routersToDeploy; i++) {
-            LinkedHashMap<Network, List<? extends NicProfile>> networks =
-                    this.nwHelper.createRouterNetworks(this);
-            //don't start the router as we are holding the network lock that needs to be
released at the end of router allocation
-            DomainRouterVO router = this.nwHelper.deployRouter(this, networks, false, null);
+            // Don't start the router as we are holding the network lock that needs to be
released at the end of router allocation
+            DomainRouterVO router = this.nwHelper.deployRouter(this, false, null);
 
             if (router != null) {
                 this.routerDao.addRouterToGuestNetwork(router, this.guestNetwork);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java
----------------------------------------------------------------------
diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java
b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java
index 82ea004..7c76bd7 100644
--- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java
+++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinitionBuilder.java
@@ -37,7 +37,7 @@ import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
 import com.cloud.network.dao.UserIpv6AddressDao;
 import com.cloud.network.dao.VirtualRouterProviderDao;
 import com.cloud.network.router.NetworkHelper;
-import com.cloud.network.router.VpcNetworkHelper;
+import com.cloud.network.router.VpcNetworkHelperImpl;
 import com.cloud.network.vpc.Vpc;
 import com.cloud.network.vpc.VpcManager;
 import com.cloud.network.vpc.dao.VpcDao;
@@ -95,7 +95,7 @@ public class RouterDeploymentDefinitionBuilder {
     @Inject
     protected NetworkHelper nwHelper;
     @Inject
-    protected VpcNetworkHelper vpcNwHelper;
+    protected VpcNetworkHelperImpl vpcNwHelper;
 
     protected Long offeringId;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
----------------------------------------------------------------------
diff --git a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
index 6710a12..cccdf23 100644
--- a/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
+++ b/server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java
@@ -17,7 +17,6 @@
 package org.cloud.network.router.deployment;
 
 import java.util.ArrayList;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -30,12 +29,10 @@ import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.Network;
 import com.cloud.network.PhysicalNetwork;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.dao.PhysicalNetworkDao;
-import com.cloud.network.router.VpcNetworkHelper;
 import com.cloud.network.vpc.Vpc;
 import com.cloud.network.vpc.VpcManager;
 import com.cloud.network.vpc.dao.VpcDao;
@@ -43,7 +40,6 @@ import com.cloud.network.vpc.dao.VpcOfferingDao;
 import com.cloud.user.Account;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.DomainRouterVO;
-import com.cloud.vm.NicProfile;
 import com.cloud.vm.VirtualMachineProfile.Param;
 import com.cloud.vm.dao.DomainRouterDao;
 
@@ -56,7 +52,6 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition
{
     protected PhysicalNetworkDao pNtwkDao;
     protected VpcManager vpcMgr;
     protected VlanDao vlanDao;
-    protected VpcNetworkHelper vpcNetworkHelper;
 
     protected Vpc vpc;
 
@@ -164,9 +159,7 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition
{
     @Override
     protected void deployAllVirtualRouters() throws ConcurrentOperationException, InsufficientCapacityException,
ResourceUnavailableException {
 
-        LinkedHashMap<Network, List<? extends NicProfile>> networks = vpcNetworkHelper.createRouterNetworks(this);
-
-        DomainRouterVO router = nwHelper.deployRouter(this, networks, true, vpcMgr.getSupportedVpcHypervisors());
+        DomainRouterVO router = nwHelper.deployRouter(this, true, vpcMgr.getSupportedVpcHypervisors());
 
         if (router != null) {
             routers.add(router);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
index e76186f..74b704d 100644
--- a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
+++ b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
@@ -798,11 +798,10 @@ public class RouterDeploymentDefinitionTest extends RouterDeploymentDefinitionTe
         //this.deployment.routers.add(routerVO1);
         RouterDeploymentDefinition deploymentUT = spy(this.deployment);
         doReturn(2).when(deploymentUT).getNumberOfRoutersToDeploy();
-        doReturn(null).when(this.mockNetworkGeneralHelper).createRouterNetworks(deploymentUT);
 
         final DomainRouterVO routerVO1 = mock(DomainRouterVO.class);
         final DomainRouterVO routerVO2 = mock(DomainRouterVO.class);
-        when(this.mockNetworkGeneralHelper.deployRouter(deploymentUT, null, false, null))
+        when(this.mockNetworkGeneralHelper.deployRouter(deploymentUT, false, null))
             .thenReturn(routerVO1).thenReturn(routerVO2);
 
         // Execute

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d4ddb72/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
index 3a72fa9..7b06aa0 100644
--- a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
+++ b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
@@ -36,7 +36,7 @@ import com.cloud.deploy.DeployDestination;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
-import com.cloud.network.router.VpcNetworkHelper;
+import com.cloud.network.router.NicProfileHelper;
 import com.cloud.network.vpc.VpcManager;
 import com.cloud.network.vpc.VpcVO;
 import com.cloud.network.vpc.dao.VpcDao;
@@ -64,7 +64,7 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
     @Mock
     protected VpcManager vpcMgr;
     @Mock
-    protected VpcNetworkHelper vpcHelper;
+    protected NicProfileHelper vpcHelper;
 
     protected RouterDeploymentDefinition deployment;
 


Mime
View raw message