org.openstack4j.model.network.Network Java Examples

The following examples show how to use org.openstack4j.model.network.Network. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenstackRoutingFloatingIpHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
private void processGratuitousArpPacket(NetFloatingIP floatingIP,
                                        InstancePort instancePort) {
    Set<OpenstackNode> gws = ImmutableSet.copyOf(osNodeService.completeNodes(GATEWAY));

    Network osNet = osNetworkService.network(instancePort.networkId());

    OpenstackNode selectedGw = getGwByInstancePort(gws, instancePort);
    ExternalPeerRouter externalPeerRouter =
            externalPeerRouterForNetwork(osNet, osNetworkService, osRouterAdminService);
    if (externalPeerRouter == null) {
        log.error("Failed to process GARP packet for floating ip {}, because ",
                                                        NO_EXT_PEER_ROUTER_MSG);
        return;
    }

    processGarpPacketForFloatingIp(floatingIP, instancePort,
                    externalPeerRouter.vlanId(), selectedGw, packetService);

}
 
Example #2
Source File: OpenStackPlatformResources.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Override
public CloudIpPools publicIpPool(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
    OSClient<?> osClient = openStackClient.createOSClient(cloudCredential);
    Map<String, Set<CloudIpPool>> cloudIpPools = new HashMap<>();
    CloudRegions regions = regions(cloudCredential, region, filters, true);
    for (Entry<Region, List<AvailabilityZone>> regionListEntry : regions.getCloudRegions().entrySet()) {
        Set<CloudIpPool> cloudGateWays = new HashSet<>();
        List<? extends Network> networks = getNetworks(osClient);
        List<? extends Network> networksWithExternalRouter = networks.stream().filter(Network::isRouterExternal).collect(Collectors.toList());
        for (Network network : networksWithExternalRouter) {
            CloudIpPool cloudIpPool = new CloudIpPool();
            cloudIpPool.setId(network.getId());
            cloudIpPool.setName(network.getName());
            cloudGateWays.add(cloudIpPool);
        }
        for (AvailabilityZone availabilityZone : regionListEntry.getValue()) {
            cloudIpPools.put(availabilityZone.value(), cloudGateWays);
        }
    }
    LOGGER.debug("Openstack public ip pool result: {}", cloudIpPools);
    return new CloudIpPools(cloudIpPools);
}
 
Example #3
Source File: OpenstackIntegrationTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Test
public void createNeutronNetwork() throws Exception {
    ExtendedCamelContext camelContext = Mockito.mock(ExtendedCamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());

    Message msg = new DefaultMessage(camelContext);
    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);

    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(OpenstackConstants.NAME, dummyNetwork.getName());
    msg.setHeader(NeutronConstants.NETWORK_TYPE, dummyNetwork.getNetworkType());
    msg.setHeader(NeutronConstants.TENANT_ID, dummyNetwork.getTenantId());

    NeutronEndpoint endpoint = Mockito.mock(NeutronEndpoint.class);
    Producer producer = new NetworkProducer(endpoint, client);
    producer.process(exchange);

    ArgumentCaptor<Network> captor = ArgumentCaptor.forClass(Network.class);
    verify(networkService).create(captor.capture());

    assertEqualsNetwork(dummyNetwork, captor.getValue());
    assertNotNull(msg.getBody(Network.class).getId());
}
 
Example #4
Source File: OpenstackSwitchingIcmpHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
private void setRoutableSubnetsIcmpRules(OpenstackNode osNode,
                                         String segmentId,
                                         Subnet updatedSubnet,
                                         Set<Subnet> routableSubnets,
                                         IpAddress gatewayIp,
                                         Type networkType,
                                         boolean install) {
    setGatewayIcmpReplyRule(osNode, segmentId, gatewayIp, networkType, install);

    routableSubnets.forEach(subnet -> {
        setGatewayIcmpReplyRule(osNode, segmentId,
                IpAddress.valueOf(subnet.getGateway()), networkType, install);

        Network network = osNetworkService.network(subnet.getNetworkId());

        setGatewayIcmpReplyRule(osNode, network.getProviderSegID(),
                IpAddress.valueOf(updatedSubnet.getGateway()), networkType, install);
    });
}
 
Example #5
Source File: OpenstackRoutingArpHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
private void processGarpPacketForComputeNode(OpenstackNode computeNode,
                                             OpenstackNode gatewayNode) {
    instancePortService.instancePort(computeNode.intgBridge())
            .forEach(instancePort -> {
        NetFloatingIP floatingIP =
                floatingIpByInstancePort(instancePort, osRouterAdminService);
        Network network = osNetworkService.network(instancePort.networkId());
        ExternalPeerRouter externalPeerRouter =
                externalPeerRouterForNetwork(network, osNetworkService,
                                                    osRouterAdminService);
        if (floatingIP != null && externalPeerRouter != null) {
            processGarpPacketForFloatingIp(
                    floatingIP, instancePort, externalPeerRouter.vlanId(),
                                                gatewayNode, packetService);
        }
    });
}
 
Example #6
Source File: OpenstackNetworkingUtil.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the given floating IP is associated with a VM.
 *
 * @param service openstack network service
 * @param fip floating IP
 * @return true if the given floating IP associated with a VM, false otherwise
 */
public static boolean isAssociatedWithVM(OpenstackNetworkService service,
                                         NetFloatingIP fip) {
    Port osPort = service.port(fip.getPortId());
    if (osPort == null) {
        return false;
    }

    if (!Strings.isNullOrEmpty(osPort.getDeviceId())) {
        Network osNet = service.network(osPort.getNetworkId());
        if (osNet == null) {
            final String errorFormat = ERR_FLOW + "no network(%s) exists";
            final String error = String.format(errorFormat,
                    fip.getFloatingIpAddress(), osPort.getNetworkId());
            throw new IllegalStateException(error);
        }
        return true;
    } else {
        return false;
    }
}
 
Example #7
Source File: OpenstackNetworkManager.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public String gatewayIp(String portId) {
    checkNotNull(portId);

    Port port = port(portId);

    checkNotNull(port);

    IpAddress ipAddress = port.getFixedIps().stream()
            .map(ip -> IpAddress.valueOf(ip.getIpAddress()))
            .findAny().orElse(null);

    checkNotNull(ipAddress);

    Network network = network(port.getNetworkId());

    checkNotNull(network);

    return subnets(network.getId()).stream()
            .filter(s -> IpPrefix.valueOf(s.getCidr()).contains(ipAddress))
            .map(Subnet::getGateway)
            .findAny().orElse(null);
}
 
Example #8
Source File: OpenstackNetworkManager.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public IpPrefix ipPrefix(String portId) {
    checkNotNull(portId);

    Port port = port(portId);

    checkNotNull(port);

    IpAddress ipAddress = port.getFixedIps().stream()
            .map(ip -> IpAddress.valueOf(ip.getIpAddress()))
            .findAny().orElse(null);

    checkNotNull(ipAddress);

    Network network = network(port.getNetworkId());

    checkNotNull(network);

    return subnets(network.getId()).stream()
            .map(s -> IpPrefix.valueOf(s.getCidr()))
            .filter(prefix -> prefix.contains(ipAddress))
            .findAny().orElse(null);
}
 
Example #9
Source File: OpenstackSwitchingArpHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
private void processDefaultArpRuleForBroadcastMode(OpenstackNode osNode,
                                                   boolean install) {
    setVnetArpRuleForBroadcastMode(osNode, install);

    // we do not add fake gateway ARP rules for FLAT network
    // ARP packets generated by FLAT typed VM should not be
    // delegated to switch to handle
    osNetworkService.subnets().stream().filter(subnet ->
            osNetworkService.network(subnet.getNetworkId()) != null &&
                    osNetworkService.networkType(subnet.getNetworkId()) != FLAT)
            .forEach(subnet -> {
                String netId = subnet.getNetworkId();
                Network net = osNetworkService.network(netId);
                setFakeGatewayArpRule(subnet, net, install, osNode);
            });
}
 
Example #10
Source File: OpenstackRoutingHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
private void routerIfaceAdded(Router osRouter, RouterInterface osRouterIface) {
    Subnet osSubnet = osNetworkAdminService.subnet(osRouterIface.getSubnetId());
    if (osSubnet == null) {
        final String error = String.format(
                "Failed to set flows for router %s: subnet %s does not exist",
                osRouterIface.getId(),
                osRouterIface.getSubnetId());
        throw new IllegalStateException(error);
    }

    if (!osRouter.isAdminStateUp()) {
        Network network = osNetworkAdminService.network(osSubnet.getNetworkId());
        Type netType = osNetworkAdminService.networkType(osSubnet.getNetworkId());
        setRouterAdminRules(network.getProviderSegID(), netType, true);
    }

    setInternalRoutes(osRouter, osSubnet, true);
    setGatewayRules(osSubnet, osRouter, true);
    log.info("Connected subnet({}) to {}", osSubnet.getCidr(), osRouter.getName());
}
 
Example #11
Source File: OpenstackRoutingHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
private void routerIfaceRemoved(Router osRouter, RouterInterface osRouterIface) {
    Subnet osSubnet = osNetworkAdminService.subnet(osRouterIface.getSubnetId());
    if (osSubnet == null) {
        final String error = String.format(
                "Failed to set flows for router %s: subnet %s does not exist",
                osRouterIface.getId(),
                osRouterIface.getSubnetId());
        throw new IllegalStateException(error);
    }

    if (!osRouter.isAdminStateUp()) {
        Network network = osNetworkAdminService.network(osSubnet.getNetworkId());
        Type netType = osNetworkAdminService.networkType(osSubnet.getNetworkId());
        setRouterAdminRules(network.getProviderSegID(), netType, false);
    }

    setInternalRoutes(osRouter, osSubnet, false);
    setGatewayRules(osSubnet, osRouter, false);
    log.info("Disconnected subnet({}) from {}", osSubnet.getCidr(), osRouter.getName());
}
 
Example #12
Source File: OpenstackNetworkManager.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void removeNetwork(String netId) {
    checkArgument(!Strings.isNullOrEmpty(netId), ERR_NULL_NETWORK_ID);
    synchronized (this) {
        if (isNetworkInUse(netId)) {
            final String error = String.format(MSG_NETWORK, netId, ERR_IN_USE);
            throw new IllegalStateException(error);
        }
        Network osNet = osNetworkStore.removeNetwork(netId);
        if (osNet != null) {
            log.info(String.format(MSG_NETWORK, osNet.getName(), MSG_REMOVED));
        }

        Versioned<OpenstackNetwork> augmentedNetwork = augmentedNetworkMap.remove(netId);
        if (augmentedNetwork != null) {
            log.info(String.format(MSG_NETWORK_TYPE,
                                augmentedNetwork.value().type(), MSG_REMOVED));
        }
    }
}
 
Example #13
Source File: OpenstackSubnetListCommand.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
protected void doExecute() {
    OpenstackNetworkService service = get(OpenstackNetworkService.class);
    List<Subnet> subnets = Lists.newArrayList(service.subnets());
    subnets.sort(Comparator.comparing(Subnet::getName));

    if (outputJson()) {
        print("%s", json(subnets));
    } else {
        print(FORMAT, "ID", "Name", "CIDR", "GatewayIp", "NetworkId",
                                            "NetworkName", "HostRoutes");

        for (Subnet subnet: subnets) {
            Network osNet = service.network(subnet.getNetworkId());
            String netName = osNet == null ? "N/A" : osNet.getName();
            print(FORMAT,
                    subnet.getId(),
                    subnet.getName(),
                    subnet.getCidr(),
                    subnet.getGateway(),
                    subnet.getNetworkId(),
                    netName,
                    subnet.getHostRoutes());
        }
    }
}
 
Example #14
Source File: OpenstackNetworkManager.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void updateNetwork(Network osNet) {
    checkNotNull(osNet, ERR_NULL_NETWORK);
    checkArgument(!Strings.isNullOrEmpty(osNet.getId()), ERR_NULL_NETWORK_ID);

    osNetworkStore.updateNetwork(osNet);

    OpenstackNetwork finalAugmentedNetwork = buildAugmentedNetworkFromType(osNet);
    augmentedNetworkMap.compute(osNet.getId(), (id, existing) -> {
        final String error = osNet.getId() + ERR_NOT_FOUND;
        checkArgument(existing != null, error);
        return finalAugmentedNetwork;
    });

    log.info(String.format(MSG_NETWORK, osNet.getId(), MSG_UPDATED));
}
 
Example #15
Source File: OpenstackNetworkManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Tests updating a network, and checks if it triggers proper events.
 */
@Test
public void testCreateAndUpdateNetwork() {
    target.createNetwork(NETWORK);
    assertEquals("Number of networks did not match", 1, target.networks().size());
    assertEquals("Network did not match", NETWORK_NAME, target.network(NETWORK_ID).getName());

    final Network updated = NeutronNetwork.builder()
            .from(NETWORK_COPY)
            .name(UPDATED_NAME)
            .build();
    target.updateNetwork(updated);

    assertEquals("Number of networks did not match", 1, target.networks().size());
    assertEquals("Network did not match", UPDATED_NAME, target.network(NETWORK_ID).getName());
    validateEvents(OPENSTACK_NETWORK_CREATED, OPENSTACK_NETWORK_UPDATED);
}
 
Example #16
Source File: OpenstackNetworkManager.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void createNetwork(Network osNet) {
    checkNotNull(osNet, ERR_NULL_NETWORK);
    checkArgument(!Strings.isNullOrEmpty(osNet.getId()), ERR_NULL_NETWORK_ID);

    osNetworkStore.createNetwork(osNet);

    OpenstackNetwork finalAugmentedNetwork = buildAugmentedNetworkFromType(osNet);
    augmentedNetworkMap.compute(osNet.getId(), (id, existing) -> {
        final String error = osNet.getId() + ERR_DUPLICATE;
        checkArgument(existing == null, error);
        return finalAugmentedNetwork;
    });

    log.info(String.format(MSG_NETWORK, osNet.getName(), MSG_CREATED));
}
 
Example #17
Source File: OpenstackSwitchingHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
private void setNetworkBlockRules(Network network, boolean install) {

        Type type = osNetworkService.networkType(network.getId());

        // TODO: we block a network traffic by referring to segment ID for now
        // we might need to find a better way to block the traffic of a network
        // in case the segment ID is overlapped in different types network (VXLAN, GRE, VLAN)
        switch (type) {
            case VXLAN:
            case GRE:
            case GENEVE:
                setNetworkBlockRulesForTunnel(network.getProviderSegID(), install);
                break;
            case VLAN:
                setNetworkBlockRulesForVlan(network.getProviderSegID(), install);
                break;
            case FLAT:
                // TODO: need to find a way to block flat typed network
                break;
            default:
                break;
        }
    }
 
Example #18
Source File: OpenstackRoutingSnatHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
private void setSourceNat(RouterInterface routerIface, boolean install) {
    Subnet osSubnet = osNetworkAdminService.subnet(routerIface.getSubnetId());
    Network osNet = osNetworkAdminService.network(osSubnet.getNetworkId());
    Type netType = osNetworkAdminService.networkType(osSubnet.getNetworkId());

    osNodeService.completeNodes(COMPUTE).forEach(cNode -> {
        setRulesToGateway(cNode, osNet.getProviderSegID(),
                IpPrefix.valueOf(osSubnet.getCidr()), netType, install);
    });

    if (getStatefulSnatFlag()) {
        setStatefulSnatRules(routerIface, install);
    } else {
        setReactiveSnatRules(routerIface, install);
    }

    final String updateStr = install ? MSG_ENABLED : MSG_DISABLED;
    log.info(updateStr + "external access for subnet({})", osSubnet.getCidr());
}
 
Example #19
Source File: DistributedOpenstackNetworkStore.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void updateNetwork(Network osNet) {
    osNetworkStore.compute(osNet.getId(), (id, existing) -> {
        final String error = osNet.getName() + ERR_NOT_FOUND;
        checkArgument(existing != null, error);
        return osNet;
    });
}
 
Example #20
Source File: OpenstackRoutingSnatHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private void setReactiveSnatRules(RouterInterface routerIface, boolean install) {
    Subnet osSubnet = osNetworkAdminService.subnet(routerIface.getSubnetId());
    Network osNet = osNetworkAdminService.network(osSubnet.getNetworkId());
    Type netType = osNetworkAdminService.networkType(osSubnet.getNetworkId());

    osNodeService.completeNodes(GATEWAY)
            .forEach(gwNode -> setRulesToController(
                    gwNode.intgBridge(),
                    osNet.getProviderSegID(),
                    IpPrefix.valueOf(osSubnet.getCidr()),
                    netType,
                    install));
}
 
Example #21
Source File: DistributedOpenstackNetworkStore.java    From onos with Apache License 2.0 5 votes vote down vote up
@Activate
protected void activate() {
    ApplicationId appId = coreService.registerApplication(OPENSTACK_NETWORKING_APP_ID);

    osNetworkStore = storageService.<String, Network>consistentMapBuilder()
            .withSerializer(Serializer.using(SERIALIZER_NEUTRON_L2))
            .withName("openstack-networkstore")
            .withApplicationId(appId)
            .build();
    osNetworkStore.addListener(networkMapListener);

    osSubnetStore = storageService.<String, Subnet>consistentMapBuilder()
            .withSerializer(Serializer.using(SERIALIZER_NEUTRON_L2))
            .withName("openstack-subnetstore")
            .withApplicationId(appId)
            .build();
    osSubnetStore.addListener(subnetMapListener);

    osPortStore = storageService.<String, Port>consistentMapBuilder()
            .withSerializer(Serializer.using(SERIALIZER_NEUTRON_L2))
            .withName("openstack-portstore")
            .withApplicationId(appId)
            .build();
    osPortStore.addListener(portMapListener);

    externalPeerRouterStore = storageService.<String, ExternalPeerRouter>consistentMapBuilder()
            .withSerializer(Serializer.using(SERIALIZER_EXTERNAL_PEER_ROUTER_MAP))
            .withName("external-routermap")
            .withApplicationId(appId)
            .build();
    externalPeerRouterStore.addListener(peerRouterListener);

    log.info("Started");
}
 
Example #22
Source File: OpenstackSwitchingArpHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(OpenstackNetworkEvent event) {
    Network network = event.subject();

    if (network == null) {
        log.debug("Network is not specified.");
        return false;
    } else {
        return network.getProviderSegID() != null;
    }
}
 
Example #23
Source File: OpenstackNetworkManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public String segmentId(String netId) {
    Network network = network(netId);

    checkNotNull(network);

    return network.getProviderSegID();
}
 
Example #24
Source File: DistributedOpenstackNetworkStore.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void createNetwork(Network osNet) {
    osNetworkStore.compute(osNet.getId(), (id, existing) -> {
        final String error = osNet.getName() + ERR_DUPLICATE;
        checkArgument(existing == null, error);
        return osNet;
    });
}
 
Example #25
Source File: OpenstackSwitchingHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Obtains the VNI from the given instance port.
 *
 * @param instPort instance port object
 * @return Virtual Network Identifier (VNI)
 */
private Long getVni(InstancePort instPort) {
    Network osNet = osNetworkService.network(instPort.networkId());
    if (osNet == null || Strings.isNullOrEmpty(osNet.getProviderSegID())) {
        final String error =
                String.format(ERR_SET_FLOWS_VNI,
                    instPort, osNet == null ? STR_NONE : osNet.getName());
        throw new IllegalStateException(error);
    }
    return Long.valueOf(osNet.getProviderSegID());
}
 
Example #26
Source File: OpenstackSwitchingHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Obtains the VLAN ID from the given instance port.
 *
 * @param instPort instance port object
 * @return VLAN ID
 */
private VlanId getVlanId(InstancePort instPort) {
    Network osNet = osNetworkService.network(instPort.networkId());

    if (osNet == null || Strings.isNullOrEmpty(osNet.getProviderSegID())) {
        final String error =
                String.format(ERR_SET_FLOWS_VNI,
                    instPort, osNet == null ? STR_NONE : osNet.getName());
        throw new IllegalStateException(error);
    }

    return VlanId.vlanId(osNet.getProviderSegID());
}
 
Example #27
Source File: OpenstackRoutingSnatHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private void populateSnatFlowRules(InboundPacket packetIn,
                                   InstancePort srcInstPort,
                                   TpPort patPort, IpAddress externalIp,
                                   ExternalPeerRouter externalPeerRouter) {
    Network osNet = osNetworkService.network(srcInstPort.networkId());
    Type netType = osNetworkService.networkType(srcInstPort.networkId());

    if (osNet == null) {
        final String error = String.format("%s network %s not found",
                ERR_PACKET_IN, srcInstPort.networkId());
        throw new IllegalStateException(error);
    }

    setStatelessSnatDownstreamRules(srcInstPort,
            osNet.getProviderSegID(),
            netType,
            externalIp,
            externalPeerRouter,
            patPort,
            packetIn);

    setStatelessSnatUpstreamRules(osNet.getProviderSegID(),
            netType,
            externalIp,
            externalPeerRouter,
            patPort,
            packetIn);
}
 
Example #28
Source File: OpenstackSwitchingHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private void setUpstreamRulesForFlat(InstancePort instPort, boolean install) {
    TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchInPort(instPort.portNumber())
            .build();

    Network network = osNetworkService.network(instPort.networkId());

    if (network == null) {
        log.warn("The network does not exist");
        return;
    }

    deviceService.getPorts(instPort.deviceId()).stream()
            .filter(port -> {
                String annotPortName = port.annotations().value(PORT_NAME);
                String portName = structurePortName(INTEGRATION_TO_PHYSICAL_PREFIX
                        + network.getProviderPhyNet());
                return Objects.equals(annotPortName, portName);
            })
            .findAny().ifPresent(port -> {
                TrafficTreatment treatment = DefaultTrafficTreatment.builder()
                        .setOutput(port.number())
                        .build();

                osFlowRuleService.setRule(
                        appId,
                        instPort.deviceId(),
                        selector,
                        treatment,
                        PRIORITY_FLAT_UPSTREAM_RULE,
                        FLAT_TABLE,
                        install);
    });
}
 
Example #29
Source File: OpenstackNetworkManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private OpenstackNetwork buildAugmentedNetworkFromType(Network osNet) {
    OpenstackNetwork augmentedNetwork = null;
    if (osNet.getNetworkType() == null) {
        augmentedNetwork = new DefaultOpenstackNetwork(osNet.getId(), GENEVE);
    } else {
        switch (osNet.getNetworkType()) {
            case FLAT:
                augmentedNetwork = new DefaultOpenstackNetwork(osNet.getId(), FLAT);
                break;
            case VLAN:
                augmentedNetwork = new DefaultOpenstackNetwork(osNet.getId(), VLAN);
                break;
            case VXLAN:
                augmentedNetwork = new DefaultOpenstackNetwork(osNet.getId(), VXLAN);
                break;
            case GRE:
                augmentedNetwork = new DefaultOpenstackNetwork(osNet.getId(), GRE);
                break;
            case LOCAL:
                augmentedNetwork = new DefaultOpenstackNetwork(osNet.getId(), LOCAL);
                break;
            default:
                break;
        }
    }

    return augmentedNetwork;
}
 
Example #30
Source File: OpenstackSwitchingDhcpHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private DhcpOption doMtu(Subnet osSubnet) {
    DhcpOption option = new DhcpOption();
    option.setCode(DHCP_OPTION_MTU);
    option.setLength((byte) DHCP_OPTION_MTU_LENGTH);
    Network osNetwork = osNetworkService.network(osSubnet.getNetworkId());
    checkNotNull(osNetwork);
    checkNotNull(osNetwork.getMTU());

    option.setData(ByteBuffer.allocate(DHCP_OPTION_MTU_LENGTH)
                    .putShort(osNetwork.getMTU().shortValue()).array());

    return option;
}