use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.
the class SimpleFabricConfig method fabricNetworks.
/**
* Returns all fabric networks in this configuration.
*
* @return a set of fabric networks
*/
public Set<FabricNetwork> fabricNetworks() {
Set<FabricNetwork> fabricNetworks = Sets.newHashSet();
JsonNode fabricNetworkNodes = object.get(FABRIC_NETWORKS);
if (fabricNetworkNodes == null) {
return fabricNetworks;
}
fabricNetworkNodes.forEach(jsonNode -> {
Set<String> ifaces = Sets.newHashSet();
JsonNode fabricNetworkIfaces = jsonNode.path(INTERFACES);
if (fabricNetworkIfaces == null) {
log.warn("Fabric network interfaces cannot find {}; skip: jsonNode={}", INTERFACES, jsonNode);
} else if (!fabricNetworkIfaces.toString().isEmpty()) {
fabricNetworkIfaces.forEach(ifacesNode -> ifaces.add(ifacesNode.asText()));
}
// NONE or VLAN
String encapsulation = NONE_ENCAPSULATION;
if (jsonNode.hasNonNull(ENCAPSULATION)) {
encapsulation = jsonNode.get(ENCAPSULATION).asText();
}
boolean isForward = true;
if (jsonNode.hasNonNull(IS_FORWARD)) {
isForward = jsonNode.get(IS_FORWARD).asBoolean();
}
boolean isBroadcast = true;
if (jsonNode.hasNonNull(IS_BROADCAST)) {
isBroadcast = jsonNode.get(IS_BROADCAST).asBoolean();
}
try {
fabricNetworks.add(DefaultFabricNetwork.builder().name(jsonNode.get(NAME).asText()).interfaceNames(ifaces).encapsulation(EncapsulationType.enumFromString(encapsulation)).forward(isForward).broadcast(isBroadcast).build());
} catch (Exception e) {
log.warn("Fabric network parse failed; skip: jsonNode={}", jsonNode);
}
});
return fabricNetworks;
}
use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.
the class SimpleFabricManager method dump.
// Dump handler
protected void dump(String subject, PrintStream out) {
if ("show".equals(subject)) {
out.println("Static Configuration Flag:");
out.println(" ALLOW_IPV6=" + ALLOW_IPV6);
out.println(" ALLOW_ETH_ADDRESS_SELECTOR=" + ALLOW_ETH_ADDRESS_SELECTOR);
out.println(" REACTIVE_SINGLE_TO_SINGLE=" + REACTIVE_SINGLE_TO_SINGLE);
out.println(" REACTIVE_ALLOW_LINK_CP=" + REACTIVE_ALLOW_LINK_CP);
out.println(" REACTIVE_HASHED_PATH_SELECTION=" + REACTIVE_HASHED_PATH_SELECTION);
out.println(" REACTIVE_MATCH_IP_PROTO=" + REACTIVE_MATCH_IP_PROTO);
out.println("");
out.println("SimpleFabricAppId:");
out.println(" " + appId());
out.println("");
out.println("fabricNetworks:");
for (FabricNetwork fabricNetwork : fabricNetworks()) {
out.println(" " + fabricNetwork);
}
out.println("");
out.println("fabricSubnets:");
for (FabricSubnet fabricIpSubnet : defaultFabricSubnets()) {
out.println(" " + fabricIpSubnet);
}
out.println("");
out.println("fabricRoutes:");
for (FabricRoute route : fabricRoutes()) {
out.println(" " + route);
}
}
}
use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.
the class SimpleFabricRouting method refreshIntercepts.
/**
* Refresh device flow rules for intercepts on local fabricSubnets.
*/
private void refreshIntercepts() {
Set<FlowRule> newInterceptFlowRules = new HashSet<>();
for (Device device : deviceService.getAvailableDevices()) {
for (FabricSubnet subnet : simpleFabric.defaultFabricSubnets()) {
newInterceptFlowRules.add(generateInterceptFlowRule(true, device.id(), subnet.prefix()));
// check if this devices has the fabricSubnet, then add ip broadcast flue rule
FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(subnet.networkName());
if (fabricNetwork != null && fabricNetwork.contains(device.id())) {
newInterceptFlowRules.add(generateLocalSubnetIpBctFlowRule(device.id(), subnet.prefix(), fabricNetwork));
}
// JUST FOR FLOW RULE TEST ONLY
// newInterceptFlowRules.add(generateTestFlowRule(device.id(), subnet.ipPrefix()));
}
for (FabricRoute route : simpleFabric.fabricRoutes()) {
newInterceptFlowRules.add(generateInterceptFlowRule(false, device.id(), route.prefix()));
}
}
if (!newInterceptFlowRules.equals(interceptFlowRules)) {
// NOTE: DO NOT REMOVE INTERCEPT FLOW RULES FOR FAILED DEVICE FLOW UPDATE MIGHT BE BLOCKED
/*
interceptFlowRules.stream()
.filter(rule -> !newInterceptFlowRules.contains(rule))
.forEach(rule -> {
flowRuleService.removeFlowRules(rule);
log.info("simple fabric reactive routing remove intercept flow rule: {}", rule);
});
*/
newInterceptFlowRules.stream().filter(rule -> !interceptFlowRules.contains(rule)).forEach(rule -> {
flowRuleService.applyFlowRules(rule);
log.info("simple fabric routing apply intercept flow rule: {}", rule);
});
interceptFlowRules = newInterceptFlowRules;
}
}
use of org.onosproject.simplefabric.api.FabricNetwork in project onos by opennetworkinglab.
the class DefaultFabricNetworkTest method testConstruction.
/**
* Test object construction.
*/
@Test
public void testConstruction() {
FabricNetwork network = fabricNetwork1;
assertEquals(network.name(), NAME_1);
assertEquals(network.interfaceNames(), INTF_NAME_SET_1);
assertEquals(network.encapsulation(), ENCAP_TYPE_1);
assertEquals(network.isForward(), IS_FORWARD_1);
assertEquals(network.isBroadcast(), IS_BROADCAST_1);
}
use of org.onosproject.simplefabric.api.FabricNetwork 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;
}
}
Aggregations