Search in sources :

Example 6 with LinkKey

use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.

the class OpticalOduIntentCompiler method findAvailableTributarySlots.

/**
 * Find available TributarySlots across path.
 *
 * @param intent
 * @param path path in OTU topology
 * @return Map of Linkey and Set of available TributarySlots on its ports
 */
private Map<LinkKey, Set<TributarySlot>> findAvailableTributarySlots(OpticalOduIntent intent, Path path) {
    Set<LinkKey> linkRequest = Sets.newHashSetWithExpectedSize(path.links().size());
    for (int i = 0; i < path.links().size(); i++) {
        LinkKey link = linkKey(path.links().get(i));
        linkRequest.add(link);
    }
    return findTributarySlots(intent, linkRequest);
}
Also used : LinkKey(org.onosproject.net.LinkKey) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 7 with LinkKey

use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.

the class LabelAllocatorTest method testRandomBehaviorNone.

/**
 * To test random behavior. Using NONE optimization
 */
@Test
public void testRandomBehaviorNone() {
    // By default Random is the selection behavior used
    assertThat(this.allocator.getLabelSelection(), instanceOf(RandomSelection.class));
    // It has to be an instance of NONE
    assertEquals(this.allocator.getOptLabelSelection(), LabelAllocator.OptimizationBehavior.NONE);
    // Filter reservations
    this.resourceService.filterAssignment = true;
    // We change the available Ids
    this.resourceService.availableMplsLabels = ImmutableSet.of(1, 2, 3, 4, 5, 6);
    // First allocation on a subset of links
    Map<LinkKey, Identifier<?>> allocation = this.allocator.assignLabelToLinks(ImmutableSet.copyOf(links.subList(2, 3)), IntentId.valueOf(idGenerator.getNewId()), EncapsulationType.MPLS);
    Identifier<?> id = allocation.get(LinkKey.linkKey(d3p0, d2p1));
    // value has to be a MPLS label
    assertThat(id, instanceOf(MplsLabel.class));
    // value should not be a forbidden value
    MplsLabel mplsLabel = (MplsLabel) id;
    assertTrue(0 < mplsLabel.toInt() && mplsLabel.toInt() < MplsLabel.MAX_MPLS);
    // We test the behavior for MPLS
    allocation = this.allocator.assignLabelToLinks(ImmutableSet.copyOf(links.subList(1, 3)), IntentId.valueOf(idGenerator.getNewId()), EncapsulationType.MPLS);
    id = allocation.get(LinkKey.linkKey(d1p1, d3p1));
    assertThat(id, instanceOf(MplsLabel.class));
    mplsLabel = (MplsLabel) id;
    assertTrue(0 < mplsLabel.toInt() && mplsLabel.toInt() < MplsLabel.MAX_MPLS);
    id = allocation.get(LinkKey.linkKey(d3p0, d2p1));
    assertThat(id, instanceOf(MplsLabel.class));
    mplsLabel = (MplsLabel) id;
    assertTrue(0 < mplsLabel.toInt() && mplsLabel.toInt() < MplsLabel.MAX_MPLS);
}
Also used : LinkKey(org.onosproject.net.LinkKey) Identifier(org.onlab.util.Identifier) RandomSelection(org.onosproject.net.resource.impl.LabelAllocator.RandomSelection) MplsLabel(org.onlab.packet.MplsLabel) Test(org.junit.Test)

Example 8 with LinkKey

use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.

the class LabelAllocatorTest method testRandomBehaviorMinSwap.

/**
 * To test the random behavior. Using MIN_SWAP optimization
 */
@Test
public void testRandomBehaviorMinSwap() {
    // By default Random is the selection behavior used
    assertThat(this.allocator.getLabelSelection(), instanceOf(RandomSelection.class));
    // Change to MIN_SWAP
    this.allocator.setOptLabelSelection(minswap);
    assertEquals(this.allocator.getOptLabelSelection(), LabelAllocator.OptimizationBehavior.MIN_SWAP);
    // Filter reservations
    this.resourceService.filterAssignment = true;
    // We change the available Ids
    this.resourceService.availableMplsLabels = ImmutableSet.of(1, 2, 3, 4, 5, 6, 7, 8);
    // First allocation on a subset of links
    Map<LinkKey, Identifier<?>> allocation = this.allocator.assignLabelToLinks(ImmutableSet.copyOf(links2.subList(2, 3)), IntentId.valueOf(idGenerator.getNewId()), EncapsulationType.MPLS);
    Identifier<?> id = allocation.get(LinkKey.linkKey(d3p0, d4p1));
    // value has to be a MPLS label
    assertThat(id, instanceOf(MplsLabel.class));
    // value should not be a forbidden value
    MplsLabel mplsLabel = (MplsLabel) id;
    assertTrue(0 < mplsLabel.toInt() && mplsLabel.toInt() < MplsLabel.MAX_MPLS);
    // We test the behavior for MPLS
    allocation = this.allocator.assignLabelToLinks(ImmutableSet.copyOf(links2.subList(1, 4)), IntentId.valueOf(idGenerator.getNewId()), EncapsulationType.MPLS);
    id = allocation.get(LinkKey.linkKey(d1p1, d3p1));
    assertThat(id, instanceOf(MplsLabel.class));
    mplsLabel = (MplsLabel) id;
    assertTrue(0 < mplsLabel.toInt() && mplsLabel.toInt() < MplsLabel.MAX_MPLS);
    id = allocation.get(LinkKey.linkKey(d3p0, d4p1));
    assertThat(id, instanceOf(MplsLabel.class));
    mplsLabel = (MplsLabel) id;
    assertTrue(0 < mplsLabel.toInt() && mplsLabel.toInt() < MplsLabel.MAX_MPLS);
    id = allocation.get(LinkKey.linkKey(d4p0, d2p1));
    assertThat(id, instanceOf(MplsLabel.class));
    mplsLabel = (MplsLabel) id;
    assertTrue(0 < mplsLabel.toInt() && mplsLabel.toInt() < MplsLabel.MAX_MPLS);
}
Also used : LinkKey(org.onosproject.net.LinkKey) Identifier(org.onlab.util.Identifier) RandomSelection(org.onosproject.net.resource.impl.LabelAllocator.RandomSelection) MplsLabel(org.onlab.packet.MplsLabel) Test(org.junit.Test)

Example 9 with LinkKey

use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.

the class ConfigureLinkCommand method doExecute.

@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();
}
Also used : LinkKey(org.onosproject.net.LinkKey) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DeviceService(org.onosproject.net.device.DeviceService) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) BasicLinkConfig(org.onosproject.net.config.basics.BasicLinkConfig)

Example 10 with LinkKey

use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.

the class ECLinkStore method removeLink.

@Override
public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
    final LinkKey linkKey = LinkKey.linkKey(src, dst);
    ProviderId primaryProviderId = getBaseProviderId(linkKey);
    // Stop if there is no base provider.
    if (primaryProviderId == null) {
        return null;
    }
    LinkDescription removedLinkDescription = linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId));
    if (removedLinkDescription != null) {
        return purgeLinkCache(linkKey);
    }
    return null;
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) LinkKey(org.onosproject.net.LinkKey) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription)

Aggregations

LinkKey (org.onosproject.net.LinkKey)61 Test (org.junit.Test)34 ConnectPoint (org.onosproject.net.ConnectPoint)31 Link (org.onosproject.net.Link)23 Identifier (org.onlab.util.Identifier)14 DeviceId (org.onosproject.net.DeviceId)9 Set (java.util.Set)7 MplsLabel (org.onlab.packet.MplsLabel)7 VlanId (org.onlab.packet.VlanId)7 LinkDescription (org.onosproject.net.link.LinkDescription)7 LinkEvent (org.onosproject.net.link.LinkEvent)7 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)6 ProviderId (org.onosproject.net.provider.ProviderId)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 FirstFitSelection (org.onosproject.net.resource.impl.LabelAllocator.FirstFitSelection)5 RandomSelection (org.onosproject.net.resource.impl.LabelAllocator.RandomSelection)5 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)4 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)4 BasicLinkConfig (org.onosproject.net.config.basics.BasicLinkConfig)4