Search in sources :

Example 16 with NetworkACL

use of com.cloud.legacymodel.network.vpc.NetworkACL in project cosmic by MissionCriticalCloud.

the class NetworkACLServiceImpl method updateNetworkACLItem.

@Override
public NetworkACLItem updateNetworkACLItem(final Long id, final String protocol, final List<String> sourceCidrList, final NetworkACLItem.TrafficType trafficType, final String action, final Integer number, final Integer sourcePortStart, final Integer sourcePortEnd, final Integer icmpCode, final Integer icmpType, final String newUUID, final Boolean forDisplay) throws ResourceUnavailableException {
    final NetworkACLItemVO aclItem = _networkACLItemDao.findById(id);
    if (aclItem == null) {
        throw new InvalidParameterValueException("Unable to find ACL Item cannot be found");
    }
    if (aclItem.getAclId() == NetworkACL.DEFAULT_ALLOW || aclItem.getAclId() == NetworkACL.DEFAULT_DENY) {
        throw new InvalidParameterValueException("Default ACL Items cannot be updated");
    }
    final NetworkACL acl = _networkAclMgr.getNetworkACL(aclItem.getAclId());
    final Vpc vpc = _entityMgr.findById(Vpc.class, acl.getVpcId());
    final Account caller = CallContext.current().getCallingAccount();
    _accountMgr.checkAccess(caller, null, true, vpc);
    if (number != null) {
        // Check if ACL Item with specified number already exists
        final NetworkACLItemVO aclNumber = _networkACLItemDao.findByAclAndNumber(acl.getId(), number);
        if (aclNumber != null && aclNumber.getId() != id) {
            throw new InvalidParameterValueException("ACL item with number " + number + " already exists in ACL: " + acl.getUuid());
        }
    }
    validateNetworkACLItem(sourcePortStart == null ? aclItem.getSourcePortStart() : sourcePortStart, sourcePortEnd == null ? aclItem.getSourcePortEnd() : sourcePortEnd, sourceCidrList, protocol, icmpCode, icmpType == null ? aclItem.getIcmpType() : icmpType, action, number);
    return _networkAclMgr.updateNetworkACLItem(id, protocol, sourceCidrList, trafficType, action, number, sourcePortStart, sourcePortEnd, icmpCode, icmpType, newUUID, forDisplay);
}
Also used : Account(com.cloud.legacymodel.user.Account) InvalidParameterValueException(com.cloud.legacymodel.exceptions.InvalidParameterValueException) Vpc(com.cloud.legacymodel.network.vpc.Vpc) NetworkACL(com.cloud.legacymodel.network.vpc.NetworkACL)

Aggregations

NetworkACL (com.cloud.legacymodel.network.vpc.NetworkACL)16 Vpc (com.cloud.legacymodel.network.vpc.Vpc)11 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)8 Account (com.cloud.legacymodel.user.Account)8 ArrayList (java.util.ArrayList)5 Network (com.cloud.legacymodel.network.Network)4 NetworkVO (com.cloud.network.dao.NetworkVO)4 NetworkACLResponse (com.cloud.api.response.NetworkACLResponse)3 ResourceTagResponse (com.cloud.api.response.ResourceTagResponse)3 DataCenter (com.cloud.legacymodel.dc.DataCenter)3 ResourceTag (com.cloud.server.ResourceTag)3 ActionEvent (com.cloud.event.ActionEvent)2 NetworkACLItem (com.cloud.legacymodel.network.vpc.NetworkACLItem)2 PhysicalNetwork (com.cloud.network.PhysicalNetwork)2 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)2 List (java.util.List)2 ServerApiException (com.cloud.api.ServerApiException)1 CapabilityResponse (com.cloud.api.response.CapabilityResponse)1 IPAddressResponse (com.cloud.api.response.IPAddressResponse)1 ListResponse (com.cloud.api.response.ListResponse)1