Пример #1
0
  private void setExternalConnection(OpenstackRouter osRouter, String osSubNetId) {
    if (!osRouter.gatewayExternalInfo().isEnablePnat()) {
      log.debug("Source NAT is disabled");
      return;
    }

    OpenstackSubnet osSubNet = openstackService.subnet(osSubNetId);
    OpenstackNetwork osNet = openstackService.network(osSubNet.networkId());
    populateExternalRules(osNet, osSubNet);
  }
Пример #2
0
  private void unsetExternalConnection(
      OpenstackRouter osRouter, String osNetId, String subNetCidr) {
    if (!osRouter.gatewayExternalInfo().isEnablePnat()) {
      log.debug("Source NAT is disabled");
      return;
    }

    // FIXME router interface is subnet specific, not network
    OpenstackNetwork osNet = openstackService.network(osNetId);
    removeExternalRules(osNet, subNetCidr);
  }
Пример #3
0
  @Override
  public void removeRouterInterface(OpenstackRouterInterface routerIface) {
    OpenstackRouter osRouter = openstackService.router(routerIface.id());
    if (osRouter == null) {
      log.warn("Failed to remove router interface {}", routerIface);
      return;
    }

    OpenstackSubnet osSubnet = openstackService.subnet(routerIface.subnetId());
    OpenstackNetwork osNet = openstackService.network(osSubnet.networkId());

    unsetGatewayIcmp(
        Ip4Address.valueOf(openstackService.subnet(routerIface.subnetId()).gatewayIp()));

    unsetRoutes(osRouter, osSubnet);

    if (osRouter.gatewayExternalInfo().externalFixedIps().size() > 0) {
      unsetExternalConnection(osRouter, osNet.id(), osSubnet.cidr());
    }
    log.info("Disconnected {} from router {}", osSubnet.cidr(), osRouter.name());
  }