@Override public NetworkACL getNetworkACL(final long id) { return _networkACLDao.findById(id); }
vpcIds.add(vpc.getId()); SearchBuilder<NetworkACLVO> searchBuilder = _networkAclDao.createSearchBuilder(); searchBuilder.and("vpcId", searchBuilder.entity().getVpcId(), Op.IN); SearchCriteria<NetworkACLVO> sc = searchBuilder.create(); sc.setParameters("vpcId", vpcIds.toArray()); List<NetworkACLVO> acls = _networkAclDao.search(sc, null); if (acls == null || acls.size() == 0) { s_logger.debug("no acls found");
/** * Reassign the ACL rules from the original vpc to the new VPC * @param srcVpcId * @param dstVpcId */ private void reassignACLRulesToNewVpc(long srcVpcId, long dstVpcId){ List<NetworkACLVO> networkACL = _networkACLDao.listByVpcId(srcVpcId); for (NetworkACLVO aclList : networkACL) { aclList.setVpcId(dstVpcId); _networkACLDao.persist(aclList); } }
final SearchBuilder<NetworkACLVO> vpcSearch = _networkACLDao.createSearchBuilder(); vpcSearch.and("vpcId", vpcSearch.entity().getVpcId(), Op.IN); sb.join("vpcSearch", vpcSearch, sb.entity().getAclId(), vpcSearch.entity().getId(), JoinBuilder.JoinType.INNER); final NetworkACL acl = _networkACLDao.findById(aclId); if (acl.getVpcId() != 0) { final Vpc vpc = _vpcDao.findById(acl.getVpcId());
@Override @ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_UPDATE, eventDescription = "updating network acl", async = true) public NetworkACL updateNetworkACL(UpdateNetworkACLListCmd updateNetworkACLListCmd) { Long id = updateNetworkACLListCmd.getId(); NetworkACLVO acl = _networkACLDao.findById(id); Vpc vpc = _entityMgr.findById(Vpc.class, acl.getVpcId()); Account caller = CallContext.current().getCallingAccount(); _accountMgr.checkAccess(caller, null, true, vpc); String name = updateNetworkACLListCmd.getName(); if (StringUtils.isNotBlank(name)) { acl.setName(name); } String description = updateNetworkACLListCmd.getDescription(); if (StringUtils.isNotBlank(description)) { acl.setDescription(description); } String customId = updateNetworkACLListCmd.getCustomId(); if (StringUtils.isNotBlank(customId)) { acl.setUuid(customId); } Boolean forDisplay = updateNetworkACLListCmd.getDisplay(); if (forDisplay != null) { acl.setDisplay(forDisplay); } _networkACLDao.update(id, acl); return _networkACLDao.findById(id); }
final Boolean display = cmd.getDisplay(); final SearchBuilder<NetworkACLVO> sb = _networkACLDao.createSearchBuilder(); sb.and("id", sb.entity().getId(), Op.EQ); sb.and("name", sb.entity().getName(), Op.EQ); final SearchCriteria<NetworkACLVO> ssc = _networkACLDao.createSearchCriteria(); ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%"); final Pair<List<NetworkACLVO>, Integer> acls = _networkACLDao.searchAndCount(sc, filter); return new Pair<List<? extends NetworkACL>, Integer>(acls.first(), acls.second());
final SearchBuilder<NetworkACLVO> searchBuilder = _networkAclDao.createSearchBuilder(); final Pair<List<NetworkACLVO>, Integer> aclsCountPair = _networkAclDao.searchAndCount(searchCriteria, filter);
@Override public NetworkACLItem moveNetworkAclRuleToNewPosition(MoveNetworkAclItemCmd moveNetworkAclItemCmd) { String uuidRuleBeingMoved = moveNetworkAclItemCmd.getUuidRuleBeingMoved(); String nextAclRuleUuid = moveNetworkAclItemCmd.getNextAclRuleUuid(); String previousAclRuleUuid = moveNetworkAclItemCmd.getPreviousAclRuleUuid(); if (StringUtils.isBlank(previousAclRuleUuid) && StringUtils.isBlank(nextAclRuleUuid)) { throw new InvalidParameterValueException("Both previous and next ACL rule IDs cannot be blank."); } NetworkACLItemVO ruleBeingMoved = _networkACLItemDao.findByUuid(uuidRuleBeingMoved); if (ruleBeingMoved == null) { throw new InvalidParameterValueException(String.format("Could not find a rule with ID[%s]", uuidRuleBeingMoved)); } NetworkACLItemVO previousRule = retrieveAndValidateAclRule(previousAclRuleUuid); NetworkACLItemVO nextRule = retrieveAndValidateAclRule(nextAclRuleUuid); validateMoveAclRulesData(ruleBeingMoved, previousRule, nextRule); try { NetworkACLVO lockedAcl = _networkACLDao.acquireInLockTable(ruleBeingMoved.getAclId()); List<NetworkACLItemVO> allAclRules = getAllAclRulesSortedByNumber(lockedAcl.getId()); validateAclConsistency(moveNetworkAclItemCmd, lockedAcl, allAclRules); if (previousRule == null) { return moveRuleToTheTop(ruleBeingMoved, allAclRules); } if (nextRule == null) { return moveRuleToTheBottom(ruleBeingMoved, allAclRules); } return moveRuleBetweenAclRules(ruleBeingMoved, allAclRules, previousRule, nextRule); } finally { _networkACLDao.releaseFromLockTable(ruleBeingMoved.getAclId()); } }
@Override public NetworkACL createNetworkACL(final String name, final String description, final long vpcId, final Boolean forDisplay) { final NetworkACLVO acl = new NetworkACLVO(name, description, vpcId); if (forDisplay != null) { acl.setDisplay(forDisplay); } return _networkACLDao.persist(acl); }
@Override public boolean deleteNetworkACL(final NetworkACL acl) { final long aclId = acl.getId(); final List<NetworkVO> networks = _networkDao.listByAclId(aclId); if (networks != null && networks.size() > 0) { throw new CloudRuntimeException("ACL is still associated with " + networks.size() + " tier(s). Cannot delete network ACL: " + acl.getUuid()); } final List<VpcGatewayVO> pvtGateways = _vpcGatewayDao.listByAclIdAndType(aclId, VpcGateway.Type.Private); if (pvtGateways != null && pvtGateways.size() > 0) { throw new CloudRuntimeException("ACL is still associated with " + pvtGateways.size() + " private gateway(s). Cannot delete network ACL: " + acl.getUuid()); } final List<NetworkACLItemVO> aclItems = _networkACLItemDao.listByACL(aclId); for (final NetworkACLItemVO networkACLItem : aclItems) { revokeNetworkACLItem(networkACLItem.getId()); } return _networkACLDao.remove(aclId); }
public static NetworkACL findByNetworkACLId(long aclId) { return s_networkACLDao.findById(aclId); }
if (networkAclId == null) continue; NetworkACLVO networkAcl = _networkACLDao.findById(networkAclId);
NetworkACLVO acl = _networkACLDao.findById(aclId); NetworkPolicyModel policyModel = _manager.getDatabase().lookupNetworkPolicy(acl.getUuid()); if (policyModel == null) {
NetworkACLVO acl = _networkACLDao.findById(dbNet.getNetworkACLId()); NetworkPolicyModel policyModel = _manager.getDatabase().lookupNetworkPolicy(acl.getUuid()); if (policyModel == null) {
/** * Validates if the data provided to move the ACL rule is supported by this implementation. The user needs to provide a valid ACL UUID, and at least one of the previous or the next ACL rule. * The validation is as follows: * <ul> * <li> If both ACL rules 'previous' and 'next' are invalid, we throw an {@link InvalidParameterValueException}; * <li> informed previous and next ACL rules must have the same ACL ID as the rule being moved; otherwise, an {@link InvalidParameterValueException} is thrown; * <li> then we check if the user trying to move ACL rules has access to the VPC, where the ACL rules are being applied. * </ul> */ protected void validateMoveAclRulesData(NetworkACLItemVO ruleBeingMoved, NetworkACLItemVO previousRule, NetworkACLItemVO nextRule) { if (nextRule == null && previousRule == null) { throw new InvalidParameterValueException("Both previous and next ACL rule IDs cannot be invalid."); } long aclId = ruleBeingMoved.getAclId(); if ((nextRule != null && nextRule.getAclId() != aclId) || (previousRule != null && previousRule.getAclId() != aclId)) { throw new InvalidParameterValueException("Cannot use ACL rules from differenting ACLs. Rule being moved."); } NetworkACLVO acl = _networkACLDao.findById(aclId); Vpc vpc = _entityMgr.findById(Vpc.class, acl.getVpcId()); Account caller = CallContext.current().getCallingAccount(); _accountMgr.checkAccess(caller, null, true, vpc); } }
@Override @ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_DELETE, eventDescription = "Deleting Network ACL List", async = true) public boolean deleteNetworkACL(final long id) { final Account caller = CallContext.current().getCallingAccount(); final NetworkACL acl = _networkACLDao.findById(id); if (acl == null) { throw new InvalidParameterValueException("Unable to find specified ACL"); } //Do not allow deletion of default ACLs if (acl.getId() == NetworkACL.DEFAULT_ALLOW || acl.getId() == NetworkACL.DEFAULT_DENY) { throw new InvalidParameterValueException("Default ACL cannot be removed"); } final Vpc vpc = _entityMgr.findById(Vpc.class, acl.getVpcId()); if (vpc == null) { throw new InvalidParameterValueException("Unable to find specified VPC associated with the ACL"); } _accountMgr.checkAccess(caller, null, true, vpc); return _networkAclMgr.deleteNetworkACL(acl); }
NetworkACLVO acl = _networkACLDao.findById(dbn.getNetworkACLId()); NetworkPolicyModel policyModel = _manager.getDatabase().lookupNetworkPolicy(acl.getUuid()); if (policyModel == null) {
final NetworkACL acl = _networkACLDao.findById(aclId); if (acl == null) { throw new InvalidParameterValueException("Unable to find specified NetworkACL");
final NetworkACLVO aclVO = _networkAclDao.findById(aclId); if (aclVO == null) { throw new InvalidParameterValueException("Invalid network acl id passed ");
final NetworkACL acl = _networkACLDao.findById(aclId); if (acl == null) { throw new InvalidParameterValueException("Unable to find specified NetworkACL");