use of org.onosproject.openstacknetworking.api.InstancePort.State.REMOVE_PENDING in project onos by opennetworkinglab.
the class PurgeInstancePortsCommand method doExecute.
@Override
protected void doExecute() {
InstancePortAdminService service = get(InstancePortAdminService.class);
if ((!isAll && !isInactive && !isPending && portIds == null) || (isAll && isInactive && isPending) || (isInactive && isPending && portIds != null) || (portIds != null && isAll && isPending) || (isAll && isInactive && portIds != null)) {
print("Please specify one of portIds, --all or --inactive or --pending options.");
return;
}
if (isAll) {
portIds = service.instancePorts().stream().map(InstancePort::portId).toArray(String[]::new);
} else if (isInactive) {
portIds = service.instancePorts().stream().filter(p -> p.state() == INACTIVE).map(InstancePort::portId).toArray(String[]::new);
} else if (isPending) {
portIds = service.instancePorts().stream().filter(p -> p.state() == REMOVE_PENDING).map(InstancePort::portId).toArray(String[]::new);
}
for (String portId : portIds) {
service.removeInstancePort(portId);
print("Instance port %s has been removed!", portId);
}
print("Done.");
}
Aggregations