You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/07/11 21:05:47 UTC
[2/2] git commit: VPC: don't send staticRoutes in Revoke state to the
VPC VR
VPC: don't send staticRoutes in Revoke state to the VPC VR
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/d2e491a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/d2e491a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/d2e491a3
Branch: refs/heads/vpc
Commit: d2e491a377ac87e211590532f8481484cac7d388
Parents: 37ab2dd
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Wed Jul 11 10:35:43 2012 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Wed Jul 11 12:05:33 2012 -0700
----------------------------------------------------------------------
.../VpcVirtualNetworkApplianceManagerImpl.java | 23 ++++++++--
.../src/com/cloud/vm/dao/DomainRouterDaoImpl.java | 34 ++++++++------
2 files changed, 37 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2e491a3/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 a15640b..541fc61 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -858,12 +858,15 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
List<StaticRouteProfile> staticRouteProfiles = new ArrayList<StaticRouteProfile>(routes.size());
Map<Long, VpcGateway> gatewayMap = new HashMap<Long, VpcGateway>();
for (StaticRoute route : routes) {
- VpcGateway gateway = gatewayMap.get(route.getVpcGatewayId());
- if (gateway == null) {
- gateway = _vpcMgr.getVpcGateway(route.getVpcGatewayId());
- gatewayMap.put(gateway.getId(), gateway);
+ if (route.getState() != StaticRoute.State.Revoke) {
+ //skip static route in revoke state
+ VpcGateway gateway = gatewayMap.get(route.getVpcGatewayId());
+ if (gateway == null) {
+ gateway = _vpcMgr.getVpcGateway(route.getVpcGatewayId());
+ gatewayMap.put(gateway.getId(), gateway);
+ }
+ staticRouteProfiles.add(new StaticRouteProfile(route, gateway));
}
- staticRouteProfiles.add(new StaticRouteProfile(route, gateway));
}
s_logger.debug("Found " + staticRouteProfiles.size() + " static routes to apply as a part of vpc route "
@@ -1038,6 +1041,16 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
return true;
}
+ //exclude static route in Revoke state
+ Iterator<StaticRouteProfile> it = staticRoutes.iterator();
+ while (it.hasNext()) {
+ StaticRouteProfile profile = it.next();
+ if (profile.getState() == StaticRoute.State.Revoke) {
+ s_logger.debug("Not sending static route " + profile + " because its in " + StaticRoute.State.Revoke + " state");
+ it.remove();
+ }
+ }
+
boolean result = true;
for (VirtualRouter router : routers) {
if (router.getState() == State.Running) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d2e491a3/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
index e9e05bb..590fd6a 100755
--- a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
+++ b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
@@ -28,6 +28,7 @@ import com.cloud.network.RouterNetworkVO;
import com.cloud.network.router.VirtualRouter;
import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.offering.NetworkOffering;
+import com.cloud.offerings.dao.NetworkOfferingDaoImpl;
import com.cloud.user.UserStatisticsVO;
import com.cloud.user.dao.UserStatisticsDaoImpl;
import com.cloud.utils.component.ComponentLocator;
@@ -53,6 +54,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
HostDaoImpl _hostsDao = ComponentLocator.inject(HostDaoImpl.class);
RouterNetworkDaoImpl _routerNetworkDao = ComponentLocator.inject(RouterNetworkDaoImpl.class);
UserStatisticsDaoImpl _userStatsDao = ComponentLocator.inject(UserStatisticsDaoImpl.class);
+ NetworkOfferingDaoImpl _offDao = ComponentLocator.inject(NetworkOfferingDaoImpl.class);
protected final SearchBuilder<DomainRouterVO> VpcSearch;
protected DomainRouterDaoImpl() {
@@ -281,22 +283,24 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
@Override
@DB
public void addRouterToGuestNetwork(VirtualRouter router, Network guestNetwork) {
- if (_routerNetworkDao.findByRouterAndNetwork(router.getId(), guestNetwork.getId()) == null &&
- !guestNetwork.getName().equalsIgnoreCase(NetworkOffering.SystemPrivateGatewayNetworkOffering)) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- //1) add router to network
- RouterNetworkVO routerNtwkMap = new RouterNetworkVO(router.getId(), guestNetwork.getId(), guestNetwork.getGuestType());
- _routerNetworkDao.persist(routerNtwkMap);
- //2) create user stats entry for the network
- UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterIdToDeployIn(),
- guestNetwork.getId(), null, router.getId(), router.getType().toString());
- if (stats == null) {
- stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterIdToDeployIn(), null, router.getId(),
- router.getType().toString(), guestNetwork.getId());
- _userStatsDao.persist(stats);
+ if (_routerNetworkDao.findByRouterAndNetwork(router.getId(), guestNetwork.getId()) == null) {
+ NetworkOffering off = _offDao.findById(guestNetwork.getNetworkOfferingId());
+ if (!(off.getName().equalsIgnoreCase(NetworkOffering.SystemPrivateGatewayNetworkOffering))) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ //1) add router to network
+ RouterNetworkVO routerNtwkMap = new RouterNetworkVO(router.getId(), guestNetwork.getId(), guestNetwork.getGuestType());
+ _routerNetworkDao.persist(routerNtwkMap);
+ //2) create user stats entry for the network
+ UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterIdToDeployIn(),
+ guestNetwork.getId(), null, router.getId(), router.getType().toString());
+ if (stats == null) {
+ stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterIdToDeployIn(), null, router.getId(),
+ router.getType().toString(), guestNetwork.getId());
+ _userStatsDao.persist(stats);
+ }
+ txn.commit();
}
- txn.commit();
}
}