use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SimpleFabricForwarding method dump.
// Dump command handler
private void dump(String subject, PrintStream out) {
if ("intents".equals(subject)) {
out.println("Forwarding Broadcast Intents:\n");
for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
out.println(" " + intent.key().toString() + ": " + intent.selector().criteria() + ", [" + intent.filteredIngressPoint().connectPoint() + "] -> " + intent.filteredEgressPoints().stream().map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet()));
}
out.println("");
out.println("Forwarding Unicast Intents:\n");
for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
out.println(" " + intent.key().toString() + ": " + intent.selector().criteria() + ", [" + intent.filteredIngressPoints().stream().map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet()) + "] -> " + intent.filteredEgressPoint().connectPoint());
}
out.println("");
out.println("Forwarding Intents to Be Purged:\n");
for (Key key : toBePurgedIntentKeys) {
out.println(" " + key.toString());
}
out.println("");
}
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SimpleFabricForwarding method refresh.
private void refresh() {
log.debug("simple fabric forwarding refresh");
Map<Key, SinglePointToMultiPointIntent> newBctIntentsMap = Maps.newConcurrentMap();
Map<Key, MultiPointToSinglePointIntent> newUniIntentsMap = Maps.newConcurrentMap();
for (FabricNetwork fabricNetwork : simpleFabric.fabricNetworks()) {
// if fabricNetwork.isForward == false or number of interfaces() < 2, no Intents generated
for (SinglePointToMultiPointIntent intent : buildBrcIntents(fabricNetwork)) {
newBctIntentsMap.put(intent.key(), intent);
}
for (MultiPointToSinglePointIntent intent : buildUniIntents(fabricNetwork, hostsFromL2Network(fabricNetwork))) {
newUniIntentsMap.put(intent.key(), intent);
}
if (fabricNetwork.isDirty()) {
fabricNetwork.setDirty(false);
}
}
boolean bctUpdated = false;
for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
SinglePointToMultiPointIntent newIntent = newBctIntentsMap.get(intent.key());
if (newIntent == null) {
log.info("simple fabric forwarding withdraw broadcast intent: {}", intent.key().toString());
toBePurgedIntentKeys.add(intent.key());
intentService.withdraw(intent);
bctUpdated = true;
}
}
for (SinglePointToMultiPointIntent intent : newBctIntentsMap.values()) {
SinglePointToMultiPointIntent oldIntent = bctIntentsMap.get(intent.key());
if (oldIntent == null || !oldIntent.filteredEgressPoints().equals(intent.filteredEgressPoints()) || !oldIntent.filteredIngressPoint().equals(intent.filteredIngressPoint()) || !oldIntent.selector().equals(intent.selector()) || !oldIntent.treatment().equals(intent.treatment()) || !oldIntent.constraints().equals(intent.constraints())) {
log.info("simple fabric forwarding submit broadcast intent: {}", intent.key().toString());
toBePurgedIntentKeys.remove(intent.key());
intentService.submit(intent);
bctUpdated = true;
}
}
boolean uniUpdated = false;
for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
MultiPointToSinglePointIntent newIntent = newUniIntentsMap.get(intent.key());
if (newIntent == null) {
log.info("simple fabric forwarding withdraw unicast intent: {}", intent.key().toString());
toBePurgedIntentKeys.add(intent.key());
intentService.withdraw(intent);
uniUpdated = true;
}
}
for (MultiPointToSinglePointIntent intent : newUniIntentsMap.values()) {
MultiPointToSinglePointIntent oldIntent = uniIntentsMap.get(intent.key());
if (oldIntent == null || !oldIntent.filteredEgressPoint().equals(intent.filteredEgressPoint()) || !oldIntent.filteredIngressPoints().equals(intent.filteredIngressPoints()) || !oldIntent.selector().equals(intent.selector()) || !oldIntent.treatment().equals(intent.treatment()) || !oldIntent.constraints().equals(intent.constraints())) {
log.info("simple fabric forwarding submit unicast intent: {}", intent.key().toString());
toBePurgedIntentKeys.remove(intent.key());
intentService.submit(intent);
uniUpdated = true;
}
}
if (bctUpdated) {
bctIntentsMap = newBctIntentsMap;
}
if (uniUpdated) {
uniIntentsMap = newUniIntentsMap;
}
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SimpleFabricForwarding method buildUniIntents.
// Builds unicast Intents for a L2 Network.
private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork, Set<Host> hosts) {
Set<Interface> interfaces = fabricNetwork.interfaces();
if (!fabricNetwork.isForward() || interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(this::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(host.mac()).build();
MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoints(srcFcps).filteredEgressPoint(hostFcp).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_UNICAST).resourceGroup(resourceGroup);
uniIntents.add(intentBuilder.build());
});
return uniIntents;
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SimpleFabricRouting method dump.
// Dump Cli Handler
private void dump(String subject, PrintStream out) {
if ("intents".equals(subject)) {
out.println("Routing Route Intents:\n");
for (Intent entry : intentService.getIntents()) {
if (appId.equals(entry.appId())) {
MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
out.println(" " + intent.key().toString() + " to " + intent.egressPoint().toString() + " set " + intent.treatment().immediate().toString() + " from " + intent.ingressPoints().toString());
}
}
out.println("");
out.println("Routing Intercept Flow Rules:\n");
List<FlowRule> rules = new ArrayList(interceptFlowRules);
Collections.sort(rules, new Comparator<FlowRule>() {
@Override
public int compare(FlowRule a, FlowRule b) {
int r = a.deviceId().toString().compareTo(b.deviceId().toString());
// descending on priority
return (r != 0) ? r : Integer.compare(b.priority(), a.priority());
}
});
for (FlowRule rule : rules) {
out.println(" device=" + rule.deviceId().toString() + " priority=" + rule.priority() + " selector=" + rule.selector().criteria().toString());
}
out.println("");
out.println("Routing Intents to Be Purged:\n");
for (Key key : toBePurgedIntentKeys) {
out.println(" " + key.toString());
}
out.println("");
} else if ("reactive-intents".equals(subject)) {
for (Intent entry : intentService.getIntents()) {
if (appId.equals(entry.appId())) {
MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
out.println(intent.key().toString() + " to " + intent.egressPoint().toString() + " set " + intent.treatment().immediate().toString() + " from " + intent.ingressPoints().toString());
}
}
}
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class SimpleFabricRouting method refreshRouteIntents.
/**
* Refresh routes by examining network resource status.
*/
private void refreshRouteIntents() {
for (Intent entry : intentService.getIntents()) {
if (!appId.equals(entry.appId())) {
continue;
}
MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
if (!intentService.isLocal(intent.key())) {
if (toBePurgedIntentKeys.contains(intent.key())) {
// clear non local intent
toBePurgedIntentKeys.remove(intent.key());
}
continue;
}
try {
switch(intentService.getIntentState(intent.key())) {
// case FAILED: // failed intent is not auto removed
case WITHDRAWN:
log.warn("intent found failed or withdrawn; " + "remove and try to purge intent: key={}", intent.key());
// purge intents here without withdraw
intentService.purge(intentService.getIntent(intent.key()));
toBePurgedIntentKeys.add(intent.key());
continue;
default:
// no action
break;
}
} catch (Exception e) {
log.warn("intent status lookup failed: error={}", e);
// this intent seems invalid; no action
continue;
}
// dummy loop to break on remove cases
if (!deviceService.isAvailable(intent.egressPoint().deviceId())) {
log.info("refresh route intents; remove intent for no device: key={}", intent.key());
intentService.withdraw(intentService.getIntent(intent.key()));
toBePurgedIntentKeys.add(intent.key());
continue;
}
if (!(simpleFabric.fabricNetwork(intent.egressPoint(), VlanId.NONE) != null || (REACTIVE_ALLOW_LINK_CP && !linkService.getEgressLinks(intent.egressPoint()).isEmpty()))) {
log.info("refresh route intents; remove intent for egress point not available: key={}", intent.key());
intentService.withdraw(intentService.getIntent(intent.key()));
toBePurgedIntentKeys.add(intent.key());
continue;
}
// MAY NEED TO CHECK: intent.egressPoint and intent.treatment's dstMac is valid against hosts
if (REACTIVE_SINGLE_TO_SINGLE && !REACTIVE_ALLOW_LINK_CP) {
// single path intent only; no need to check ingress points
continue;
}
Set<FilteredConnectPoint> newIngressPoints = new HashSet<>();
boolean ingressPointChanged = false;
for (FilteredConnectPoint cp : intent.filteredIngressPoints()) {
if (deviceService.isAvailable(cp.connectPoint().deviceId()) && (simpleFabric.fabricNetwork(cp.connectPoint(), VlanId.NONE) != null || (REACTIVE_ALLOW_LINK_CP && !linkService.getIngressLinks(cp.connectPoint()).isEmpty()))) {
newIngressPoints.add(cp);
} else {
log.info("refresh route ingress cp of " + "not in 2Networks nor links: {}", cp);
ingressPointChanged = true;
}
}
if (newIngressPoints.isEmpty()) {
log.info("refresh route intents; " + "remove intent for no ingress nor egress point available: key={}", intent.key());
intentService.withdraw(intentService.getIntent(intent.key()));
toBePurgedIntentKeys.add(intent.key());
continue;
}
// update ingress points
if (ingressPointChanged) {
MultiPointToSinglePointIntent updatedIntent = MultiPointToSinglePointIntent.builder().appId(appId).key(intent.key()).selector(intent.selector()).treatment(intent.treatment()).filteredIngressPoints(newIngressPoints).filteredEgressPoint(intent.filteredEgressPoint()).priority(intent.priority()).constraints(intent.constraints()).build();
log.info("refresh route update intent: key={} updatedIntent={}", intent.key(), updatedIntent);
// may remove from old purged entry
toBePurgedIntentKeys.remove(intent.key());
intentService.submit(updatedIntent);
}
}
}
Aggregations