protected void markStaticRouteForRevoke(final StaticRouteVO route, final Account caller) { s_logger.debug("Revoking static route " + route); if (caller != null) { _accountMgr.checkAccess(caller, null, false, route); } if (route.getState() == StaticRoute.State.Staged) { if (s_logger.isDebugEnabled()) { s_logger.debug("Found a static route that is still in stage state so just removing it: " + route); } _staticRouteDao.remove(route.getId()); } else if (route.getState() == StaticRoute.State.Add || route.getState() == StaticRoute.State.Active) { route.setState(StaticRoute.State.Revoke); _staticRouteDao.update(route.getId(), route); s_logger.debug("Marked static route " + route + " with state " + StaticRoute.State.Revoke); } }
@Override public boolean setStateToAdd(StaticRouteVO rule) { SearchCriteria<StaticRouteVO> sc = AllFieldsSearch.create(); sc.setParameters("id", rule.getId()); sc.setParameters("state", StaticRoute.State.Staged); rule.setState(StaticRoute.State.Add); return update(rule, sc) > 0; }
final StaticRouteVO ruleVO = _staticRouteDao.findById(route.getId()); ruleVO.setState(StaticRoute.State.Active); _staticRouteDao.update(ruleVO.getId(), ruleVO); s_logger.debug("Marked route " + route + " with state " + StaticRoute.State.Active);
@Override public StaticRouteVO doInTransaction(final TransactionStatus status) throws NetworkRuleConflictException { StaticRouteVO newRoute = new StaticRouteVO(gateway.getId(), cidr, vpc.getId(), vpc.getAccountId(), vpc.getDomainId()); s_logger.debug("Adding static route " + newRoute); newRoute = _staticRouteDao.persist(newRoute); detectRoutesConflict(newRoute); if (!_staticRouteDao.setStateToAdd(newRoute)) { throw new CloudRuntimeException("Unable to update the state to add for " + newRoute); } CallContext.current().setEventDetails("Static route Id: " + newRoute.getId()); return newRoute; } });
_accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria); sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ); sb.and("vpcGatewayId", sb.entity().getVpcGatewayId(), SearchCriteria.Op.EQ); sb.groupBy(sb.entity().getId()); sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
protected StaticRouteDaoImpl() { super(); AllFieldsSearch = createSearchBuilder(); AllFieldsSearch.and("gatewayId", AllFieldsSearch.entity().getVpcGatewayId(), Op.EQ); AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ); AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ); AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ); AllFieldsSearch.done(); NotRevokedSearch = createSearchBuilder(); NotRevokedSearch.and("vpcId", NotRevokedSearch.entity().getVpcId(), Op.EQ); NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), Op.NEQ); NotRevokedSearch.done(); RoutesByGatewayCount = createSearchBuilder(Long.class); RoutesByGatewayCount.select(null, Func.COUNT, RoutesByGatewayCount.entity().getId()); RoutesByGatewayCount.and("gatewayId", RoutesByGatewayCount.entity().getVpcGatewayId(), Op.EQ); RoutesByGatewayCount.done(); }