Search in sources :

Example 1 with GATEWAY

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY in project onos by opennetworkinglab.

the class OpenstackRoutingHandler method setGatewayRules.

private void setGatewayRules(Subnet osSubnet, Router osRouter, boolean install) {
    OpenstackNode srcNatGw = osNodeService.completeNodes(GATEWAY).stream().findFirst().orElse(null);
    if (srcNatGw == null) {
        return;
    }
    if (Strings.isNullOrEmpty(osSubnet.getGateway())) {
        // do nothing if no gateway is set
        return;
    }
    Network net = osNetworkAdminService.network(osSubnet.getNetworkId());
    Type netType = osNetworkAdminService.networkType(osSubnet.getNetworkId());
    Set<Subnet> routableSubnets = routableSubnets(osRouter, osSubnet.getId());
    // install rules to each compute node for routing IP packets to gateways
    osNodeService.completeNodes(COMPUTE).stream().filter(cNode -> cNode.dataIp() != null).forEach(cNode -> setRulesToGatewayWithRoutableSubnets(cNode, srcNatGw, net.getProviderSegID(), osSubnet, routableSubnets, netType, install));
    // install rules to punt ICMP packets to controller at gateway node
    // this rule is only valid for stateless ICMP SNAT case
    osNodeService.completeNodes(GATEWAY).forEach(gNode -> setReactiveGatewayIcmpRule(IpAddress.valueOf(osSubnet.getGateway()), gNode.intgBridge(), install));
    final String updateStr = install ? MSG_ENABLED : MSG_DISABLED;
    log.debug(updateStr + "IP to {}", osSubnet.getGateway());
}
Also used : OpenstackRouterService(org.onosproject.openstacknetworking.api.OpenstackRouterService) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) Constants(org.onosproject.openstacknetworking.api.Constants) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) STAT_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.STAT_OUTBOUND_TABLE) Ethernet(org.onlab.packet.Ethernet) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) PRIORITY_INTERNAL_ROUTING_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_INTERNAL_ROUTING_RULE) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) ApplicationId(org.onosproject.core.ApplicationId) NodeId(org.onosproject.cluster.NodeId) PRIORITY_ICMP_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ICMP_RULE) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ImmutableSet(com.google.common.collect.ImmutableSet) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PRIORITY_ADMIN_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ADMIN_RULE) ICMP(org.onlab.packet.ICMP) USE_STATEFUL_SNAT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_STATEFUL_SNAT) Collectors(java.util.stream.Collectors) OpenstackNetworkingUtil.getPropertyValueAsBoolean(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValueAsBoolean) Objects(java.util.Objects) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) ClusterService(org.onosproject.cluster.ClusterService) DeviceId(org.onosproject.net.DeviceId) ROUTING_TABLE(org.onosproject.openstacknetworking.api.Constants.ROUTING_TABLE) IpPrefix(org.onlab.packet.IpPrefix) GATEWAY(org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) RulePopulatorUtil.buildExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension) RouterInterface(org.openstack4j.model.network.RouterInterface) OpenstackRouterEvent(org.onosproject.openstacknetworking.api.OpenstackRouterEvent) Strings(com.google.common.base.Strings) Component(org.osgi.service.component.annotations.Component) OpenstackNetworkingUtil.tunnelPortNumByNetType(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetType) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService) Router(org.openstack4j.model.network.Router) Activate(org.osgi.service.component.annotations.Activate) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ARP_MODE(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) PRIORITY_ICMP_REQUEST_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ICMP_REQUEST_RULE) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Subnet(org.openstack4j.model.network.Subnet) PRIORITY_SWITCHING_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_SWITCHING_RULE) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) IPv4(org.onlab.packet.IPv4) OpenstackRouterListener(org.onosproject.openstacknetworking.api.OpenstackRouterListener) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) OpenstackNetworkingUtil.getPropertyValue(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValue) ConfigProperty(org.onosproject.cfg.ConfigProperty) OpenstackNetworkingUtil.deriveResourceName(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.deriveResourceName) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) ARP_BROADCAST_MODE(org.onosproject.openstacknetworking.api.Constants.ARP_BROADCAST_MODE) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) OpenstackNetworkingUtil.tunnelPortNumByNetType(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetType) Network(org.openstack4j.model.network.Network) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Subnet(org.openstack4j.model.network.Subnet)

Example 2 with GATEWAY

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY in project onos by opennetworkinglab.

the class OpenstackRoutingSnatHandler method setStatefulSnatRules.

private void setStatefulSnatRules(RouterInterface routerIface, boolean install) {
    Subnet osSubnet = osNetworkAdminService.subnet(routerIface.getSubnetId());
    Network osNet = osNetworkAdminService.network(osSubnet.getNetworkId());
    Type netType = osNetworkAdminService.networkType(osSubnet.getNetworkId());
    if (netType == FLAT) {
        log.warn("FLAT typed network does not need SNAT rules");
        return;
    }
    Optional<Router> osRouter = osRouterService.routers().stream().filter(router -> routerIface.getId().equals(router.getId())).findAny();
    if (!osRouter.isPresent()) {
        log.warn("Cannot find a router attached with the given router interface {} ", routerIface);
        return;
    }
    IpAddress natAddress = externalGatewayIpSnatEnabled(osRouter.get(), osNetworkAdminService);
    if (natAddress == null) {
        log.debug("NAT address is not found");
        return;
    }
    IpAddress extRouterAddress = getGatewayIpAddress(osRouter.get());
    if (extRouterAddress == null) {
        log.warn("External router address is not found");
        return;
    }
    ExternalPeerRouter externalPeerRouter = osNetworkService.externalPeerRouter(extRouterAddress);
    if (externalPeerRouter == null) {
        log.warn("External peer router not found");
        return;
    }
    Map<OpenstackNode, PortRange> gwPortRangeMap = getAssignedPortsForGateway(ImmutableList.copyOf(osNodeService.nodes(GATEWAY)));
    osNodeService.completeNodes(GATEWAY).forEach(gwNode -> {
        if (install) {
            PortRange gwPortRange = gwPortRangeMap.get(gwNode);
            Map<String, PortRange> netPortRangeMap = getAssignedPortsForNet(getNetIdByRouterId(routerIface.getId()), gwPortRange.min(), gwPortRange.max());
            PortRange netPortRange = netPortRangeMap.get(osNet.getId());
            setStatefulSnatUpstreamRule(gwNode, natAddress, Long.parseLong(osNet.getProviderSegID()), externalPeerRouter, netPortRange.min(), netPortRange.max(), install);
        } else {
            setStatefulSnatUpstreamRule(gwNode, natAddress, Long.parseLong(osNet.getProviderSegID()), externalPeerRouter, 0, 0, install);
        }
    });
}
Also used : ConsistentMap(org.onosproject.store.service.ConsistentMap) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) Constants(org.onosproject.openstacknetworking.api.Constants) InstancePortEvent(org.onosproject.openstacknetworking.api.InstancePortEvent) DriverService(org.onosproject.net.driver.DriverService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) USE_STATEFUL_SNAT_DEFAULT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_STATEFUL_SNAT_DEFAULT) StorageService(org.onosproject.store.service.StorageService) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) OpenstackNetworkingUtil.externalGatewayIpSnatEnabled(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.externalGatewayIpSnatEnabled) USE_STATEFUL_SNAT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.USE_STATEFUL_SNAT) RulePopulatorUtil(org.onosproject.openstacknetworking.util.RulePopulatorUtil) InstancePortListener(org.onosproject.openstacknetworking.api.InstancePortListener) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) OpenstackNetworkingUtil.externalPeerRouterFromSubnet(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.externalPeerRouterFromSubnet) PRIORITY_EXTERNAL_ROUTING_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_EXTERNAL_ROUTING_RULE) DeviceId(org.onosproject.net.DeviceId) ROUTING_TABLE(org.onosproject.openstacknetworking.api.Constants.ROUTING_TABLE) Dictionary(java.util.Dictionary) Tools(org.onlab.util.Tools) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) ComponentContext(org.osgi.service.component.ComponentContext) KryoNamespace(org.onlab.util.KryoNamespace) RouterInterface(org.openstack4j.model.network.RouterInterface) Component(org.osgi.service.component.annotations.Component) GW_COMMON_TABLE(org.onosproject.openstacknetworking.api.Constants.GW_COMMON_TABLE) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService) DEFAULT_GATEWAY_MAC(org.onosproject.openstacknetworking.api.Constants.DEFAULT_GATEWAY_MAC) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Port(org.openstack4j.model.network.Port) TpPort(org.onlab.packet.TpPort) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) VlanId(org.onlab.packet.VlanId) MoreObjects(com.google.common.base.MoreObjects) IPv4(org.onlab.packet.IPv4) OpenstackRouterListener(org.onosproject.openstacknetworking.api.OpenstackRouterListener) ConfigProperty(org.onosproject.cfg.ConfigProperty) LeadershipService(org.onosproject.cluster.LeadershipService) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) OpenstackRouterService(org.onosproject.openstacknetworking.api.OpenstackRouterService) CoreService(org.onosproject.core.CoreService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) OpenstackNetworkListener(org.onosproject.openstacknetworking.api.OpenstackNetworkListener) TCP(org.onlab.packet.TCP) ByteBuffer(java.nio.ByteBuffer) Ethernet(org.onlab.packet.Ethernet) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) VLAN(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type.VLAN) OpenstackNetworkEvent(org.onosproject.openstacknetworking.api.OpenstackNetworkEvent) NodeId(org.onosproject.cluster.NodeId) Serializer(org.onosproject.store.service.Serializer) ImmutableSet(com.google.common.collect.ImmutableSet) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) Collectors(java.util.stream.Collectors) OpenstackNetworkingUtil.getPropertyValueAsBoolean(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValueAsBoolean) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PRIORITY_SNAT_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_SNAT_RULE) FLAT(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type.FLAT) PacketContext(org.onosproject.net.packet.PacketContext) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) IpPrefix(org.onlab.packet.IpPrefix) PRIORITY_STATEFUL_SNAT_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_STATEFUL_SNAT_RULE) GATEWAY(org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) RulePopulatorUtil.buildExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildExtension) OpenstackRouterEvent(org.onosproject.openstacknetworking.api.OpenstackRouterEvent) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) OpenstackNetworkingUtil.tunnelPortNumByNetType(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetType) ImmutableList(com.google.common.collect.ImmutableList) Router(org.openstack4j.model.network.Router) IP(org.openstack4j.model.network.IP) Activate(org.osgi.service.component.annotations.Activate) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) ExternalGateway(org.openstack4j.model.network.ExternalGateway) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) Subnet(org.openstack4j.model.network.Subnet) Maps(com.google.common.collect.Maps) UDP(org.onlab.packet.UDP) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) CT_NAT_SRC_FLAG(org.onosproject.openstacknetworking.util.RulePopulatorUtil.CT_NAT_SRC_FLAG) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) DistributedSet(org.onosproject.store.service.DistributedSet) OpenstackNetworkingUtil.getRouterFromSubnet(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getRouterFromSubnet) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OpenstackNetworkingUtil.deriveResourceName(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.deriveResourceName) Reference(org.osgi.service.component.annotations.Reference) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) Router(org.openstack4j.model.network.Router) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) Type(org.onosproject.openstacknetworking.api.OpenstackNetwork.Type) OpenstackNetworkingUtil.tunnelPortNumByNetType(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.tunnelPortNumByNetType) Network(org.openstack4j.model.network.Network) IpAddress(org.onlab.packet.IpAddress) OpenstackNetworkingUtil.externalPeerRouterFromSubnet(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.externalPeerRouterFromSubnet) Subnet(org.openstack4j.model.network.Subnet) OpenstackNetworkingUtil.getRouterFromSubnet(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getRouterFromSubnet)

Example 3 with GATEWAY

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY in project onos by opennetworkinglab.

the class OpenstackRoutingArpHandler method processArpPacket.

private void processArpPacket(PacketContext context, Ethernet ethernet) {
    ARP arp = (ARP) ethernet.getPayload();
    if (arp.getOpCode() == ARP.OP_REQUEST && ARP_PROXY_MODE.equals(getArpMode())) {
        if (log.isTraceEnabled()) {
            log.trace("ARP request received from {} for {}", Ip4Address.valueOf(arp.getSenderProtocolAddress()).toString(), Ip4Address.valueOf(arp.getTargetProtocolAddress()).toString());
        }
        IpAddress targetIp = Ip4Address.valueOf(arp.getTargetProtocolAddress());
        MacAddress targetMac = null;
        NetFloatingIP floatingIP = osRouterAdminService.floatingIps().stream().filter(ip -> ip.getFloatingIpAddress().equals(targetIp.toString())).findAny().orElse(null);
        // In case target ip is for associated floating ip, sets target mac to vm's.
        if (floatingIP != null && floatingIP.getPortId() != null) {
            InstancePort instPort = instancePortService.instancePort(floatingIP.getPortId());
            if (instPort == null) {
                log.trace("Unknown target ARP request for {}, ignore it", targetIp);
                return;
            } else {
                targetMac = instPort.macAddress();
            }
            OpenstackNode gw = getGwByInstancePort(osNodeService.completeNodes(GATEWAY), instPort);
            if (gw == null) {
                return;
            }
            // if the ARP packet_in received from non-relevant GWs, we simply ignore it
            if (!Objects.equals(gw.intgBridge(), context.inPacket().receivedFrom().deviceId())) {
                return;
            }
        }
        if (isExternalGatewaySourceIp(targetIp)) {
            targetMac = Constants.DEFAULT_GATEWAY_MAC;
        }
        if (targetMac == null) {
            log.trace("Unknown target ARP request for {}, ignore it", targetIp);
            return;
        }
        Ethernet ethReply = ARP.buildArpReply(targetIp.getIp4Address(), targetMac, ethernet);
        TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(context.inPacket().receivedFrom().port()).build();
        packetService.emit(new DefaultOutboundPacket(context.inPacket().receivedFrom().deviceId(), treatment, ByteBuffer.wrap(ethReply.serialize())));
        context.block();
    }
    if (arp.getOpCode() == ARP.OP_REPLY) {
        ConnectPoint cp = context.inPacket().receivedFrom();
        PortNumber receivedPortNum = cp.port();
        IpAddress spa = Ip4Address.valueOf(arp.getSenderProtocolAddress());
        MacAddress sha = MacAddress.valueOf(arp.getSenderHardwareAddress());
        log.debug("ARP reply ip: {}, mac: {}", spa, sha);
        try {
            Set<String> extRouterIps = osNetworkService.externalPeerRouters().stream().map(r -> r.ipAddress().toString()).collect(Collectors.toSet());
            // if SPA is NOT contained in existing external router IP set, we ignore it
            if (!extRouterIps.contains(spa.toString())) {
                return;
            }
            OpenstackNode node = osNodeService.node(cp.deviceId());
            if (node == null) {
                return;
            }
            // we only handles the ARP-Reply message received by gateway node
            if (node.type() != GATEWAY) {
                return;
            }
            if (receivedPortNum.equals(node.uplinkPortNum())) {
                osNetworkAdminService.updateExternalPeerRouterMac(spa, sha);
            }
        } catch (Exception e) {
            log.error("Exception occurred because of {}", e);
        }
    }
}
Also used : OpenstackNetworkingUtil.getGwByInstancePort(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getGwByInstancePort) OpenstackNetworkingUtil.processGarpPacketForFloatingIp(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.processGarpPacketForFloatingIp) CoreService(org.onosproject.core.CoreService) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) OpenstackRouterAdminService(org.onosproject.openstacknetworking.api.OpenstackRouterAdminService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) ARP(org.onlab.packet.ARP) Constants(org.onosproject.openstacknetworking.api.Constants) OpenstackNetworkListener(org.onosproject.openstacknetworking.api.OpenstackNetworkListener) OpenstackNetworkingUtil.externalGatewayIp(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.externalGatewayIp) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) InstancePortAdminService(org.onosproject.openstacknetworking.api.InstancePortAdminService) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) ApplicationId(org.onosproject.core.ApplicationId) RulePopulatorUtil.buildMoveEthSrcToDstExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveEthSrcToDstExtension) RulePopulatorUtil.buildMoveArpShaToThaExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveArpShaToThaExtension) OpenstackNetworkEvent(org.onosproject.openstacknetworking.api.OpenstackNetworkEvent) ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) NodeId(org.onosproject.cluster.NodeId) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ImmutableSet(com.google.common.collect.ImmutableSet) Ip4Address(org.onlab.packet.Ip4Address) Device(org.onosproject.net.Device) OpenstackFlowRuleService(org.onosproject.openstacknetworking.api.OpenstackFlowRuleService) ARP_PROXY_MODE(org.onosproject.openstacknetworking.api.Constants.ARP_PROXY_MODE) Deactivate(org.osgi.service.component.annotations.Deactivate) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) EthType(org.onlab.packet.EthType) InboundPacket(org.onosproject.net.packet.InboundPacket) NetFloatingIP(org.openstack4j.model.network.NetFloatingIP) OPENSTACK_NETWORKING_APP_ID(org.onosproject.openstacknetworking.api.Constants.OPENSTACK_NETWORKING_APP_ID) OpenstackNetworkingUtil.getGwByComputeDevId(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getGwByComputeDevId) PacketContext(org.onosproject.net.packet.PacketContext) ClusterService(org.onosproject.cluster.ClusterService) ARP_MODE_DEFAULT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE_DEFAULT) OpenstackNetworkingUtil.floatingIpByInstancePort(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.floatingIpByInstancePort) DeviceId(org.onosproject.net.DeviceId) GATEWAY(org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Network(org.openstack4j.model.network.Network) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) GATEWAY_MAC_DEFAULT(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.GATEWAY_MAC_DEFAULT) ComponentContext(org.osgi.service.component.ComponentContext) RulePopulatorUtil.buildMoveArpSpaToTpaExtension(org.onosproject.openstacknetworking.util.RulePopulatorUtil.buildMoveArpSpaToTpaExtension) OpenstackRouterEvent(org.onosproject.openstacknetworking.api.OpenstackRouterEvent) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Component(org.osgi.service.component.annotations.Component) GW_COMMON_TABLE(org.onosproject.openstacknetworking.api.Constants.GW_COMMON_TABLE) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService) Objects.requireNonNull(java.util.Objects.requireNonNull) Router(org.openstack4j.model.network.Router) IP(org.openstack4j.model.network.IP) Activate(org.osgi.service.component.annotations.Activate) OpenstackNetworkingUtil.externalPeerRouterForNetwork(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.externalPeerRouterForNetwork) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ARP_MODE(org.onosproject.openstacknetworking.impl.OsgiPropertyConstants.ARP_MODE) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) Port(org.openstack4j.model.network.Port) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) PRIORITY_ARP_GATEWAY_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_GATEWAY_RULE) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) OpenstackRouterListener(org.onosproject.openstacknetworking.api.OpenstackRouterListener) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) OpenstackNetworkingUtil.getPropertyValue(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getPropertyValue) ConfigProperty(org.onosproject.cfg.ConfigProperty) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) PRIORITY_ARP_CONTROL_RULE(org.onosproject.openstacknetworking.api.Constants.PRIORITY_ARP_CONTROL_RULE) LeadershipService(org.onosproject.cluster.LeadershipService) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) ARP_BROADCAST_MODE(org.onosproject.openstacknetworking.api.Constants.ARP_BROADCAST_MODE) OpenstackNetworkingUtil.getGwByInstancePort(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getGwByInstancePort) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) OpenstackNetworkingUtil.floatingIpByInstancePort(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.floatingIpByInstancePort) NetFloatingIP(org.openstack4j.model.network.NetFloatingIP) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) MacAddress(org.onlab.packet.MacAddress) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) IpAddress(org.onlab.packet.IpAddress) PortNumber(org.onosproject.net.PortNumber) ARP(org.onlab.packet.ARP)

Example 4 with GATEWAY

use of org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY in project onos by opennetworkinglab.

the class OpenstackNorthSouthProbeCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackTroubleshootService tsService = get(OpenstackTroubleshootService.class);
    InstancePortService instPortService = get(InstancePortService.class);
    OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
    MastershipService mastershipService = get(MastershipService.class);
    ClusterService clusterService = get(ClusterService.class);
    if (tsService == null || osNodeService == null || instPortService == null || mastershipService == null) {
        error("Failed to troubleshoot openstack networking.");
        return;
    }
    if ((!isAll && vmIps == null) || (isAll && vmIps != null)) {
        print("Please specify one of VM IP address or -a option.");
        return;
    }
    NodeId localNodeId = clusterService.getLocalNode().id();
    for (OpenstackNode gw : osNodeService.completeNodes(GATEWAY)) {
        if (!localNodeId.equals(mastershipService.getMasterFor(gw.intgBridge()))) {
            error("Current node is not the master for all gateway nodes. " + "Please enforce mastership first using openstack-reset-mastership -c !");
            return;
        }
    }
    if (isAll) {
        printHeader();
        // send ICMP PACKET_OUT to all connect VMs whose instance port state is ACTIVE
        instPortService.instancePorts().stream().filter(p -> p.state() == ACTIVE).filter(p -> instPortService.floatingIp(p.portId()) != null).forEach(port -> printReachability(tsService.probeNorthSouth(port)));
    } else {
        final Set<InstancePort> ports = Sets.newConcurrentHashSet();
        for (String ip : vmIps) {
            instPortService.instancePorts().stream().filter(p -> p.state().equals(InstancePort.State.ACTIVE)).filter(p -> instPortService.floatingIp(p.portId()) != null).filter(p -> ip.equals(instPortService.floatingIp(p.portId()).toString())).forEach(ports::add);
        }
        printHeader();
        ports.forEach(port -> probeExecutor.execute(() -> printReachability(tsService.probeNorthSouth(port))));
    }
}
Also used : NodeId(org.onosproject.cluster.NodeId) GATEWAY(org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ACTIVE(org.onosproject.openstacknetworking.api.InstancePort.State.ACTIVE) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) Set(java.util.Set) Argument(org.apache.karaf.shell.api.action.Argument) Sets(com.google.common.collect.Sets) Command(org.apache.karaf.shell.api.action.Command) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) OpenstackTroubleshootService(org.onosproject.openstacktroubleshoot.api.OpenstackTroubleshootService) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) Reachability(org.onosproject.openstacktroubleshoot.api.Reachability) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Completion(org.apache.karaf.shell.api.action.Completion) ClusterService(org.onosproject.cluster.ClusterService) Option(org.apache.karaf.shell.api.action.Option) MastershipService(org.onosproject.mastership.MastershipService) ExecutorService(java.util.concurrent.ExecutorService) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) ClusterService(org.onosproject.cluster.ClusterService) OpenstackTroubleshootService(org.onosproject.openstacktroubleshoot.api.OpenstackTroubleshootService) InstancePortService(org.onosproject.openstacknetworking.api.InstancePortService) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) NodeId(org.onosproject.cluster.NodeId) MastershipService(org.onosproject.mastership.MastershipService) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Aggregations

Set (java.util.Set)4 ExecutorService (java.util.concurrent.ExecutorService)4 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)4 ClusterService (org.onosproject.cluster.ClusterService)4 NodeId (org.onosproject.cluster.NodeId)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 Sets (com.google.common.collect.Sets)3 Objects (java.util.Objects)3 Collectors (java.util.stream.Collectors)3 Ethernet (org.onlab.packet.Ethernet)3 IpAddress (org.onlab.packet.IpAddress)3 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)3 ConfigProperty (org.onosproject.cfg.ConfigProperty)3 LeadershipService (org.onosproject.cluster.LeadershipService)3 ApplicationId (org.onosproject.core.ApplicationId)3 CoreService (org.onosproject.core.CoreService)3 DeviceId (org.onosproject.net.DeviceId)3 PortNumber (org.onosproject.net.PortNumber)3 DeviceService (org.onosproject.net.device.DeviceService)3 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3