use of org.onosproject.k8snode.api.K8sRouterBridge in project onos by opennetworkinglab.
the class K8sRoutingSnatHandler method setRouterSnatRules.
private void setRouterSnatRules(K8sNode k8sNode, boolean install) {
for (K8sHost host : k8sHostService.completeHosts()) {
if (host.nodeNames().contains(k8sNode.hostname())) {
K8sRouterBridge bridge = host.routerBridges().stream().filter(b -> b.segmentId() == k8sNode.segmentId()).findAny().orElse(null);
if (bridge != null) {
setRouterSnatUpstreamRule(k8sNode, bridge, install);
setRouterSnatDownstreamRule(k8sNode, bridge, install);
}
}
}
}
use of org.onosproject.k8snode.api.K8sRouterBridge in project onos by opennetworkinglab.
the class DefaultK8sHostHandler method processDeviceCreatedState.
@Override
public void processDeviceCreatedState(K8sHost k8sHost) {
try {
if (!isOvsdbConnected(k8sHost, ovsdbPortNum, ovsdbController, deviceService)) {
ovsdbController.connect(k8sHost.hostIp(), tpPort(ovsdbPortNum));
return;
}
// create patch ports into tunnel bridge face to integration bridge
for (K8sTunnelBridge bridge : k8sHost.tunBridges()) {
for (String node : k8sHost.nodeNames()) {
K8sNode k8sNode = k8sNodeAdminService.node(node);
if (k8sNode.segmentId() == bridge.tunnelId()) {
createTunnelPatchInterfaces(k8sHost.ovsdb(), bridge, k8sNode);
createInterPatchInterfaces(k8sHost.ovsdb(), k8sNode);
}
}
}
// create tunnel ports
for (K8sTunnelBridge bridge : k8sHost.tunBridges()) {
if (!isTunPortEnabled(bridge, bridge.vxlanPortName())) {
createVxlanTunnelInterface(k8sHost.ovsdb(), bridge);
}
if (!isTunPortEnabled(bridge, bridge.grePortName())) {
createGreTunnelInterface(k8sHost.ovsdb(), bridge);
}
if (!isTunPortEnabled(bridge, bridge.genevePortName())) {
createGeneveTunnelInterface(k8sHost.ovsdb(), bridge);
}
}
// create patch ports into router bridge face to external bridge
for (K8sRouterBridge bridge : k8sHost.routerBridges()) {
for (String node : k8sHost.nodeNames()) {
K8sNode k8sNode = k8sNodeAdminService.node(node);
if (k8sNode.segmentId() == bridge.segmentId()) {
createRouterPatchInterfaces(k8sHost.ovsdb(), bridge, k8sNode);
}
}
}
} catch (Exception e) {
log.error("Exception occurred because of {}", e);
}
}
use of org.onosproject.k8snode.api.K8sRouterBridge in project onos by opennetworkinglab.
the class K8sNetworkingUtil method allK8sDevices.
/**
* Returns all device identifiers belong to kubernetes nodes and hosts.
*
* @param nodeService node service
* @param hostService host service
* @return all device identifiers belong to kubernetes nodes and hosts
*/
public static Set<DeviceId> allK8sDevices(K8sNodeService nodeService, K8sHostService hostService) {
Set<DeviceId> allDevIds = new HashSet<>();
Set<DeviceId> intgDevIds = nodeService.completeNodes().stream().map(K8sNode::intgBridge).collect(Collectors.toSet());
Set<DeviceId> extDevIds = nodeService.completeNodes().stream().map(K8sNode::extBridge).collect(Collectors.toSet());
Set<DeviceId> tunDevIds = nodeService.completeNodes().stream().map(K8sNode::tunBridge).collect(Collectors.toSet());
Set<DeviceId> localDevIds = nodeService.completeNodes().stream().map(K8sNode::localBridge).collect(Collectors.toSet());
Set<DeviceId> hostTunDevIds = new HashSet<>();
Set<DeviceId> hostRouterDevIds = new HashSet<>();
for (K8sHost host : hostService.completeHosts()) {
Set<K8sTunnelBridge> hostTunBrs = host.tunBridges();
Set<K8sRouterBridge> hostRouterBrs = host.routerBridges();
hostTunDevIds.addAll(hostTunBrs.stream().map(K8sTunnelBridge::deviceId).collect(Collectors.toSet()));
hostRouterDevIds.addAll(hostRouterBrs.stream().map(K8sRouterBridge::deviceId).collect(Collectors.toSet()));
}
allDevIds.addAll(intgDevIds);
allDevIds.addAll(extDevIds);
allDevIds.addAll(tunDevIds);
allDevIds.addAll(localDevIds);
allDevIds.addAll(hostTunDevIds);
allDevIds.addAll(hostRouterDevIds);
return allDevIds;
}
use of org.onosproject.k8snode.api.K8sRouterBridge in project onos by opennetworkinglab.
the class DefaultK8sApiConfigHandler method buildK8sHost.
private K8sHost buildK8sHost(HostNodesInfo hostNodesInfo, K8sApiConfig config) {
int segmentId = config.segmentId();
K8sTunnelBridge tBridge = new K8sTunnelBridge(segmentId);
K8sRouterBridge rBridge = new K8sRouterBridge(segmentId);
return DefaultK8sHost.builder().hostIp(hostNodesInfo.hostIp()).state(K8sHostState.INIT).tunBridges(ImmutableSet.of(tBridge)).routerBridges(ImmutableSet.of(rBridge)).nodeNames(hostNodesInfo.nodes()).build();
}
Aggregations