Search in sources :

Example 16 with BridgeConfig

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

Example 17 with BridgeConfig

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());
}
Also used : DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) K8sApiConfigService(org.onosproject.k8snode.api.K8sApiConfigService) CoreService(org.onosproject.core.CoreService) K8sNodeAdminService(org.onosproject.k8snode.api.K8sNodeAdminService) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) K8sNodeListener(org.onosproject.k8snode.api.K8sNodeListener) VXLAN(org.onosproject.k8snode.api.Constants.VXLAN) TpPort.tpPort(org.onlab.packet.TpPort.tpPort) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) Thread.sleep(java.lang.Thread.sleep) K8sNodeState(org.onosproject.k8snode.api.K8sNodeState) NodeId(org.onosproject.cluster.NodeId) INCOMPLETE(org.onosproject.k8snode.api.K8sNodeState.INCOMPLETE) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) AUTO_RECOVERY(org.onosproject.k8snode.impl.OsgiPropertyConstants.AUTO_RECOVERY) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) Collectors(java.util.stream.Collectors) K8sNodeUtil.getBooleanProperty(org.onosproject.k8snode.util.K8sNodeUtil.getBooleanProperty) K8sNodeUtil.isOvsdbConnected(org.onosproject.k8snode.util.K8sNodeUtil.isOvsdbConnected) DefaultPatchDescription(org.onosproject.net.behaviour.DefaultPatchDescription) Objects(java.util.Objects) List(java.util.List) TunnelEndPoints(org.onosproject.net.behaviour.TunnelEndPoints) DeviceEvent(org.onosproject.net.device.DeviceEvent) AUTO_RECOVERY_DEFAULT(org.onosproject.k8snode.impl.OsgiPropertyConstants.AUTO_RECOVERY_DEFAULT) ClusterService(org.onosproject.cluster.ClusterService) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) GENEVE(org.onosproject.k8snode.api.Constants.GENEVE) GRE(org.onosproject.k8snode.api.Constants.GRE) Tools(org.onlab.util.Tools) K8sNodeUtil.getOvsdbClient(org.onosproject.k8snode.util.K8sNodeUtil.getOvsdbClient) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) ComponentContext(org.osgi.service.component.ComponentContext) PORT_NAME(org.onosproject.net.AnnotationKeys.PORT_NAME) TunnelKey(org.onosproject.net.behaviour.TunnelKey) Component(org.osgi.service.component.annotations.Component) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) DEVICE_CREATED(org.onosproject.k8snode.api.K8sNodeState.DEVICE_CREATED) K8sNodeEvent(org.onosproject.k8snode.api.K8sNodeEvent) Activate(org.osgi.service.component.annotations.Activate) COMPLETE(org.onosproject.k8snode.api.K8sNodeState.COMPLETE) K8sNode(org.onosproject.k8snode.api.K8sNode) ExecutorService(java.util.concurrent.ExecutorService) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) DeviceListener(org.onosproject.net.device.DeviceListener) Logger(org.slf4j.Logger) K8sNodeHandler(org.onosproject.k8snode.api.K8sNodeHandler) PatchDescription(org.onosproject.net.behaviour.PatchDescription) APP_ID(org.onosproject.k8snode.api.K8sNodeService.APP_ID) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) OVSDB_PORT(org.onosproject.k8snode.impl.OsgiPropertyConstants.OVSDB_PORT) Modified(org.osgi.service.component.annotations.Modified) OVSDB_PORT_NUM_DEFAULT(org.onosproject.k8snode.impl.OsgiPropertyConstants.OVSDB_PORT_NUM_DEFAULT) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) K8sNodeService(org.onosproject.k8snode.api.K8sNodeService) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) NORMAL(org.onosproject.k8snode.api.K8sApiConfig.Mode.NORMAL) Device(org.onosproject.net.Device) 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