Search in sources :

Example 21 with Bandwidth

use of org.onlab.util.Bandwidth in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testSetupPath.

/**
 * Checks setupPath method works.
 */
@Test
public void testSetupPath() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    List<Link> links = Stream.of(LINK1, LINK2, LINK3, LINK4, LINK5, LINK6).collect(Collectors.toList());
    Path path = new DefaultPath(PROVIDER_ID, links, new ScalarWeight(0));
    OpticalConnectivityId cid = target.setupPath(path, bandwidth, latency);
    assertNotNull(cid);
    // Checks intents are installed as expected
    assertEquals(1, intentService.submitted.size());
    assertEquals(OpticalConnectivityIntent.class, intentService.submitted.get(0).getClass());
    OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.submitted.get(0);
    assertEquals(CP31, connIntent.getSrc());
    assertEquals(CP52, connIntent.getDst());
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Duration(java.time.Duration) DefaultPath(org.onosproject.net.DefaultPath) DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link) ScalarWeight(org.onlab.graph.ScalarWeight) Test(org.junit.Test)

Example 22 with Bandwidth

use of org.onlab.util.Bandwidth in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testRemoveConnectivity.

/**
 * Checks removeConnectivity method works.
 */
@Test
public void testRemoveConnectivity() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency);
    // Checks intents are withdrawn
    assertTrue(target.removeConnectivity(cid));
    assertEquals(1, intentService.withdrawn.size());
    assertEquals(OpticalConnectivityIntent.class, intentService.withdrawn.get(0).getClass());
    OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.withdrawn.get(0);
    assertEquals(CP31, connIntent.getSrc());
    assertEquals(CP52, connIntent.getDst());
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Duration(java.time.Duration) Test(org.junit.Test)

Example 23 with Bandwidth

use of org.onlab.util.Bandwidth in project onos by opennetworkinglab.

the class ConnectivityIntentCommand method buildConstraints.

/**
 * Builds the constraint list for this command based on the command line
 * parameters.
 *
 * @return List of constraint objects describing the constraints requested
 */
protected List<Constraint> buildConstraints() {
    final List<Constraint> constraints = new LinkedList<>();
    // Check for a bandwidth specification
    if (!isNullOrEmpty(bandwidthString)) {
        Bandwidth bandwidth;
        try {
            bandwidth = Bandwidth.bps(Long.parseLong(bandwidthString));
        // when the string can't be parsed as long, then try to parse as double
        } catch (NumberFormatException e) {
            bandwidth = Bandwidth.bps(Double.parseDouble(bandwidthString));
        }
        constraints.add(new BandwidthConstraint(bandwidth));
    }
    // Check for partial failure specification
    if (partial) {
        constraints.add(new PartialFailureConstraint());
    }
    // Check for encapsulation specification
    if (!isNullOrEmpty(encapsulationString)) {
        final EncapsulationType encapType = EncapsulationType.valueOf(encapsulationString);
        constraints.add(new EncapsulationConstraint(encapType));
    }
    // Check for hashed path selection
    if (hashedPathSelection) {
        constraints.add(new HashedPathSelectionConstraint());
    }
    // Check for domain processing
    if (domains) {
        constraints.add(DomainConstraint.domain());
    }
    // Check for a latency specification
    if (!isNullOrEmpty(latConstraint)) {
        try {
            long lat = Long.parseLong(latConstraint);
            constraints.add(new LatencyConstraint(Duration.of(lat, ChronoUnit.NANOS)));
        } catch (NumberFormatException e) {
            double lat = Double.parseDouble(latConstraint);
            constraints.add(new LatencyConstraint(Duration.of((long) lat, ChronoUnit.NANOS)));
        }
    }
    return constraints;
}
Also used : EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) EncapsulationType(org.onosproject.net.EncapsulationType) HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) DomainConstraint(org.onosproject.net.intent.constraint.DomainConstraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) Bandwidth(org.onlab.util.Bandwidth) LatencyConstraint(org.onosproject.net.intent.constraint.LatencyConstraint) LinkedList(java.util.LinkedList) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint)

Example 24 with Bandwidth

use of org.onlab.util.Bandwidth in project onos by opennetworkinglab.

the class ResourceDeviceListener method registerPortResource.

private void registerPortResource(Device device, Port port) {
    Resource portPath = Resources.discrete(device.id(), port.number()).resource();
    if (!adminService.register(portPath)) {
        log.error("Failed to register Port: {}", portPath.id());
    }
    queryBandwidth(device.id(), port.number()).map(bw -> portPath.child(Bandwidth.class, bw.bps())).map(adminService::register).ifPresent(success -> {
        if (!success) {
            log.error("Failed to register Bandwidth for {}", portPath.id());
        }
    });
    // for VLAN IDs
    Set<VlanId> vlans = queryVlanIds(device.id(), port.number());
    if (!vlans.isEmpty()) {
        boolean success = adminService.register(vlans.stream().map(portPath::child).collect(Collectors.toList()));
        if (!success) {
            log.error("Failed to register VLAN IDs for {}", portPath.id());
        }
    }
    // for MPLS labels
    Set<MplsLabel> mplsLabels = queryMplsLabels(device.id(), port.number());
    if (!mplsLabels.isEmpty()) {
        boolean success = adminService.register(mplsLabels.stream().map(portPath::child).collect(Collectors.toList()));
        if (!success) {
            log.error("Failed to register MPLS Labels for {}", portPath.id());
        }
    }
    // for Lambdas
    Set<OchSignal> lambdas = queryLambdas(device.id(), port.number());
    if (!lambdas.isEmpty()) {
        boolean success = adminService.register(lambdas.stream().map(portPath::child).collect(Collectors.toList()));
        if (!success) {
            log.error("Failed to register lambdas for {}", portPath.id());
        }
    }
    // for Tributary slots
    Set<TributarySlot> tSlots = queryTributarySlots(device.id(), port.number());
    if (!tSlots.isEmpty()) {
        boolean success = adminService.register(tSlots.stream().map(portPath::child).collect(Collectors.toList()));
        if (!success) {
            log.error("Failed to register tributary slots for {}", portPath.id());
        }
    }
}
Also used : Bandwidth(org.onlab.util.Bandwidth) Resource(org.onosproject.net.resource.Resource) DiscreteResource(org.onosproject.net.resource.DiscreteResource) TributarySlot(org.onosproject.net.TributarySlot) MplsLabel(org.onlab.packet.MplsLabel) OchSignal(org.onosproject.net.OchSignal) VlanId(org.onlab.packet.VlanId)

Aggregations

Bandwidth (org.onlab.util.Bandwidth)24 Test (org.junit.Test)15 OpticalConnectivityId (org.onosproject.newoptical.api.OpticalConnectivityId)14 Duration (java.time.Duration)12 ConnectPoint (org.onosproject.net.ConnectPoint)10 Link (org.onosproject.net.Link)6 DefaultLink (org.onosproject.net.DefaultLink)5 Key (org.onosproject.net.intent.Key)5 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)5 ContinuousResource (org.onosproject.net.resource.ContinuousResource)5 Path (org.onosproject.net.Path)4 Constraint (org.onosproject.net.intent.Constraint)4 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)4 ResourceAllocation (org.onosproject.net.resource.ResourceAllocation)4 ResourceService (org.onosproject.net.resource.ResourceService)4 List (java.util.List)3 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)3 MockResourceService (org.onosproject.net.resource.MockResourceService)3 ImmutableList (com.google.common.collect.ImmutableList)2 ArrayList (java.util.ArrayList)2