Search in sources :

Example 6 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 7 with BridgeConfig

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

Example 8 with BridgeConfig

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);
        }
    }
}
Also used : INTEGRATION_BRIDGE(org.onosproject.kubevirtnode.api.Constants.INTEGRATION_BRIDGE) DefaultBridgeDescription(org.onosproject.net.behaviour.DefaultBridgeDescription) GRE(org.onosproject.kubevirtnode.api.Constants.GRE) GATEWAY(org.onosproject.kubevirtnode.api.KubevirtNode.Type.GATEWAY) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) KubevirtNodeUtil.getOvsdbClient(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.getOvsdbClient) DEVICE_CREATED(org.onosproject.kubevirtnode.api.KubevirtNodeState.DEVICE_CREATED) TpPort.tpPort(org.onlab.packet.TpPort.tpPort) GENEVE(org.onosproject.kubevirtnode.api.Constants.GENEVE) FlowRuleService(org.onosproject.net.flow.FlowRuleService) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) AUTO_RECOVERY(org.onosproject.kubevirtnode.impl.OsgiPropertyConstants.AUTO_RECOVERY) 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) AUTO_RECOVERY_DEFAULT(org.onosproject.kubevirtnode.impl.OsgiPropertyConstants.AUTO_RECOVERY_DEFAULT) Deactivate(org.osgi.service.component.annotations.Deactivate) KubevirtNodeUtil.isOvsdbConnected(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.isOvsdbConnected) BridgeName(org.onosproject.net.behaviour.BridgeName) Set(java.util.Set) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) KubevirtPhyInterface(org.onosproject.kubevirtnode.api.KubevirtPhyInterface) Collectors(java.util.stream.Collectors) INTEGRATION_TO_TUNNEL(org.onosproject.kubevirtnode.api.Constants.INTEGRATION_TO_TUNNEL) OVSDB_PORT(org.onosproject.kubevirtnode.impl.OsgiPropertyConstants.OVSDB_PORT) DefaultPatchDescription(org.onosproject.net.behaviour.DefaultPatchDescription) Objects(java.util.Objects) KubevirtNodeAdminService(org.onosproject.kubevirtnode.api.KubevirtNodeAdminService) List(java.util.List) TunnelEndPoints(org.onosproject.net.behaviour.TunnelEndPoints) INIT(org.onosproject.kubevirtnode.api.KubevirtNodeState.INIT) DeviceEvent(org.onosproject.net.device.DeviceEvent) ClusterService(org.onosproject.cluster.ClusterService) KubevirtNodeState(org.onosproject.kubevirtnode.api.KubevirtNodeState) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig) InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) KubevirtNodeUtil.resolveHostname(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.resolveHostname) Tools(org.onlab.util.Tools) BridgeDescription(org.onosproject.net.behaviour.BridgeDescription) ComponentContext(org.osgi.service.component.ComponentContext) TUNNEL_BRIDGE(org.onosproject.kubevirtnode.api.Constants.TUNNEL_BRIDGE) PORT_NAME(org.onosproject.net.AnnotationKeys.PORT_NAME) TunnelKey(org.onosproject.net.behaviour.TunnelKey) APP_ID(org.onosproject.kubevirtnode.api.KubevirtNodeService.APP_ID) COMPLETE(org.onosproject.kubevirtnode.api.KubevirtNodeState.COMPLETE) INCOMPLETE(org.onosproject.kubevirtnode.api.KubevirtNodeState.INCOMPLETE) KubevirtNodeHandler(org.onosproject.kubevirtnode.api.KubevirtNodeHandler) PHYSICAL_TO_INTEGRATION_SUFFIX(org.onosproject.kubevirtnode.api.Constants.PHYSICAL_TO_INTEGRATION_SUFFIX) INTEGRATION_TO_PHYSICAL_PREFIX(org.onosproject.kubevirtnode.api.Constants.INTEGRATION_TO_PHYSICAL_PREFIX) KubevirtApiConfigService(org.onosproject.kubevirtnode.api.KubevirtApiConfigService) Component(org.osgi.service.component.annotations.Component) WORKER(org.onosproject.kubevirtnode.api.KubevirtNode.Type.WORKER) Lists(com.google.common.collect.Lists) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) TENANT_BRIDGE_PREFIX(org.onosproject.kubevirtnode.api.Constants.TENANT_BRIDGE_PREFIX) KubevirtNodeUtil.structurePortName(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.structurePortName) Activate(org.osgi.service.component.annotations.Activate) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) ControllerInfo(org.onosproject.net.behaviour.ControllerInfo) DeviceListener(org.onosproject.net.device.DeviceListener) Logger(org.slf4j.Logger) BRIDGE_PREFIX(org.onosproject.kubevirtnode.api.Constants.BRIDGE_PREFIX) STT(org.onosproject.kubevirtnode.api.Constants.STT) PatchDescription(org.onosproject.net.behaviour.PatchDescription) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription) FLOW_KEY(org.onosproject.kubevirtnode.api.Constants.FLOW_KEY) OVSDB_PORT_NUM_DEFAULT(org.onosproject.kubevirtnode.impl.OsgiPropertyConstants.OVSDB_PORT_NUM_DEFAULT) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) KubevirtNodeEvent(org.onosproject.kubevirtnode.api.KubevirtNodeEvent) KubevirtNodeListener(org.onosproject.kubevirtnode.api.KubevirtNodeListener) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) TUNNEL_TO_INTEGRATION(org.onosproject.kubevirtnode.api.Constants.TUNNEL_TO_INTEGRATION) VXLAN(org.onosproject.kubevirtnode.api.Constants.VXLAN) Reference(org.osgi.service.component.annotations.Reference) KubevirtNodeUtil.addOrRemoveSystemInterface(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.addOrRemoveSystemInterface) LeadershipService(org.onosproject.cluster.LeadershipService) KubevirtNodeUtil.getBooleanProperty(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.getBooleanProperty) Device(org.onosproject.net.Device) BridgeConfig(org.onosproject.net.behaviour.BridgeConfig)

Example 9 with BridgeConfig

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

Example 10 with BridgeConfig

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

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