Search in sources :

Example 1 with LabelResourceService

use of org.onosproject.incubator.net.resource.label.LabelResourceService in project onos by opennetworkinglab.

the class LabelReleaseCommand method doExecute.

@Override
protected void doExecute() {
    LabelResourceService lrs = get(LabelResourceService.class);
    Multimap<DeviceId, LabelResource> map = ArrayListMultimap.create();
    String[] labelIds = releaseLabelIds.split(",");
    DefaultLabelResource resource = null;
    for (int i = 0; i < labelIds.length; i++) {
        resource = new DefaultLabelResource(DeviceId.deviceId(deviceId), LabelResourceId.labelResourceId(Long.parseLong(labelIds[i])));
        map.put(DeviceId.deviceId(deviceId), resource);
    }
    lrs.releaseToDevicePool(map);
}
Also used : DefaultLabelResource(org.onosproject.incubator.net.resource.label.DefaultLabelResource) LabelResource(org.onosproject.incubator.net.resource.label.LabelResource) LabelResourceService(org.onosproject.incubator.net.resource.label.LabelResourceService) DeviceId(org.onosproject.net.DeviceId) DefaultLabelResource(org.onosproject.incubator.net.resource.label.DefaultLabelResource)

Example 2 with LabelResourceService

use of org.onosproject.incubator.net.resource.label.LabelResourceService in project onos by opennetworkinglab.

the class LabelResourceCommand method doExecute.

@Override
protected void doExecute() {
    LabelResourceService lrs = get(LabelResourceService.class);
    LabelResourcePool pool = lrs.getDeviceLabelResourcePool(DeviceId.deviceId(deviceId));
    if (pool != null) {
        print(FMT, pool.deviceId().toString(), pool.beginLabel(), pool.endLabel(), pool.totalNum(), pool.usedNum(), pool.currentUsedMaxLabelId(), pool.releaseLabelId().toString());
    } else {
        print(FMT, deviceId, null, null, null, null, null, null);
    }
}
Also used : LabelResourceService(org.onosproject.incubator.net.resource.label.LabelResourceService) LabelResourcePool(org.onosproject.incubator.net.resource.label.LabelResourcePool)

Example 3 with LabelResourceService

use of org.onosproject.incubator.net.resource.label.LabelResourceService in project onos by opennetworkinglab.

the class GlobalLabelApplyCommand method doExecute.

@Override
protected void doExecute() {
    LabelResourceService lrs = get(LabelResourceService.class);
    Collection<LabelResource> result = lrs.applyFromGlobalPool(Long.parseLong(applyNum));
    if (!result.isEmpty()) {
        for (Iterator<LabelResource> iterator = result.iterator(); iterator.hasNext(); ) {
            DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator.next();
            print(FMT, defaultLabelResource.deviceId().toString(), defaultLabelResource.labelResourceId().toString());
        }
    }
}
Also used : DefaultLabelResource(org.onosproject.incubator.net.resource.label.DefaultLabelResource) LabelResource(org.onosproject.incubator.net.resource.label.LabelResource) LabelResourceService(org.onosproject.incubator.net.resource.label.LabelResourceService) DefaultLabelResource(org.onosproject.incubator.net.resource.label.DefaultLabelResource)

Example 4 with LabelResourceService

use of org.onosproject.incubator.net.resource.label.LabelResourceService in project onos by opennetworkinglab.

the class GlobalLabelCommand method doExecute.

@Override
protected void doExecute() {
    LabelResourceService lrs = get(LabelResourceService.class);
    LabelResourcePool pool = lrs.getGlobalLabelResourcePool();
    if (pool != null) {
        print(FMT, pool.deviceId().toString(), pool.beginLabel(), pool.endLabel(), pool.totalNum(), pool.usedNum(), pool.currentUsedMaxLabelId(), pool.releaseLabelId().toString());
    }
}
Also used : LabelResourceService(org.onosproject.incubator.net.resource.label.LabelResourceService) LabelResourcePool(org.onosproject.incubator.net.resource.label.LabelResourcePool)

Example 5 with LabelResourceService

use of org.onosproject.incubator.net.resource.label.LabelResourceService in project onos by opennetworkinglab.

the class GlobalLabelReleaseCommand method doExecute.

@Override
protected void doExecute() {
    LabelResourceService lrs = get(LabelResourceService.class);
    Set<LabelResourceId> release = new HashSet<LabelResourceId>();
    String[] labelIds = releaseLabelIds.split(",");
    LabelResourceId resource = null;
    for (int i = 0; i < labelIds.length; i++) {
        resource = LabelResourceId.labelResourceId(Long.parseLong(labelIds[i]));
        release.add(resource);
    }
    lrs.releaseToGlobalPool(release);
}
Also used : LabelResourceService(org.onosproject.incubator.net.resource.label.LabelResourceService) LabelResourceId(org.onosproject.incubator.net.resource.label.LabelResourceId) HashSet(java.util.HashSet)

Aggregations

LabelResourceService (org.onosproject.incubator.net.resource.label.LabelResourceService)6 DefaultLabelResource (org.onosproject.incubator.net.resource.label.DefaultLabelResource)3 LabelResource (org.onosproject.incubator.net.resource.label.LabelResource)3 LabelResourcePool (org.onosproject.incubator.net.resource.label.LabelResourcePool)2 HashSet (java.util.HashSet)1 LabelResourceId (org.onosproject.incubator.net.resource.label.LabelResourceId)1 DeviceId (org.onosproject.net.DeviceId)1