Ejemplo n.º 1
0
  public Router createRouter(String routerName, String externalNetworkId)
      throws RegionException, NeutronException {
    if (!checkRouterNameExist(routerName)) {
      Optional<? extends RouterApi> routerApiExtension = neutronApi.getRouterApi(getRegionOne());

      if (routerApiExtension.isPresent()) {
        RouterApi routerApi = routerApiExtension.get();
        ExternalGatewayInfo externalGateway =
            ExternalGatewayInfo.builder()
                .networkId(externalNetworkId)
                //                  .enableSnat(true)
                .build();
        return routerApi.create(
            CreateRouter.createBuilder()
                .name(routerName)
                .adminStateUp(true)
                .externalGatewayInfo(externalGateway)
                .build());

      } else {
        throw new NeutronException("RouterApi is not present");
      }

    } else {

      throw new NeutronException("Router name exists on this tenant!");
    }
  }
Ejemplo n.º 2
0
  public boolean deleteRouter(String routerId) throws NeutronException, RegionException {
    Optional<? extends RouterApi> routerApiExtension = neutronApi.getRouterApi(getRegionOne());

    if (routerApiExtension.isPresent()) {
      RouterApi routerApi = routerApiExtension.get();
      return routerApi.delete(routerId);
    } else {
      throw new NeutronException("RouterApi is not present");
    }
  }
Ejemplo n.º 3
0
  public ArrayList<Router> listRouter() throws RegionException, NeutronException {

    Optional<? extends RouterApi> routerApiExtension = neutronApi.getRouterApi(getRegionOne());

    if (routerApiExtension.isPresent()) {
      RouterApi routerApi = routerApiExtension.get();
      return Lists.newArrayList(routerApi.list().concat());
    } else {
      throw new NeutronException("RouterApi is not present");
    }
  }
Ejemplo n.º 4
0
  public RouterInterface addRouterToInterface(String routerId, String subnetId)
      throws NeutronException, RegionException {

    Optional<? extends RouterApi> routerApiExtension = neutronApi.getRouterApi(getRegionOne());

    if (routerApiExtension.isPresent()) {
      RouterApi routerApi = routerApiExtension.get();
      return routerApi.addInterfaceForSubnet(routerId, subnetId);
    } else {
      throw new NeutronException("RouterApi is not present");
    }
  }