Search in sources :

Example 6 with ExternalPeerRouter

use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.

the class OpenstackRoutingSnatHandler method routerUpdated.

private void routerUpdated(Router osRouter) {
    ExternalGateway exGateway = osRouter.getExternalGatewayInfo();
    ExternalPeerRouter externalPeerRouter = osNetworkAdminService.externalPeerRouter(exGateway);
    VlanId vlanId = externalPeerRouter == null ? VlanId.NONE : externalPeerRouter.vlanId();
    if (exGateway == null) {
        deleteUnassociatedExternalPeerRouter();
        osRouterService.routerInterfaces(osRouter.getId()).forEach(iface -> setSourceNat(iface, false));
    } else {
        osNetworkAdminService.deriveExternalPeerRouterMac(exGateway, osRouter, vlanId);
        osRouterService.routerInterfaces(osRouter.getId()).forEach(iface -> setSourceNat(iface, exGateway.isEnableSnat()));
    }
}
Also used : ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) ExternalGateway(org.openstack4j.model.network.ExternalGateway) VlanId(org.onlab.packet.VlanId)

Example 7 with ExternalPeerRouter

use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.

the class OpenstackRoutingFloatingIpHandler method processGratuitousArpPacket.

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);
}
Also used : ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) Network(org.openstack4j.model.network.Network) OpenstackNetworkingUtil.externalPeerRouterForNetwork(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.externalPeerRouterForNetwork) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Example 8 with ExternalPeerRouter

use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.

the class OpenstackRoutingFloatingIpHandler method setFloatingIpRules.

private void setFloatingIpRules(NetFloatingIP floatingIp, InstancePort instPort, OpenstackNode gateway, ExternalPeerRouter peerRouter, boolean install) {
    if (instPort == null) {
        log.debug("No instance port found");
        return;
    }
    Network osNet = osNetworkService.network(instPort.networkId());
    ExternalPeerRouter externalPeerRouter = peerRouter != null ? peerRouter : externalPeerRouterForNetwork(osNet, osNetworkService, osRouterAdminService);
    if (externalPeerRouter == null) {
        log.warn("External peer router is not ready for now, " + "floating IP rules will be installed/uninstalled " + "when external peer router is available...");
        return;
    }
    if (install) {
        preCommitPortService.subscribePreCommit(instPort.portId(), OPENSTACK_PORT_PRE_REMOVE, this.getClass().getName());
        log.info("Subscribed the port {} on listening pre-remove event", instPort.portId());
    } else {
        preCommitPortService.unsubscribePreCommit(instPort.portId(), OPENSTACK_PORT_PRE_REMOVE, instancePortService, this.getClass().getName());
        log.info("Unsubscribed the port {} on listening pre-remove event", instPort.portId());
    }
    updateComputeNodeRules(instPort, osNet, gateway, install);
    updateGatewayNodeRules(floatingIp, instPort, osNet, externalPeerRouter, gateway, install);
    // TODO: need to refactor setUpstreamRules if possible
    setUpstreamRules(floatingIp, osNet, instPort, externalPeerRouter, install);
    log.trace("Succeeded to set flow rules for floating ip {}:{} and install: {}", floatingIp.getFloatingIpAddress(), floatingIp.getFixedIpAddress(), install);
}
Also used : ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) Network(org.openstack4j.model.network.Network) OpenstackNetworkingUtil.externalPeerRouterForNetwork(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.externalPeerRouterForNetwork)

Example 9 with ExternalPeerRouter

use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.

the class ExternalPeerRouterCodecTest method testExternalPeerRouterEncode.

/**
 * Tests the external peer router encoding.
 */
@Test
public void testExternalPeerRouterEncode() {
    ExternalPeerRouter router = DefaultExternalPeerRouter.builder().ipAddress(IpAddress.valueOf("10.10.10.1")).macAddress(MacAddress.valueOf("11:22:33:44:55:66")).vlanId(VlanId.vlanId("1")).build();
    ObjectNode routerJson = externalPeerRouterCodec.encode(router, context);
    assertThat(routerJson, matchesExternalPeerRouter(router));
}
Also used : DefaultExternalPeerRouter(org.onosproject.openstacknetworking.impl.DefaultExternalPeerRouter) ExternalPeerRouterJsonMatcher.matchesExternalPeerRouter(org.onosproject.openstacknetworking.codec.ExternalPeerRouterJsonMatcher.matchesExternalPeerRouter) ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Test(org.junit.Test)

Example 10 with ExternalPeerRouter

use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.

the class DeleteExternalPeerRouterCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackNetworkAdminService service = get(OpenstackNetworkAdminService.class);
    if (service.externalPeerRouters().stream().noneMatch(router -> router.ipAddress().toString().equals(ipAddress))) {
        print(NO_ELEMENT);
        return;
    }
    try {
        service.deleteExternalPeerRouter(ipAddress);
    } catch (IllegalArgumentException e) {
        log.error("Exception occurred because of {}", e);
    }
    print(FORMAT, "Router IP", "Mac Address", "VLAN ID");
    List<ExternalPeerRouter> routers = Lists.newArrayList(service.externalPeerRouters());
    for (ExternalPeerRouter router : routers) {
        print(FORMAT, router.ipAddress(), router.macAddress().toString(), router.vlanId());
    }
}
Also used : ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService)

Aggregations

ExternalPeerRouter (org.onosproject.openstacknetworking.api.ExternalPeerRouter)17 IpAddress (org.onlab.packet.IpAddress)6 VlanId (org.onlab.packet.VlanId)4 OpenstackNetworkAdminService (org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService)4 Router (org.openstack4j.model.network.Router)4 Subnet (org.openstack4j.model.network.Subnet)4 List (java.util.List)3 OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)3 ExternalGateway (org.openstack4j.model.network.ExternalGateway)3 Network (org.openstack4j.model.network.Network)3 Lists (com.google.common.collect.Lists)2 Argument (org.apache.karaf.shell.api.action.Argument)2 Command (org.apache.karaf.shell.api.action.Command)2 Test (org.junit.Test)2 Ethernet (org.onlab.packet.Ethernet)2 IPv4 (org.onlab.packet.IPv4)2 MacAddress (org.onlab.packet.MacAddress)2 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)2 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)2 DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)2