Search in sources :

Example 1 with BasicLinkConfig

use of org.onosproject.net.config.basics.BasicLinkConfig 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 2 with BasicLinkConfig

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

the class OplinkSwitchProtection method addLinkToPeer.

private void addLinkToPeer(DeviceId peerId) {
    if (peerId == null) {
        log.warn("PeerID is null for device {}", data().deviceId());
        return;
    }
    ConnectPoint dstCp = new ConnectPoint(data().deviceId(), PortNumber.portNumber(VIRTUAL_PORT));
    ConnectPoint srcCp = new ConnectPoint(peerId, PortNumber.portNumber(VIRTUAL_PORT));
    LinkKey link = linkKey(srcCp, dstCp);
    BasicLinkConfig cfg = handler().get(NetworkConfigService.class).addConfig(link, BasicLinkConfig.class);
    cfg.type(Link.Type.VIRTUAL);
    cfg.apply();
}
Also used : LinkKey(org.onosproject.net.LinkKey) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) BasicLinkConfig(org.onosproject.net.config.basics.BasicLinkConfig)

Aggregations

ConnectPoint (org.onosproject.net.ConnectPoint)2 LinkKey (org.onosproject.net.LinkKey)2 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)2 BasicLinkConfig (org.onosproject.net.config.basics.BasicLinkConfig)2 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)1 Link (org.onosproject.net.Link)1 DeviceService (org.onosproject.net.device.DeviceService)1