use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class OpenRoadmFlowRuleProgrammable method editConfigDeleteConnection.
/**
* Entry point to remove a Crossconnect.
*
* @param xc - OpenROADM flow rule (cross-connect data)
*/
private boolean editConfigDeleteConnection(OpenRoadmFlowRule xc) {
String name = openRoadmConnectionName(xc);
FlowRule flowRule = getConnectionCache().get(did(), name);
if (flowRule == null) {
openRoadmLog("editConfigDeleteConnection, {} not in cache", name);
// What to do ? it should be in the cache
return true;
}
// Delete Connection
editConfigDeleteConnectionEntry(name);
// Remove connection from cache
getConnectionCache().remove(did(), xc);
DeviceService deviceService = this.handler().get(DeviceService.class);
OpenRoadmConnection conn = OpenRoadmConnectionFactory.create(name, xc, deviceService);
// Delete interfaces. Note, deletion of interfaces may fail if
// they are used by other connections.
editConfigDeleteInterfaceEntry(conn.dstNmcName);
editConfigDeleteInterfaceEntry(conn.srcNmcName);
if ((conn.getType() != OpenRoadmFlowRule.Type.ADD_LINK) && (conn.getType() != OpenRoadmFlowRule.Type.LOCAL)) {
editConfigDeleteInterfaceEntry(conn.srcMcName);
}
if ((conn.getType() != OpenRoadmFlowRule.Type.DROP_LINK) && (conn.getType() != OpenRoadmFlowRule.Type.LOCAL)) {
editConfigDeleteInterfaceEntry(conn.dstMcName);
}
return true;
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class TsCheckLoop method doExecute.
@Override
protected void doExecute() {
NetworkDiagnosticService service = getService(NetworkDiagnosticService.class);
DeviceService ds = getService(DeviceService.class);
HostService hs = getService(HostService.class);
FlowRuleService frs = getService(FlowRuleService.class);
LinkService ls = getService(LinkService.class);
service.findAnomalies(NetworkDiagnostic.Type.LOOP).forEach(loop -> print(loop.toString()));
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class OpticalIntentsWebResource method getIntents.
/**
* Get the optical intents on the network.
*
* @return 200 OK
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getIntents() {
DeviceService deviceService = get(DeviceService.class);
IntentService intentService = get(IntentService.class);
Iterator intentItr = intentService.getIntents().iterator();
ArrayNode arrayFlows = mapper().createArrayNode();
while (intentItr.hasNext()) {
Intent intent = (Intent) intentItr.next();
if (intent instanceof OpticalConnectivityIntent) {
OpticalConnectivityIntent opticalConnectivityIntent = (OpticalConnectivityIntent) intent;
Device srcDevice = deviceService.getDevice(opticalConnectivityIntent.getSrc().deviceId());
Device dstDevice = deviceService.getDevice(opticalConnectivityIntent.getDst().deviceId());
String srcDeviceName = srcDevice.annotations().value(AnnotationKeys.NAME);
String dstDeviceName = dstDevice.annotations().value(AnnotationKeys.NAME);
ObjectNode objectNode = mapper().createObjectNode();
objectNode.put("intent id", opticalConnectivityIntent.id().toString());
objectNode.put("app id", opticalConnectivityIntent.appId().name());
objectNode.put("state", intentService.getIntentState(opticalConnectivityIntent.key()).toString());
objectNode.put("src", opticalConnectivityIntent.getSrc().toString());
objectNode.put("dst", opticalConnectivityIntent.getDst().toString());
objectNode.put("srcName", srcDeviceName);
objectNode.put("dstName", dstDeviceName);
// Only for INSTALLED intents
if (intentService.getIntentState(intent.key()) == IntentState.INSTALLED) {
// Retrieve associated FlowRuleIntent
FlowRuleIntent installableIntent = (FlowRuleIntent) intentService.getInstallableIntents(opticalConnectivityIntent.key()).stream().filter(FlowRuleIntent.class::isInstance).findFirst().orElse(null);
// TODO store utilized ochSignal in the intent resources
if (installableIntent != null) {
OchSignal signal = installableIntent.flowRules().stream().filter(r -> r.selector().criteria().size() == NUM_CRITERIA_OPTICAL_CONNECTIVIY_RULE).map(r -> ((OchSignalCriterion) r.selector().getCriterion(Criterion.Type.OCH_SIGID)).lambda()).findFirst().orElse(null);
objectNode.put("ochSignal", signal.toString());
objectNode.put("centralFreq", signal.centralFrequency().asTHz() + " THz");
}
// Retrieve path and print it to REST
if (installableIntent != null) {
String path = installableIntent.resources().stream().filter(Link.class::isInstance).map(Link.class::cast).map(r -> deviceService.getDevice(r.src().deviceId())).map(r -> r.annotations().value(AnnotationKeys.NAME)).collect(Collectors.joining(" -> "));
List<Link> pathLinks = installableIntent.resources().stream().filter(Link.class::isInstance).map(Link.class::cast).collect(Collectors.toList());
DefaultPath defaultPath = new DefaultPath(PROVIDER_ID, pathLinks, new ScalarWeight(1));
objectNode.put("path", defaultPath.toString());
objectNode.put("pathName", path + " -> " + dstDeviceName);
}
}
arrayFlows.add(objectNode);
}
}
ObjectNode root = this.mapper().createObjectNode().putPOJO("Intents", arrayFlows);
return ok(root).build();
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class MastersListCommand method doExecute.
@Override
protected void doExecute() {
ClusterService service = get(ClusterService.class);
MastershipService mastershipService = get(MastershipService.class);
DeviceService deviceService = get(DeviceService.class);
List<ControllerNode> nodes = newArrayList(service.getNodes());
Collections.sort(nodes, Comparators.NODE_COMPARATOR);
if (outputJson()) {
print("%s", json(service, mastershipService, nodes));
} else {
for (ControllerNode node : nodes) {
List<DeviceId> ids = Lists.newArrayList(mastershipService.getDevicesOf(node.id()));
ids.removeIf(did -> deviceService.getDevice(did) == null);
Collections.sort(ids, Comparators.ELEMENT_ID_COMPARATOR);
print("%s: %d devices", node.id(), ids.size());
for (DeviceId deviceId : ids) {
print(" %s", deviceId);
}
}
}
}
use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.
the class RolesCommand method doExecute.
@Override
protected void doExecute() {
DeviceService deviceService = get(DeviceService.class);
MastershipService roleService = get(MastershipService.class);
if (outputJson()) {
print("%s", json(roleService, getSortedDevices(deviceService)));
} else {
for (Device d : getSortedDevices(deviceService)) {
DeviceId did = d.id();
printRoles(roleService, did);
}
}
}
Aggregations