use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class DefaultKubevirtNodeHandler method createPhysicalBridgeWithConnectedMode.
private void createPhysicalBridgeWithConnectedMode(KubevirtNode osNode, KubevirtPhyInterface phyInterface) {
Device device = deviceService.getDevice(osNode.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 = phyInterface.physBridge().toString().substring(DPID_BEGIN);
String bridgeName = BRIDGE_PREFIX + phyInterface.network();
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(bridgeName).failMode(BridgeDescription.FailMode.SECURE).datapathId(dpid).mcastSnoopingEnable().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 KubevirtNodeUtil 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(KubevirtNode 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 DefaultOpenstackNodeHandler method createDpdkTunnelBridge.
private void createDpdkTunnelBridge(OpenstackNode osNode) {
Device device = deviceService.getDevice(osNode.ovsdb());
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(TUNNEL_BRIDGE).datapathType(NETDEV.name().toLowerCase());
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 removePhysicalBridge.
private void removePhysicalBridge(OpenstackNode osNode, String network) {
Device device = deviceService.getDevice(osNode.ovsdb());
BridgeName bridgeName = BridgeName.bridgeName(BRIDGE_PREFIX + network);
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.deleteBridge(bridgeName);
}
use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class DefaultOpenstackNodeHandler method createBridge.
/**
* Creates a bridge with a given name on a given openstack node.
*
* @param osNode openstack node
* @param bridgeName bridge name
* @param deviceId device identifier
*/
private void createBridge(OpenstackNode osNode, String bridgeName, DeviceId deviceId) {
Device device = deviceService.getDevice(osNode.ovsdb());
List<ControllerInfo> controllers;
if (osNode.controllers() != null && osNode.controllers().size() > 0) {
controllers = (List<ControllerInfo>) osNode.controllers();
} else {
Set<IpAddress> controllerIps = clusterService.getNodes().stream().map(ControllerNode::ip).collect(Collectors.toSet());
controllers = controllerIps.stream().map(ip -> new ControllerInfo(ip, DEFAULT_OFPORT, DEFAULT_OF_PROTO)).collect(Collectors.toList());
}
String dpid = deviceId.toString().substring(DPID_BEGIN);
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(bridgeName).failMode(BridgeDescription.FailMode.SECURE).datapathId(dpid).disableInBand().mcastSnoopingEnable().controllers(controllers);
if (osNode.datapathType().equals(NETDEV)) {
builder.datapathType(NETDEV.name().toLowerCase());
}
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.addBridge(builder.build());
}
Aggregations