mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-2429: Multiple private gateways are allowed within a VPC. Check for conflicting routes in all gateways when adding a new static route
This commit is contained in:
parent
15ccce436b
commit
d4ed20b0d3
|
|
@ -26,7 +26,7 @@ public interface StaticRouteDao extends GenericDao<StaticRouteVO, Long>{
|
|||
|
||||
boolean setStateToAdd(StaticRouteVO rule);
|
||||
|
||||
List<? extends StaticRoute> listByGatewayIdAndNotRevoked(long gatewayId);
|
||||
List<? extends StaticRoute> listByVpcIdAndNotRevoked(long vpcId);
|
||||
|
||||
List<StaticRouteVO> listByVpcId(long vpcId);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class StaticRouteDaoImpl extends GenericDaoBase<StaticRouteVO, Long> impl
|
|||
AllFieldsSearch.done();
|
||||
|
||||
NotRevokedSearch = createSearchBuilder();
|
||||
NotRevokedSearch.and("gatewayId", NotRevokedSearch.entity().getVpcGatewayId(), Op.EQ);
|
||||
NotRevokedSearch.and("vpcId", NotRevokedSearch.entity().getVpcId(), Op.EQ);
|
||||
NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), Op.NEQ);
|
||||
NotRevokedSearch.done();
|
||||
|
||||
|
|
@ -82,9 +82,9 @@ public class StaticRouteDaoImpl extends GenericDaoBase<StaticRouteVO, Long> impl
|
|||
|
||||
|
||||
@Override
|
||||
public List<? extends StaticRoute> listByGatewayIdAndNotRevoked(long gatewayId) {
|
||||
public List<? extends StaticRoute> listByVpcIdAndNotRevoked(long vpcId) {
|
||||
SearchCriteria<StaticRouteVO> sc = NotRevokedSearch.create();
|
||||
sc.setParameters("gatewayId", gatewayId);
|
||||
sc.setParameters("vpcId", vpcId);
|
||||
sc.setParameters("state", StaticRoute.State.Revoke);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1858,7 +1858,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
|||
}
|
||||
|
||||
protected void detectRoutesConflict(StaticRoute newRoute) throws NetworkRuleConflictException {
|
||||
List<? extends StaticRoute> routes = _staticRouteDao.listByGatewayIdAndNotRevoked(newRoute.getVpcGatewayId());
|
||||
//Multiple private gateways can exist within Vpc. Check for conflicts for all static routes in Vpc
|
||||
//and not just the gateway
|
||||
List<? extends StaticRoute> routes = _staticRouteDao.listByVpcIdAndNotRevoked(newRoute.getVpcId());
|
||||
assert (routes.size() >= 1) : "For static routes, we now always first persist the route and then check for " +
|
||||
"network conflicts so we should at least have one rule at this point.";
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue