use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class K8sNodeUtil method addOrRemoveSystemInterface.
/**
* Adds or removes a network interface (aka port) into a given bridge of kubernetes node.
*
* @param k8sNode kubernetes node
* @param bridgeName bridge name
* @param intfName interface name
* @param deviceService device service
* @param addOrRemove add port is true, remove it otherwise
*/
public static synchronized void addOrRemoveSystemInterface(K8sNode k8sNode, String bridgeName, String intfName, DeviceService deviceService, boolean addOrRemove) {
Device device = deviceService.getDevice(k8sNode.ovsdb());
if (device == null || !device.is(BridgeConfig.class)) {
log.info("device is null or this device if not ovsdb device");
return;
}
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
if (addOrRemove) {
bridgeConfig.addPort(BridgeName.bridgeName(bridgeName), intfName);
} else {
bridgeConfig.deletePort(BridgeName.bridgeName(bridgeName), intfName);
}
}
use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class DefaultK8sNodeHandler method createBridge.
/**
* Creates a bridge with a given name on a given kubernetes node.
*
* @param k8sNode kubernetes node
* @param bridgeName bridge name
* @param devId device identifier
*/
private void createBridge(K8sNode k8sNode, String bridgeName, DeviceId devId) {
Device device = deviceService.getDevice(k8sNode.ovsdb());
List<ControllerInfo> controllers = k8sApiConfigService.apiConfigs().stream().map(c -> new ControllerInfo(c.ipAddress(), DEFAULT_OFPORT, DEFAULT_OF_PROTO)).collect(Collectors.toList());
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());
}
Aggregations