Search in sources :

Example 1 with BandwidthCapacity

use of org.onosproject.net.config.basics.BandwidthCapacity in project onos by opennetworkinglab.

the class ResourceNetworkConfigListener method handleBandwidthCapacity.

private void handleBandwidthCapacity(NetworkConfigEvent event) {
    checkArgument(event.configClass() == BandwidthCapacity.class);
    ConnectPoint cp = (ConnectPoint) event.subject();
    if (!mastershipService.isLocalMaster(cp.deviceId())) {
        return;
    }
    BandwidthCapacity bwCapacity = cfgService.getConfig(cp, BandwidthCapacity.class);
    switch(event.type()) {
        case CONFIG_ADDED:
            if (!adminService.register(Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class).resource(bwCapacity.capacity().bps()))) {
                log.info("Failed to register Bandwidth for {}, attempting update", cp);
                if (!updateRegistration(cp, bwCapacity)) {
                    log.warn("Failed to update Bandwidth for {}", cp);
                }
            }
            break;
        case CONFIG_UPDATED:
            if (!updateRegistration(cp, bwCapacity)) {
                log.warn("Failed to update Bandwidth for {}", cp);
            }
            break;
        case CONFIG_REMOVED:
            // FIXME Following should be an update to the value based on port speed
            if (!adminService.unregister(Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class).id())) {
                log.warn("Failed to unregister Bandwidth for {}", cp);
            }
            break;
        case CONFIG_REGISTERED:
        case CONFIG_UNREGISTERED:
            // no-op
            break;
        default:
            break;
    }
}
Also used : BandwidthCapacity(org.onosproject.net.config.basics.BandwidthCapacity) Bandwidth(org.onlab.util.Bandwidth) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 2 with BandwidthCapacity

use of org.onosproject.net.config.basics.BandwidthCapacity in project onos by opennetworkinglab.

the class ResourceDeviceListener method queryBandwidth.

/**
 * Query bandwidth capacity on a port.
 *
 * @param did {@link DeviceId}
 * @param number {@link PortNumber}
 * @return bandwidth capacity
 */
private Optional<Bandwidth> queryBandwidth(DeviceId did, PortNumber number) {
    // Check and use netcfg first.
    ConnectPoint cp = new ConnectPoint(did, number);
    BandwidthCapacity config = netcfgService.getConfig(cp, BandwidthCapacity.class);
    if (config != null) {
        log.trace("Registering configured bandwidth {} for {}/{}", config.capacity(), did, number);
        return Optional.of(config.capacity());
    }
    // populate bandwidth value, assuming portSpeed == bandwidth
    Port port = deviceService.getPort(did, number);
    if (port != null) {
        return Optional.of(Bandwidth.mbps(port.portSpeed()));
    }
    return Optional.empty();
}
Also used : BandwidthCapacity(org.onosproject.net.config.basics.BandwidthCapacity) Port(org.onosproject.net.Port) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 3 with BandwidthCapacity

use of org.onosproject.net.config.basics.BandwidthCapacity in project onos by opennetworkinglab.

the class OpticalPathProvisioner method setPortBandwidth.

/**
 * Updates bandwidth resource of given connect point to specified value.
 *
 * @param cp Connect point
 * @param bandwidth New bandwidth
 */
private void setPortBandwidth(ConnectPoint cp, Bandwidth bandwidth) {
    log.debug("update Port {} Bandwidth {}", cp, bandwidth);
    BandwidthCapacity bwCapacity = networkConfigService.addConfig(cp, BandwidthCapacity.class);
    bwCapacity.capacity(bandwidth).apply();
}
Also used : BandwidthCapacity(org.onosproject.net.config.basics.BandwidthCapacity)

Aggregations

BandwidthCapacity (org.onosproject.net.config.basics.BandwidthCapacity)3 ConnectPoint (org.onosproject.net.ConnectPoint)2 Bandwidth (org.onlab.util.Bandwidth)1 Port (org.onosproject.net.Port)1