コード例 #1
0
  @Override
  @ActionEvent(
      eventType = EventTypes.EVENT_FIREWALL_OPEN,
      eventDescription = "creating firewall rule",
      create = true)
  public FirewallRule createIngressFirewallRule(FirewallRule rule)
      throws NetworkRuleConflictException {
    Account caller = CallContext.current().getCallingAccount();
    Long sourceIpAddressId = rule.getSourceIpAddressId();

    return createFirewallRule(
        sourceIpAddressId,
        caller,
        rule.getXid(),
        rule.getSourcePortStart(),
        rule.getSourcePortEnd(),
        rule.getProtocol(),
        rule.getSourceCidrList(),
        rule.getIcmpCode(),
        rule.getIcmpType(),
        null,
        rule.getType(),
        rule.getNetworkId(),
        rule.getTrafficType());
  }
コード例 #2
0
  @Override
  @ActionEvent(
      eventType = EventTypes.EVENT_FIREWALL_OPEN,
      eventDescription = "creating firewall rule",
      create = true)
  public FirewallRule createEgressFirewallRule(FirewallRule rule)
      throws NetworkRuleConflictException {
    Account caller = CallContext.current().getCallingAccount();

    Network network = _networkDao.findById(rule.getNetworkId());
    if (network.getGuestType() == Network.GuestType.Shared) {
      throw new InvalidParameterValueException(
          "Egress firewall rules are not supported for " + network.getGuestType() + "  networks");
    }

    return createFirewallRule(
        null,
        caller,
        rule.getXid(),
        rule.getSourcePortStart(),
        rule.getSourcePortEnd(),
        rule.getProtocol(),
        rule.getSourceCidrList(),
        rule.getIcmpCode(),
        rule.getIcmpType(),
        null,
        rule.getType(),
        rule.getNetworkId(),
        rule.getTrafficType());
  }