コード例 #1
0
 @Override
 public boolean applyACLToPrivateGw(PrivateGateway gateway) throws ResourceUnavailableException {
   VpcGatewayVO vpcGatewayVO = _vpcGatewayDao.findById(gateway.getId());
   List<? extends NetworkACLItem> rules =
       _networkACLItemDao.listByACL(vpcGatewayVO.getNetworkACLId());
   return applyACLToPrivateGw(gateway, rules);
 }
コード例 #2
0
  @Override
  public boolean replaceNetworkACLForPrivateGw(NetworkACL acl, PrivateGateway gateway)
      throws ResourceUnavailableException {
    VpcGatewayVO vpcGatewayVo = _vpcGatewayDao.findById(gateway.getId());
    List<NetworkACLItemVO> aclItems = _networkACLItemDao.listByACL(acl.getId());
    if (aclItems == null || aclItems.isEmpty()) {
      // Revoke ACL Items of the existing ACL if the new network acl is empty
      // Other wise existing rules will not be removed on the router elelment
      s_logger.debug("New network ACL is empty. Revoke existing rules before applying ACL");
      if (!revokeACLItemsForPrivateGw(gateway)) {
        throw new CloudRuntimeException(
            "Failed to replace network ACL. Error while removing existing ACL "
                + "items for privatewa gateway: "
                + gateway.getId());
      }
    }

    vpcGatewayVo.setNetworkACLId(acl.getId());
    if (_vpcGatewayDao.update(vpcGatewayVo.getId(), vpcGatewayVo)) {
      return applyACLToPrivateGw(gateway);
    }
    return false;
  }