use of org.onosproject.net.intent.SinglePointToMultiPointIntent 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.SinglePointToMultiPointIntent 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.SinglePointToMultiPointIntent in project onos by opennetworkinglab.
the class SimpleFabricForwarding method buildBrcIntents.
// Build Boadcast Intents for a L2 Network.
private Set<SinglePointToMultiPointIntent> buildBrcIntents(FabricNetwork fabricNetwork) {
Set<Interface> interfaces = fabricNetwork.interfaces();
if (interfaces.size() < 2 || !fabricNetwork.isForward() || !fabricNetwork.isBroadcast()) {
return ImmutableSet.of();
}
Set<SinglePointToMultiPointIntent> brcIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
// Generates broadcast Intents from any network interface to other
// network interface from the L2 Network.
interfaces.forEach(src -> {
FilteredConnectPoint srcFcp = buildFilteredConnectedPoint(src);
Set<FilteredConnectPoint> dstFcps = interfaces.stream().filter(iface -> !iface.equals(src)).map(this::buildFilteredConnectedPoint).collect(Collectors.toSet());
Key key = buildKey(fabricNetwork.name(), "BCAST", srcFcp.connectPoint(), MacAddress.BROADCAST);
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.BROADCAST).build();
SinglePointToMultiPointIntent.Builder intentBuilder = SinglePointToMultiPointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoint(srcFcp).filteredEgressPoints(dstFcps).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_BROADCAST).resourceGroup(resourceGroup);
brcIntents.add(intentBuilder.build());
});
return brcIntents;
}
use of org.onosproject.net.intent.SinglePointToMultiPointIntent in project onos by opennetworkinglab.
the class VplsIntentUtility method buildBrcIntent.
/**
* Builds a broadcast intent.
*
* @param key key to identify the intent
* @param appId application ID for this Intent
* @param src the source connect point
* @param dsts the destination connect points
* @param encap the encapsulation type
* @param resourceGroup resource group for this Intent
* @return the generated single-point to multi-point intent
*/
static SinglePointToMultiPointIntent buildBrcIntent(Key key, ApplicationId appId, FilteredConnectPoint src, Set<FilteredConnectPoint> dsts, EncapsulationType encap, ResourceGroup resourceGroup) {
log.debug("Building broadcast intent {} for source {}", SP2MP, src);
SinglePointToMultiPointIntent.Builder intentBuilder;
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.BROADCAST).build();
intentBuilder = SinglePointToMultiPointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoint(src).filteredEgressPoints(dsts).constraints(PARTIAL_FAILURE_CONSTRAINT).priority(PRIORITY_OFFSET + PRIORITY_BRC).resourceGroup(resourceGroup);
setEncap(intentBuilder, PARTIAL_FAILURE_CONSTRAINT, encap);
return intentBuilder.build();
}
use of org.onosproject.net.intent.SinglePointToMultiPointIntent in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCodec method decode.
@Override
public SinglePointToMultiPointIntent decode(ObjectNode json, CodecContext context) {
SinglePointToMultiPointIntent.Builder builder = SinglePointToMultiPointIntent.builder();
IntentCodec.intentAttributes(json, context, builder);
ConnectivityIntentCodec.intentAttributes(json, context, builder);
ObjectNode ingressJson = nullIsIllegal(get(json, INGRESS_POINT), INGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
ConnectPoint ingress = context.codec(ConnectPoint.class).decode(ingressJson, context);
builder.filteredIngressPoint(new FilteredConnectPoint(ingress));
ArrayNode egressJson = nullIsIllegal((ArrayNode) json.get(EGRESS_POINT), EGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
final JsonCodec<ConnectPoint> connectPointCodec = context.codec(ConnectPoint.class);
Set<FilteredConnectPoint> egressCp = new HashSet<>();
for (int i = 0; i < egressJson.size(); i++) {
ConnectPoint cp = connectPointCodec.decode(get(egressJson, i), context);
egressCp.add(new FilteredConnectPoint(cp));
}
builder.filteredEgressPoints(egressCp);
return builder.build();
}
Aggregations