Search in sources :

Example 1 with PortLoadBalancerAdminService

use of org.onosproject.portloadbalancer.api.PortLoadBalancerAdminService in project onos by opennetworkinglab.

the class PortLoadBalancerRemoveCommand method doExecute.

@Override
protected void doExecute() {
    DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
    int portLoadBalancerKey = Integer.parseInt(keyStr);
    PortLoadBalancerAdminService portLoadBalancerAdminService = get(PortLoadBalancerAdminService.class);
    PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId, portLoadBalancerKey);
    PortLoadBalancer portLoadBalancer = portLoadBalancerAdminService.remove(portLoadBalancerId);
    print("Removal of %s %s", portLoadBalancerId, portLoadBalancer != null ? EXECUTED : FAILED);
}
Also used : PortLoadBalancerId(org.onosproject.portloadbalancer.api.PortLoadBalancerId) DeviceId(org.onosproject.net.DeviceId) PortLoadBalancer(org.onosproject.portloadbalancer.api.PortLoadBalancer) PortLoadBalancerAdminService(org.onosproject.portloadbalancer.api.PortLoadBalancerAdminService)

Example 2 with PortLoadBalancerAdminService

use of org.onosproject.portloadbalancer.api.PortLoadBalancerAdminService in project onos by opennetworkinglab.

the class PortLoadBalancerAddCommand method doExecute.

@Override
protected void doExecute() {
    DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
    int portLoadBalancerKey = Integer.parseInt(keyStr);
    PortLoadBalancerMode mode = PortLoadBalancerMode.valueOf(modeStr.toUpperCase());
    Set<PortNumber> ports = Sets.newHashSet(portsStr).stream().map(PortNumber::fromString).collect(Collectors.toSet());
    PortLoadBalancerAdminService portLoadBalancerAdminService = get(PortLoadBalancerAdminService.class);
    PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId, portLoadBalancerKey);
    PortLoadBalancer portLoadBalancer = portLoadBalancerAdminService.createOrUpdate(portLoadBalancerId, ports, mode);
    print("%s of %s executed", portLoadBalancer == null ? CREATE : UPDATE, portLoadBalancerId);
}
Also used : PortLoadBalancerId(org.onosproject.portloadbalancer.api.PortLoadBalancerId) DeviceId(org.onosproject.net.DeviceId) PortLoadBalancerMode(org.onosproject.portloadbalancer.api.PortLoadBalancerMode) PortNumber(org.onosproject.net.PortNumber) PortLoadBalancer(org.onosproject.portloadbalancer.api.PortLoadBalancer) PortLoadBalancerAdminService(org.onosproject.portloadbalancer.api.PortLoadBalancerAdminService)

Aggregations

DeviceId (org.onosproject.net.DeviceId)2 PortLoadBalancer (org.onosproject.portloadbalancer.api.PortLoadBalancer)2 PortLoadBalancerAdminService (org.onosproject.portloadbalancer.api.PortLoadBalancerAdminService)2 PortLoadBalancerId (org.onosproject.portloadbalancer.api.PortLoadBalancerId)2 PortNumber (org.onosproject.net.PortNumber)1 PortLoadBalancerMode (org.onosproject.portloadbalancer.api.PortLoadBalancerMode)1