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!"); } }
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"); } }
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"); } }
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"); } }