org.onosproject.net.ConnectPoint Java Examples

The following examples show how to use org.onosproject.net.ConnectPoint. 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: VirtualNetworkHostManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Sets up a virtual network with hosts.
 *
 * @return virtual network
 */
private VirtualNetwork setupVnet() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));

    VirtualDevice virtualDevice1 =
            manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice virtualDevice2 =
            manager.createVirtualDevice(virtualNetwork.id(), DID2);

    ConnectPoint hostCp1 = new ConnectPoint(DID1, P1);
    ConnectPoint hostCp2 = new ConnectPoint(DID2, P2);
    manager.createVirtualPort(virtualNetwork.id(), hostCp1.deviceId(), hostCp1.port(),
            new ConnectPoint(virtualDevice1.id(), hostCp1.port()));
    manager.createVirtualPort(virtualNetwork.id(), hostCp2.deviceId(), hostCp2.port(),
            new ConnectPoint(virtualDevice2.id(), hostCp2.port()));

    manager.createVirtualHost(virtualNetwork.id(), HID1, MAC1, VLAN1, LOC1, IPSET1);
    manager.createVirtualHost(virtualNetwork.id(), HID2, MAC2, VLAN2, LOC2, IPSET2);
    return virtualNetwork;
}
 
Example #2
Source File: IsisTopologyProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void addLink(IsisLink isisLink) {
    log.debug("Addlink {}", isisLink.localSystemId());

    LinkDescription linkDes = buildLinkDes(isisLink);
    //Updating ports of the link
    //If already link exists, return
    if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) {
        return;
    }
    ConnectPoint destconnectPoint = linkDes.dst();
    PortNumber destport = destconnectPoint.port();
    if (destport.toLong() != 0) {
        deviceProviderService.updatePorts(linkDes.src().deviceId(),
                                          buildPortDescriptions(linkDes.src().deviceId(),
                                          linkDes.src().port()));
        deviceProviderService.updatePorts(linkDes.dst().deviceId(),
                                          buildPortDescriptions(linkDes.dst().deviceId(),
                                          linkDes.dst().port()));
        registerBandwidth(linkDes, isisLink);
        linkProviderService.linkDetected(linkDes);
        System.out.println("link desc " + linkDes.toString());
    }
}
 
Example #3
Source File: VirtualNetworkIntent.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new point-to-point intent with the supplied ingress/egress
 * ports and constraints.
 *
 * @param networkId    virtual network identifier
 * @param appId        application identifier
 * @param key          key of the intent
 * @param selector     traffic selector
 * @param treatment    treatment
 * @param ingressPoint ingress port
 * @param egressPoint  egress port
 * @param constraints  optional list of constraints
 * @param priority     priority to use for flows generated by this intent
 * @throws NullPointerException if {@code ingressPoint} or
 *                              {@code egressPoints} or {@code appId} is null.
 */
private VirtualNetworkIntent(NetworkId networkId,
                             ApplicationId appId,
                             Key key,
                             TrafficSelector selector,
                             TrafficTreatment treatment,
                             ConnectPoint ingressPoint,
                             ConnectPoint egressPoint,
                             List<Constraint> constraints,
                             int priority,
                             ResourceGroup resourceGroup) {
    super(appId, key, Collections.emptyList(), selector, treatment, constraints,
          priority, resourceGroup);

    checkNotNull(networkId, NETWORK_ID_NULL);
    checkArgument(!ingressPoint.equals(egressPoint),
                  "ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint);

    this.networkId = networkId;
    this.ingressPoint = checkNotNull(ingressPoint);
    this.egressPoint = checkNotNull(egressPoint);
}
 
Example #4
Source File: VirtualNetworkManager.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Determines if the virtual link (both source and destination connect point)
 * is in a cluster.
 *
 * @param networkId   virtual network identifier
 * @param virtualLink virtual link
 * @param clusters    topology clusters
 * @return true if the virtual link is in a cluster.
 */
private boolean isVirtualLinkInCluster(NetworkId networkId, VirtualLink virtualLink,
                                       Set<Set<ConnectPoint>> clusters) {
    ConnectPoint srcPhysicalCp =
            mapVirtualToPhysicalPort(networkId, virtualLink.src());
    ConnectPoint dstPhysicalCp =
            mapVirtualToPhysicalPort(networkId, virtualLink.dst());

    final boolean[] foundSrc = {false};
    final boolean[] foundDst = {false};
    clusters.forEach(connectPoints -> {
        connectPoints.forEach(connectPoint -> {
            if (connectPoint.equals(srcPhysicalCp)) {
                foundSrc[0] = true;
            } else if (connectPoint.equals(dstPhysicalCp)) {
                foundDst[0] = true;
            }
        });
        if (foundSrc[0] && foundDst[0]) {
            return;
        }
    });
    return foundSrc[0] && foundDst[0];
}
 
Example #5
Source File: VirtualNetworkLinkManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the getLink() method using a null src connect point.
 */
@Test(expected = NullPointerException.class)
public void testGetLinkByNullSrc() {

    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice srcVirtualDevice =
            manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice =
            manager.createVirtualDevice(virtualNetwork.id(), DID2);
    ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualLink(virtualNetwork.id(), src, dst);
    manager.createVirtualLink(virtualNetwork.id(), dst, src);

    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);

    // test the getLink() method with a null src connect point.
    linkService.getLink(null, dst);
}
 
Example #6
Source File: IntentPerfInstaller.java    From onos with Apache License 2.0 6 votes vote down vote up
private Intent createIntent(Key key, long mac, NodeId node, Multimap<NodeId, Device> devices) {
    // choose a random device for which this node is master
    List<Device> deviceList = devices.get(node).stream().collect(Collectors.toList());
    Device device = deviceList.get(RandomUtils.nextInt(deviceList.size()));

    //FIXME we currently ignore the path length and always use the same device
    TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchEthDst(MacAddress.valueOf(mac)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    ConnectPoint ingress = new ConnectPoint(device.id(), PortNumber.portNumber(1));
    ConnectPoint egress = new ConnectPoint(device.id(), PortNumber.portNumber(2));

    return PointToPointIntent.builder()
            .appId(appId)
            .key(key)
            .selector(selector)
            .treatment(treatment)
            .filteredIngressPoint(new FilteredConnectPoint(ingress))
            .filteredEgressPoint(new FilteredConnectPoint(egress))
            .build();
}
 
Example #7
Source File: DistributedVirtualNetworkStore.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public VirtualLink getLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst) {
    Set<VirtualLink> virtualLinkSet = networkIdVirtualLinkSetMap.get(networkId);
    if (virtualLinkSet == null) {
        return null;
    }

    VirtualLink virtualLink = null;
    for (VirtualLink link : virtualLinkSet) {
        if (src == null && link.dst().equals(dst)) {
            virtualLink = link;
            break;
        } else if (dst == null && link.src().equals(src)) {
            virtualLink = link;
            break;
        } else if (link.src().equals(src) && link.dst().equals(dst)) {
            virtualLink = link;
            break;
        }
    }
    return virtualLink;
}
 
Example #8
Source File: SimpleLinkStoreTest.java    From onos with Apache License 2.0 6 votes vote down vote up
@Test
public final void testGetDeviceIngressLinks() {
    LinkKey linkId1 = LinkKey.linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2));
    LinkKey linkId2 = LinkKey.linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1));
    LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3));

    putLink(linkId1, DIRECT);
    putLink(linkId2, DIRECT);
    putLink(linkId3, DIRECT);

    // DID1,P1 => DID2,P2
    // DID2,P2 => DID1,P1
    // DID1,P2 => DID2,P3

    Set<Link> links1 = linkStore.getDeviceIngressLinks(DID2);
    assertEquals(2, links1.size());
    // check

    Set<Link> links2 = linkStore.getDeviceIngressLinks(DID1);
    assertEquals(1, links2.size());
    assertLink(linkId2, DIRECT, links2.iterator().next());
}
 
Example #9
Source File: ControlPlaneRedirectManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Tests adding while updating the networkConfig.
 */
@Test
public void testUpdateNetworkConfig() {
    ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4));
    List<InterfaceIpAddress> interfaceIpAddresses = new ArrayList<>();
    interfaceIpAddresses.add(
            new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24"))
    );
    interfaceIpAddresses.add(
            new InterfaceIpAddress(IpAddress.valueOf("2000::ff"), IpPrefix.valueOf("2000::ff/120"))
    );

    Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses,
            MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE);
    interfaces.add(sw1Eth4);
    EasyMock.reset(flowObjectiveService);
    setUpFlowObjectiveService();
    networkConfigListener
            .event(new NetworkConfigEvent(Type.CONFIG_UPDATED, dev3, RoutingService.ROUTER_CONFIG_CLASS));
    networkConfigService.addListener(networkConfigListener);
    verify(flowObjectiveService);
}
 
Example #10
Source File: PortWaveLengthCommand.java    From onos with Apache License 2.0 6 votes vote down vote up
private OchSignal createOchSignalFromWavelength(DeviceService deviceService, ConnectPoint cp) {
    long wavelength = Long.parseLong(parameter);
    if (wavelength == 0L) {
        return null;
    }
    Port port = deviceService.getPort(cp);
    Optional<OchPort> ochPortOpt = OchPortHelper.asOchPort(port);

    if (ochPortOpt.isPresent()) {
        OchPort ochPort = ochPortOpt.get();
        GridType gridType = ochPort.lambda().gridType();
        ChannelSpacing channelSpacing = ochPort.lambda().channelSpacing();
        int slotGranularity = ochPort.lambda().slotGranularity();
        int multiplier = getMultplier(wavelength, gridType, channelSpacing);
        return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
    } else {
        print("Connect point %s is not OChPort", cp);
        return null;
    }

}
 
Example #11
Source File: GetFlowStatisticsCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
private void printPortSummaryLoad(ConnectPoint cp, SummaryFlowEntryWithLoad summaryFlowLoad) {
    print("  deviceId/Port=%s/%s, Total=%s, Immediate=%s, Short=%s, Mid=%s, Long=%s, Unknown=%s",
            cp.elementId(),
            cp.port(),
            summaryFlowLoad.totalLoad().isValid() ? summaryFlowLoad.totalLoad() : "Load{rate=0, NOT VALID}",
            summaryFlowLoad.immediateLoad().isValid() ? summaryFlowLoad.immediateLoad() : "Load{rate=0, NOT VALID}",
            summaryFlowLoad.shortLoad().isValid() ? summaryFlowLoad.shortLoad() : "Load{rate=0, NOT VALID}",
            summaryFlowLoad.midLoad().isValid() ? summaryFlowLoad.midLoad() : "Load{rate=0, NOT VALID}",
            summaryFlowLoad.longLoad().isValid() ? summaryFlowLoad.longLoad() : "Load{rate=0, NOT VALID}",
            summaryFlowLoad.unknownLoad().isValid() ? summaryFlowLoad.unknownLoad() : "Load{rate=0, NOT VALID}");
}
 
Example #12
Source File: TopologyViewMessageHandlerBase.java    From onos with Apache License 2.0 5 votes vote down vote up
protected PropertyPanel edgeLinkDetails(HostId hid, ConnectPoint cp) {
    log.debug("generate prop panel data for edgelink {} {}", hid, cp);
    LionBundle lion = getLionBundle(LION_TOPO);
    String title = lion.getSafe("title_edge_link");

    PropertyPanel pp = new PropertyPanel(title, LINK_GLYPH);
    addLinkHostProps(pp, hid, lion);
    addLinkCpBProps(pp, cp, lion);
    return pp;
}
 
Example #13
Source File: DistributedMcastRoutesStore.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void removeSinks(McastRoute route, HostId hostId, Set<ConnectPoint> sinks) {
    mcastRoutes.compute(route, (k, v) -> {
        v.removeSinks(hostId, sinks);
        return v;
    });
}
 
Example #14
Source File: AddPointToPointIntentCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected void doExecute() {
    IntentService service = get(IntentService.class);

    ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);

    ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);

    TrafficSelector selector = buildTrafficSelector();
    TrafficTreatment treatment = buildTrafficTreatment();

    List<Constraint> constraints = buildConstraints();
    if (backup) {
        constraints.add(protection());
    }

    if (useProtected) {
        constraints.add(ProtectedConstraint.useProtectedLink());
    }

    Intent intent = PointToPointIntent.builder()
            .appId(appId())
            .key(key())
            .selector(selector)
            .treatment(treatment)
            .filteredIngressPoint(new FilteredConnectPoint(ingress))
            .filteredEgressPoint(new FilteredConnectPoint(egress))
            .constraints(constraints)
            .priority(priority())
            .resourceGroup(resourceGroup())
            .build();
    service.submit(intent);
    print("Point to point intent submitted:\n%s", intent.toString());
}
 
Example #15
Source File: OplinkSwitchProtection.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Void> switchToManual(ConnectPoint identifier, int index) {
    return getProtectionEndpointConfig(identifier)
            .thenApply(m -> m.paths().get(index))
            .thenApply(m -> switchDevice(m.output().connectPoint().port()))
            .thenApply(m -> null);
}
 
Example #16
Source File: SimpleFabricRouting.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void process(PacketContext context) {
    InboundPacket pkt = context.inPacket();
    Ethernet ethPkt = pkt.parsed();
    if (ethPkt == null) {
        return;
    }
    ConnectPoint srcCp = pkt.receivedFrom();
    IpAddress srcIp;
    IpAddress dstIp;
    byte ipProto = 0;  /* 0 or tcp, udp */

    switch (EthType.EtherType.lookup(ethPkt.getEtherType())) {
    case IPV4:
        IPv4 ipv4Packet = (IPv4) ethPkt.getPayload();
        srcIp = IpAddress.valueOf(ipv4Packet.getSourceAddress());
        dstIp = IpAddress.valueOf(ipv4Packet.getDestinationAddress());
        ipProto = ipv4Packet.getProtocol();
        break;
    case IPV6:
        IPv6 ipv6Packet = (IPv6) ethPkt.getPayload();
        srcIp = IpAddress.valueOf(IpAddress.Version.INET6, ipv6Packet.getSourceAddress());
        dstIp = IpAddress.valueOf(IpAddress.Version.INET6, ipv6Packet.getDestinationAddress());
        ipProto = ipv6Packet.getNextHeader();
        break;
    default:
        return;  // ignore unknow ether type packets
    }
    if (ipProto != 6 && ipProto != 17) {
        ipProto = 0;  /* handle special for TCP and UDP only */
    }

    if (!checkVirtualGatewayIpPacket(pkt, srcIp, dstIp)) {
        ipPacketReactiveProcessor(context, ethPkt, srcCp, srcIp, dstIp, ipProto);
        // TODO: add ReactiveRouting for dstIp to srcIp with discovered egressCp as srcCp
    }
}
 
Example #17
Source File: DefaultTopologyTest.java    From onos with Apache License 2.0 5 votes vote down vote up
public static Link link(String src, int sp, String dst, int dp) {
    return DefaultLink.builder().providerId(PID)
            .src(new ConnectPoint(did(src), portNumber(sp)))
            .dst(new ConnectPoint(did(dst), portNumber(dp)))
            .type(Link.Type.DIRECT)
            .build();
}
 
Example #18
Source File: DefaultNeighbourMessageContext.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts context information from NDP packets.
 *
 * @param eth input Ethernet frame that is thought to be NDP
 * @param inPort in port
 * @param actions actions to take
 * @return MessageContext object if the packet was a valid NDP packet,
 * otherwise null
 */
private static NeighbourMessageContext createNdpContext(Ethernet eth,
                                                        ConnectPoint inPort,
                                                        NeighbourMessageActions actions) {
    if (eth.getEtherType() != Ethernet.TYPE_IPV6) {
        return null;
    }
    IPv6 ipv6 = (IPv6) eth.getPayload();

    if (ipv6.getNextHeader() != IPv6.PROTOCOL_ICMP6) {
        return null;
    }
    ICMP6 icmpv6 = (ICMP6) ipv6.getPayload();

    IpAddress sender = Ip6Address.valueOf(ipv6.getSourceAddress());
    IpAddress target;

    NeighbourMessageType type;
    if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) {
        type = NeighbourMessageType.REQUEST;
        NeighborSolicitation nsol = (NeighborSolicitation) icmpv6.getPayload();
        target = Ip6Address.valueOf(nsol.getTargetAddress());
    } else if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_ADVERTISEMENT) {
        type = NeighbourMessageType.REPLY;
        /*
         * sender and target are the same in the reply.
         * We use as target the destination ip.
         */
        target = Ip6Address.valueOf(ipv6.getDestinationAddress());
    } else {
        return null;
    }

    return new DefaultNeighbourMessageContext(actions, eth, inPort,
            NeighbourProtocol.NDP, type, target, sender);
}
 
Example #19
Source File: TroubleshootManager.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the rule in the device that mathces the input packet and has the highest priority.
 *
 * @param packet  the input packet
 * @param in      the connect point the packet comes in from
 * @param tableId the table to search
 * @return the flow entry
 */
private FlowEntry matchHighestPriority(TrafficSelector packet, ConnectPoint in, TableId tableId) {
    //Computing the possible match rules.
    final Comparator<FlowEntry> comparator = Comparator.comparing(FlowRule::priority);
    return Lists.newArrayList(flowNib.getFlowEntriesByState(in.deviceId(), FlowEntry.FlowEntryState.ADDED)
            .iterator()).stream()
            .filter(flowEntry -> {
                return flowEntry.table().equals(tableId);
            })
            .filter(flowEntry -> {
                return match(packet, flowEntry);
            }).max(comparator).orElse(null);
}
 
Example #20
Source File: BgpConfig.java    From onos with Apache License 2.0 5 votes vote down vote up
public BgpSpeakerConfig(Optional<String> name,
                        VlanId vlanId,
                        ConnectPoint connectPoint,
                        Set<IpAddress> peers) {
    this.name = checkNotNull(name);
    this.vlanId = checkNotNull(vlanId);
    this.connectPoint = checkNotNull(connectPoint);
    this.peers = checkNotNull(peers);
}
 
Example #21
Source File: MockDefaultRoutingHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
MockDefaultRoutingHandler(SegmentRoutingManager srManager,
                          Map<ConnectPoint, Set<IpPrefix>> subnetTable,
                          Map<MockRoutingTableKey, MockRoutingTableValue> routingTable) {
    super(srManager);
    this.subnetTable = subnetTable;
    this.routingTable = routingTable;
}
 
Example #22
Source File: BgpTopologyProviderTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Link getLink(ConnectPoint src, ConnectPoint dst) {
    for (Link link : linkRegistry.links) {
        if (link.src().equals(src) && link.dst().equals(dst)) {
            return link;
        }
    }
    return null;
}
 
Example #23
Source File: TopoIntentFilter.java    From onos with Apache License 2.0 5 votes vote down vote up
private boolean isIntentRelevant(MultiPointToSinglePointIntent intent,
                                 Iterable<ConnectPoint> edgePoints) {
    for (ConnectPoint point : edgePoints) {
        // Bail if intent does not involve this edge point.
        if (!point.equals(intent.egressPoint()) &&
                !intent.ingressPoints().contains(point)) {
            return false;
        }
    }
    return true;
}
 
Example #24
Source File: SegmentRoutingAppConfigTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests suppressHostByPort setter.
 *
 * @throws Exception
 */
@Test
public void testSetSuppressHostByPort() throws Exception {
    ImmutableSet.Builder<ConnectPoint> builder = ImmutableSet.builder();
    builder.add(PORT_3);
    config.setSuppressHostByPort(builder.build());

    Set<ConnectPoint> suppressHostByPort = config.suppressHostByPort();
    assertNotNull("suppressHostByPort should not be null", suppressHostByPort);
    assertThat(suppressHostByPort.size(), is(1));
    assertTrue(suppressHostByPort.contains(PORT_3));
}
 
Example #25
Source File: MultiPointToSinglePointIntentCompilerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests ingress and egress on the same device.
 */
@Test
public void testSameDeviceCompilation() {
    Set<FilteredConnectPoint> ingress =
            Sets.newHashSet(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1)),
                            new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_2)));
    FilteredConnectPoint egress =
            new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_3));

    MultiPointToSinglePointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));

    final String[] hops = {};
    MultiPointToSinglePointIntentCompiler compiler = makeCompiler(hops);
    assertThat(compiler, is(notNullValue()));

    List<Intent> result = compiler.compile(intent, null);
    assertThat(result, is(notNullValue()));
    assertThat(result, hasSize(1));
    Intent resultIntent = result.get(0);
    assertThat(resultIntent, instanceOf(LinkCollectionIntent.class));

    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(0));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
 
Example #26
Source File: FlowEntryWithLoadTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Test
public void testConstructionDEfaultLoad() {
    ConnectPoint cp = NetTestTools.connectPoint("id1", 1);
    StoredFlowEntry fe = new MockFlowEntry(FlowEntry.FlowLiveType.IMMEDIATE);
    FlowEntryWithLoad underTest;

    fe = new MockFlowEntry(FlowEntry.FlowLiveType.IMMEDIATE);
    underTest = new FlowEntryWithLoad(cp, fe);
    assertThat(underTest.connectPoint(), is(cp));
    assertThat(underTest.load(), instanceOf(DefaultLoad.class));
    assertThat(underTest.storedFlowEntry(), is(fe));

    fe = new MockFlowEntry(FlowEntry.FlowLiveType.LONG);
    underTest = new FlowEntryWithLoad(cp, fe);
    assertThat(underTest.connectPoint(), is(cp));
    assertThat(underTest.load(), instanceOf(DefaultLoad.class));

    fe = new MockFlowEntry(FlowEntry.FlowLiveType.MID);
    underTest = new FlowEntryWithLoad(cp, fe);
    assertThat(underTest.connectPoint(), is(cp));
    assertThat(underTest.load(), instanceOf(DefaultLoad.class));

    fe = new MockFlowEntry(FlowEntry.FlowLiveType.SHORT);
    underTest = new FlowEntryWithLoad(cp, fe);
    assertThat(underTest.connectPoint(), is(cp));
    assertThat(underTest.load(), instanceOf(DefaultLoad.class));

    fe = new MockFlowEntry(FlowEntry.FlowLiveType.UNKNOWN);
    underTest = new FlowEntryWithLoad(cp, fe);
    assertThat(underTest.connectPoint(), is(cp));
    assertThat(underTest.load(), instanceOf(DefaultLoad.class));
}
 
Example #27
Source File: TopoIntentFilter.java    From onos with Apache License 2.0 5 votes vote down vote up
private Set<ConnectPoint> getEdgePoints(Set<Host> hosts) {
    Set<ConnectPoint> edgePoints = new HashSet<>();
    for (Host host : hosts) {
        edgePoints.add(host.location());
    }
    return edgePoints;
}
 
Example #28
Source File: ConfigureLinkCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected void doExecute() {
    DeviceService deviceService = get(DeviceService.class);
    NetworkConfigService netCfgService = get(NetworkConfigService.class);

    ConnectPoint srcCp = ConnectPoint.deviceConnectPoint(src);
    if (deviceService.getPort(srcCp) == null) {
        print("[ERROR] %s does not exist", srcCp);
        return;
    }

    ConnectPoint dstCp = ConnectPoint.deviceConnectPoint(dst);
    if (deviceService.getPort(dstCp) == null) {
        print("[ERROR] %s does not exist", dstCp);
        return;
    }

    LinkKey link = linkKey(srcCp, dstCp);
    if (remove) {
        netCfgService.removeConfig(link, BasicLinkConfig.class);
        return;
    }

    Long bw = Optional.ofNullable(bandwidth)
                    .map(Long::valueOf)
                    .orElse(null);

    Link.Type linkType = Link.Type.valueOf(type);

    BasicLinkConfig cfg = netCfgService.addConfig(link, BasicLinkConfig.class);
    cfg.isAllowed(!disallow);
    cfg.isBidirectional(!isUniDi);
    cfg.type(linkType);
    if (bw != null) {
        cfg.bandwidth(bw);
    }

    cfg.apply();
}
 
Example #29
Source File: ConnectPointCodec.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public ObjectNode encode(ConnectPoint point, CodecContext context) {
    checkNotNull(point, "Connect point cannot be null");
    ObjectNode root = context.mapper().createObjectNode()
            .put(PORT, point.port().toString());

    if (point.elementId() instanceof DeviceId) {
        root.put(ELEMENT_DEVICE, point.deviceId().toString());
    } else if (point.elementId() instanceof HostId) {
        root.put(ELEMENT_HOST, point.hostId().toString());
    }

    return root;
}
 
Example #30
Source File: DefaultTopology.java    From onos with Apache License 2.0 5 votes vote down vote up
private ImmutableSet<ConnectPoint> findInfrastructurePoints() {
    ImmutableSet.Builder<ConnectPoint> builder = ImmutableSet.builder();
    for (TopologyEdge edge : graph.getEdges()) {
        if (edge.link().type() == Type.EDGE) {
            // exclude EDGE link from infrastructure link
            // - Device <-> Host
            // - Device <-> remote domain Device
            continue;
        }
        builder.add(edge.link().src());
        builder.add(edge.link().dst());
    }
    return builder.build();
}