Search in sources :

Example 1 with BridgeConfig

use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.

the class DefaultK8sHostHandler method createBridge.

private void createBridge(DeviceId ovsdb, K8sBridge bridge) {
    Device device = deviceService.getDevice(ovsdb);
    List<ControllerInfo> controllers = clusterService.getNodes().stream().map(n -> new ControllerInfo(n.ip(), DEFAULT_OFPORT, DEFAULT_OF_PROTO)).collect(Collectors.toList());
    String dpid = bridge.dpid().substring(DPID_BEGIN);
    BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(bridge.name()).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) CoreService(org.onosproject.core.CoreService) K8sNodeAdminService(org.onosproject.k8snode.api.K8sNodeAdminService) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) K8sHostState(org.onosproject.k8snode.api.K8sHostState) VXLAN(org.onosproject.k8snode.api.Constants.VXLAN) TpPort.tpPort(org.onlab.packet.TpPort.tpPort) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) K8sHostListener(org.onosproject.k8snode.api.K8sHostListener) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) Thread.sleep(java.lang.Thread.sleep) NodeId(org.onosproject.cluster.NodeId) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) Collectors(java.util.stream.Collectors) DefaultPatchDescription(org.onosproject.net.behaviour.DefaultPatchDescription) Objects(java.util.Objects) DEVICE_CREATED(org.onosproject.k8snode.api.K8sHostState.DEVICE_CREATED) List(java.util.List) COMPLETE(org.onosproject.k8snode.api.K8sHostState.COMPLETE) TunnelEndPoints(org.onosproject.net.behaviour.TunnelEndPoints) K8sTunnelBridge(org.onosproject.k8snode.api.K8sTunnelBridge) K8sHostEvent(org.onosproject.k8snode.api.K8sHostEvent) DeviceEvent(org.onosproject.net.device.DeviceEvent) ClusterService(org.onosproject.cluster.ClusterService) DeviceId(org.onosproject.net.DeviceId) 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) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) PORT_NAME(org.onosproject.net.AnnotationKeys.PORT_NAME) TunnelKey(org.onosproject.net.behaviour.TunnelKey) INIT(org.onosproject.k8snode.api.K8sHostState.INIT) K8sRouterBridge(org.onosproject.k8snode.api.K8sRouterBridge) Component(org.osgi.service.component.annotations.Component) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) Activate(org.osgi.service.component.annotations.Activate) K8sNode(org.onosproject.k8snode.api.K8sNode) ExecutorService(java.util.concurrent.ExecutorService) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) DeviceListener(org.onosproject.net.device.DeviceListener) OS_INTEGRATION_BRIDGE(org.onosproject.k8snode.api.Constants.OS_INTEGRATION_BRIDGE) Logger(org.slf4j.Logger) PatchDescription(org.onosproject.net.behaviour.PatchDescription) APP_ID(org.onosproject.k8snode.api.K8sNodeService.APP_ID) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription) K8sHostHandler(org.onosproject.k8snode.api.K8sHostHandler) K8sBridge(org.onosproject.k8snode.api.K8sBridge) K8sHostAdminService(org.onosproject.k8snode.api.K8sHostAdminService) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) INCOMPLETE(org.onosproject.k8snode.api.K8sHostState.INCOMPLETE) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) K8sHost(org.onosproject.k8snode.api.K8sHost) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) 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)

Example 2 with BridgeConfig

use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.

the class KubevirtNetworkHandler method createBridge.

private void createBridge(KubevirtNode node, KubevirtNetwork network) {
    Device tenantBridge = deviceService.getDevice(network.tenantDeviceId(node.hostname()));
    if (tenantBridge != null && deviceService.isAvailable(tenantBridge.id())) {
        log.warn("The tenant bridge {} already exists at node {}", network.tenantBridgeName(), node.hostname());
        return;
    }
    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 = network.tenantDeviceId(node.hostname()).toString().substring(DPID_BEGIN);
    // if the bridge is already available, we skip creating a new bridge
    if (!deviceService.isAvailable(DeviceId.deviceId(dpid))) {
        BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(network.tenantBridgeName()).failMode(BridgeDescription.FailMode.SECURE).datapathId(dpid).disableInBand().controllers(controllers);
        BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
        bridgeConfig.addBridge(builder.build());
        log.info("Created a new tunnel bridge for network {} at node {}", network.networkId(), node.hostname());
        waitFor(3);
    }
}
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 3 with BridgeConfig

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());
}
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 4 with BridgeConfig

use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.

the class DefaultOpenstackNodeHandler method createPhysicalBridge.

private void createPhysicalBridge(OpenstackNode osNode, OpenstackPhyInterface 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());
}
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 5 with BridgeConfig

use of org.onosproject.net.behaviour.BridgeConfig in project onos by opennetworkinglab.

the class DefaultOpenstackNodeHandler method cleanPhysicalInterfaces.

private void cleanPhysicalInterfaces(OpenstackNode osNode) {
    Device device = deviceService.getDevice(osNode.ovsdb());
    BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
    Set<String> bridgeNames = bridgeConfig.getBridges().stream().map(BridgeDescription::name).collect(Collectors.toSet());
    Set<String> phyNetworkNames = osNode.phyIntfs().stream().map(pi -> BRIDGE_PREFIX + pi.network()).collect(Collectors.toSet());
    // we remove existing physical bridges and patch ports, if the physical
    // bridges are not defined in openstack node
    bridgeNames.forEach(brName -> {
        if (!phyNetworkNames.contains(brName) && !brName.equals(INTEGRATION_BRIDGE)) {
            removePhysicalPatchPorts(osNode, brName.substring(NETWORK_BEGIN));
            removePhysicalBridge(osNode, brName.substring(NETWORK_BEGIN));
        }
    });
}
Also used : DpdkInterface(org.onosproject.openstacknode.api.DpdkInterface) GENEVE(org.onosproject.openstacknode.api.Constants.GENEVE) DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) OSClient(org.openstack4j.api.OSClient) OVSDB_PORT(org.onosproject.openstacknode.impl.OsgiPropertyConstants.OVSDB_PORT) OpenstackNodeUtil.structurePortName(org.onosproject.openstacknode.util.OpenstackNodeUtil.structurePortName) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) BRIDGE_PREFIX(org.onosproject.openstacknode.api.Constants.BRIDGE_PREFIX) GRE(org.onosproject.openstacknode.api.Constants.GRE) COMPLETE(org.onosproject.openstacknode.api.NodeState.COMPLETE) INTEGRATION_BRIDGE(org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE) OpenstackNodeUtil.getConnectedClient(org.onosproject.openstacknode.util.OpenstackNodeUtil.getConnectedClient) OpenstackPhyInterface(org.onosproject.openstacknode.api.OpenstackPhyInterface) TpPort.tpPort(org.onlab.packet.TpPort.tpPort) INTEGRATION_TO_PHYSICAL_PREFIX(org.onosproject.openstacknode.api.Constants.INTEGRATION_TO_PHYSICAL_PREFIX) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) OpenstackNodeUtil.isOvsdbConnected(org.onosproject.openstacknode.util.OpenstackNodeUtil.isOvsdbConnected) NodeId(org.onosproject.cluster.NodeId) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) BridgeName(org.onosproject.net.behaviour.BridgeName) Collection(java.util.Collection) OpenstackNodeUtil.addOrRemoveSystemInterface(org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveSystemInterface) Set(java.util.Set) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) Collectors(java.util.stream.Collectors) DefaultPatchDescription(org.onosproject.net.behaviour.DefaultPatchDescription) Objects(java.util.Objects) List(java.util.List) TunnelEndPoints(org.onosproject.net.behaviour.TunnelEndPoints) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) OpenstackNodeUtil.getOvsdbClient(org.onosproject.openstacknode.util.OpenstackNodeUtil.getOvsdbClient) DeviceEvent(org.onosproject.net.device.DeviceEvent) Optional(java.util.Optional) 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) GATEWAY(org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY) AUTO_RECOVERY(org.onosproject.openstacknode.impl.OsgiPropertyConstants.AUTO_RECOVERY) Tools(org.onlab.util.Tools) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) INIT(org.onosproject.openstacknode.api.NodeState.INIT) ComponentContext(org.osgi.service.component.ComponentContext) PORT_NAME(org.onosproject.net.AnnotationKeys.PORT_NAME) Interface(org.onosproject.ovsdb.rfc.table.Interface) OpenstackNodeAdminService(org.onosproject.openstacknode.api.OpenstackNodeAdminService) INCOMPLETE(org.onosproject.openstacknode.api.NodeState.INCOMPLETE) ControllerNode(org.onosproject.cluster.ControllerNode) CONTROLLER(org.onosproject.openstacknode.api.OpenstackNode.NodeType.CONTROLLER) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) TUNNEL_BRIDGE(org.onosproject.openstacknode.api.Constants.TUNNEL_BRIDGE) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) OVSDB_PORT_NUM_DEFAULT(org.onosproject.openstacknode.impl.OsgiPropertyConstants.OVSDB_PORT_NUM_DEFAULT) Activate(org.osgi.service.component.annotations.Activate) VXLAN_TUNNEL(org.onosproject.openstacknode.api.Constants.VXLAN_TUNNEL) GENEVE_TUNNEL(org.onosproject.openstacknode.api.Constants.GENEVE_TUNNEL) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) PHYSICAL_TO_INTEGRATION_SUFFIX(org.onosproject.openstacknode.api.Constants.PHYSICAL_TO_INTEGRATION_SUFFIX) DEVICE_CREATED(org.onosproject.openstacknode.api.NodeState.DEVICE_CREATED) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) DeviceListener(org.onosproject.net.device.DeviceListener) GRE_TUNNEL(org.onosproject.openstacknode.api.Constants.GRE_TUNNEL) OpenstackNodeUtil.addOrRemoveDpdkInterface(org.onosproject.openstacknode.util.OpenstackNodeUtil.addOrRemoveDpdkInterface) OpenstackNodeUtil.getBooleanProperty(org.onosproject.openstacknode.util.OpenstackNodeUtil.getBooleanProperty) Logger(org.slf4j.Logger) PatchDescription(org.onosproject.net.behaviour.PatchDescription) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription) OpenstackNodeHandler(org.onosproject.openstacknode.api.OpenstackNodeHandler) APP_ID(org.onosproject.openstacknode.api.OpenstackNodeService.APP_ID) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TunnelKeys(org.onosproject.net.behaviour.TunnelKeys) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) NETDEV(org.onosproject.openstacknode.api.DpdkConfig.DatapathType.NETDEV) VXLAN(org.onosproject.openstacknode.api.Constants.VXLAN) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) Reference(org.osgi.service.component.annotations.Reference) LeadershipService(org.onosproject.cluster.LeadershipService) NodeState(org.onosproject.openstacknode.api.NodeState) AUTO_RECOVERY_DEFAULT(org.onosproject.openstacknode.impl.OsgiPropertyConstants.AUTO_RECOVERY_DEFAULT) Device(org.onosproject.net.Device) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig)

Aggregations

Device (org.onosproject.net.Device)16 BridgeConfig (org.onosproject.net.behaviour.BridgeConfig)16 BridgeDescription (org.onosproject.net.behaviour.BridgeDescription)10 DefaultBridgeDescription (org.onosproject.net.behaviour.DefaultBridgeDescription)10 ControllerInfo (org.onosproject.net.behaviour.ControllerInfo)7 IpAddress (org.onlab.packet.IpAddress)5 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