use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class DefaultK8sHostHandler method createBridge.
private void createBridge(DeviceId ovsdb, K8sBridge bridge) {
Device device = deviceService.getDevice(ovsdb);
List<ControllerInfo> controllers = clusterService.getNodes().stream().map(n -> new ControllerInfo(n.ip(), DEFAULT_OFPORT, DEFAULT_OF_PROTO)).collect(Collectors.toList());
String dpid = bridge.dpid().substring(DPID_BEGIN);
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(bridge.name()).failMode(BridgeDescription.FailMode.SECURE).datapathId(dpid).disableInBand().controllers(controllers);
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.addBridge(builder.build());
}
use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class KubevirtNetworkHandler method createBridge.
private void createBridge(KubevirtNode node, KubevirtNetwork network) {
Device tenantBridge = deviceService.getDevice(network.tenantDeviceId(node.hostname()));
if (tenantBridge != null && deviceService.isAvailable(tenantBridge.id())) {
log.warn("The tenant bridge {} already exists at node {}", network.tenantBridgeName(), node.hostname());
return;
}
Device device = deviceService.getDevice(node.ovsdb());
IpAddress controllerIp = apiConfigService.apiConfig().controllerIp();
String serviceFqdn = apiConfigService.apiConfig().serviceFqdn();
IpAddress serviceIp = null;
if (controllerIp == null) {
if (serviceFqdn != null) {
serviceIp = resolveHostname(serviceFqdn);
}
if (serviceIp != null) {
controllerIp = serviceIp;
} else {
controllerIp = apiConfigService.apiConfig().ipAddress();
}
}
ControllerInfo controlInfo = new ControllerInfo(controllerIp, DEFAULT_OFPORT, DEFAULT_OF_PROTO);
List<ControllerInfo> controllers = Lists.newArrayList(controlInfo);
String dpid = network.tenantDeviceId(node.hostname()).toString().substring(DPID_BEGIN);
// if the bridge is already available, we skip creating a new bridge
if (!deviceService.isAvailable(DeviceId.deviceId(dpid))) {
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(network.tenantBridgeName()).failMode(BridgeDescription.FailMode.SECURE).datapathId(dpid).disableInBand().controllers(controllers);
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.addBridge(builder.build());
log.info("Created a new tunnel bridge for network {} at node {}", network.networkId(), node.hostname());
waitFor(3);
}
}
use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class DefaultKubevirtNodeHandler method createBridge.
/**
* Creates a bridge with a given name on a given kubernetes node.
*
* @param node kubevirt node
* @param bridgeName bridge name
* @param devId device identifier
*/
private void createBridge(KubevirtNode node, String bridgeName, DeviceId devId) {
Device device = deviceService.getDevice(node.ovsdb());
IpAddress controllerIp = apiConfigService.apiConfig().controllerIp();
String serviceFqdn = apiConfigService.apiConfig().serviceFqdn();
IpAddress serviceIp = null;
if (controllerIp == null) {
if (serviceFqdn != null) {
serviceIp = resolveHostname(serviceFqdn);
}
if (serviceIp != null) {
controllerIp = serviceIp;
} else {
controllerIp = apiConfigService.apiConfig().ipAddress();
}
}
ControllerInfo controlInfo = new ControllerInfo(controllerIp, DEFAULT_OFPORT, DEFAULT_OF_PROTO);
List<ControllerInfo> controllers = Lists.newArrayList(controlInfo);
String dpid = devId.toString().substring(DPID_BEGIN);
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(bridgeName).failMode(BridgeDescription.FailMode.SECURE).datapathId(dpid).disableInBand().controllers(controllers);
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.addBridge(builder.build());
}
use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class DefaultOpenstackNodeHandler method createPhysicalBridge.
private void createPhysicalBridge(OpenstackNode osNode, OpenstackPhyInterface phyInterface) {
Device device = deviceService.getDevice(osNode.ovsdb());
String bridgeName = BRIDGE_PREFIX + phyInterface.network();
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(bridgeName).mcastSnoopingEnable();
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.addBridge(builder.build());
}
use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class DefaultOpenstackNodeHandler method cleanPhysicalInterfaces.
private void cleanPhysicalInterfaces(OpenstackNode osNode) {
Device device = deviceService.getDevice(osNode.ovsdb());
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
Set<String> bridgeNames = bridgeConfig.getBridges().stream().map(BridgeDescription::name).collect(Collectors.toSet());
Set<String> phyNetworkNames = osNode.phyIntfs().stream().map(pi -> BRIDGE_PREFIX + pi.network()).collect(Collectors.toSet());
// we remove existing physical bridges and patch ports, if the physical
// bridges are not defined in openstack node
bridgeNames.forEach(brName -> {
if (!phyNetworkNames.contains(brName) && !brName.equals(INTEGRATION_BRIDGE)) {
removePhysicalPatchPorts(osNode, brName.substring(NETWORK_BEGIN));
removePhysicalBridge(osNode, brName.substring(NETWORK_BEGIN));
}
});
}
Aggregations