コード例 #1
0
  private void removeExternalRules(OpenstackNetwork osNet, String subNetCidr) {
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
    sBuilder
        .matchEthType(Ethernet.TYPE_IPV4)
        .matchTunnelId(Long.valueOf(osNet.segmentId()))
        .matchIPSrc(IpPrefix.valueOf(subNetCidr))
        .matchEthDst(Constants.DEFAULT_GATEWAY_MAC);

    nodeService
        .completeNodes()
        .forEach(
            node -> {
              ForwardingObjective.Flag flag =
                  node.type().equals(GATEWAY)
                      ? ForwardingObjective.Flag.VERSATILE
                      : ForwardingObjective.Flag.SPECIFIC;

              RulePopulatorUtil.removeRule(
                  flowObjectiveService,
                  appId,
                  node.intBridge(),
                  sBuilder.build(),
                  flag,
                  ROUTING_RULE_PRIORITY);
            });
  }
コード例 #2
0
  private void removeGatewayIcmpRule(Ip4Address gatewayIp, DeviceId deviceId) {
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();

    sBuilder
        .matchEthType(Ethernet.TYPE_IPV4)
        .matchIPProtocol(IPv4.PROTOCOL_ICMP)
        .matchIPDst(gatewayIp.toIpPrefix());

    RulePopulatorUtil.removeRule(
        flowObjectiveService,
        appId,
        deviceId,
        sBuilder.build(),
        ForwardingObjective.Flag.VERSATILE,
        GATEWAY_ICMP_PRIORITY);
  }
コード例 #3
0
  private void removeRoutingRules(Host host, Set<OpenstackSubnet> osSubNets) {
    String osSubNetId = host.annotations().value(SUBNET_ID);
    if (osSubNetId == null) {
      return;
    }

    Map<String, String> vniMap = new HashMap<>();
    openstackService.networks().stream().forEach(n -> vniMap.put(n.id(), n.segmentId()));

    osSubNets
        .stream()
        .filter(osSubNet -> !osSubNet.id().equals(osSubNetId))
        .forEach(
            osSubNet -> {
              TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
              sBuilder
                  .matchEthType(Ethernet.TYPE_IPV4)
                  .matchIPDst(host.ipAddresses().stream().findFirst().get().toIpPrefix())
                  .matchIPSrc(IpPrefix.valueOf(osSubNet.cidr()))
                  .matchTunnelId(Long.valueOf(vniMap.get(osSubNet.networkId())));

              nodeService
                  .completeNodes()
                  .stream()
                  .filter(node -> node.type().equals(COMPUTE))
                  .forEach(
                      node ->
                          RulePopulatorUtil.removeRule(
                              flowObjectiveService,
                              appId,
                              node.intBridge(),
                              sBuilder.build(),
                              ForwardingObjective.Flag.SPECIFIC,
                              EW_ROUTING_RULE_PRIORITY));
            });
    log.debug("Removed routing rule from {} to {}", host, osSubNets);
  }