Search in sources :

Example 11 with BridgeConfig

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());
}
Also used : Device(org.onosproject.net.Device) IpAddress(org.onlab.packet.IpAddress) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo)

Example 12 with BridgeConfig

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);
    }
}
Also used : Device(org.onosproject.net.Device) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig)

Example 13 with BridgeConfig

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());
}
Also used : Device(org.onosproject.net.Device) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription)

Example 14 with BridgeConfig

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);
}
Also used : Device(org.onosproject.net.Device) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) BridgeName(org.onosproject.net.behaviour.BridgeName)

Example 15 with BridgeConfig

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());
}
Also used : Device(org.onosproject.net.Device) IpAddress(org.onlab.packet.IpAddress) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo)

Aggregations

Device (org.onosproject.net.Device)17 BridgeConfig (org.onosproject.net.behaviour.BridgeConfig)17 BridgeDescription (org.onosproject.net.behaviour.BridgeDescription)11 DefaultBridgeDescription (org.onosproject.net.behaviour.DefaultBridgeDescription)11 ControllerInfo (org.onosproject.net.behaviour.ControllerInfo)8 IpAddress (org.onlab.packet.IpAddress)6 List (java.util.List)4 Objects (java.util.Objects)4 ExecutorService (java.util.concurrent.ExecutorService)4 Executors.newSingleThreadExecutor (java.util.concurrent.Executors.newSingleThreadExecutor)4 Collectors (java.util.stream.Collectors)4 TpPort.tpPort (org.onlab.packet.TpPort.tpPort)4 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)4 ClusterService (org.onosproject.cluster.ClusterService)4 LeadershipService (org.onosproject.cluster.LeadershipService)4 NodeId (org.onosproject.cluster.NodeId)4 ApplicationId (org.onosproject.core.ApplicationId)4 CoreService (org.onosproject.core.CoreService)4 PORT_NAME (org.onosproject.net.AnnotationKeys.PORT_NAME)4 DeviceId (org.onosproject.net.DeviceId)4