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 KubevirtNetworkHandler method removeBridge.
private void removeBridge(KubevirtNode node, KubevirtNetwork network) {
Device device = deviceService.getDevice(node.ovsdb());
BridgeName bridgeName = BridgeName.bridgeName(network.tenantBridgeName());
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.deleteBridge(bridgeName);
deviceService.removeDevice(network.tenantDeviceId(node.hostname()));
}
use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class DefaultKubevirtNodeHandler method cleanPhysicalInterfaces.
private void cleanPhysicalInterfaces(KubevirtNode node) {
Device device = deviceService.getDevice(node.ovsdb());
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
Set<String> bridgeNames = bridgeConfig.getBridges().stream().map(BridgeDescription::name).collect(Collectors.toSet());
Set<String> phyNetworkNames = node.phyIntfs().stream().map(pi -> BRIDGE_PREFIX + pi.network()).collect(Collectors.toSet());
// bridges are not defined in kubevirt node
for (String brName : bridgeNames) {
// physical bridges
if (brName.equals(INTEGRATION_BRIDGE) || brName.equals(TUNNEL_BRIDGE) || brName.startsWith(TENANT_BRIDGE_PREFIX)) {
continue;
}
if (!phyNetworkNames.contains(brName)) {
removePhysicalPatchPorts(node, brName.substring(NETWORK_BEGIN));
removePhysicalBridge(node, brName.substring(NETWORK_BEGIN));
log.info("Removing physical bridge {}...", brName);
}
}
}
use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.
the class DefaultKubevirtNodeHandler method removePhysicalBridge.
private void removePhysicalBridge(KubevirtNode node, String network) {
Device device = deviceService.getDevice(node.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 DefaultKubevirtNodeHandler method createPhysicalBridge.
private void createPhysicalBridge(KubevirtNode osNode, KubevirtPhyInterface 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());
}
Aggregations