Search in sources :

Example 6 with InterfaceConfig

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

the class OpenstackVtapManager method setTunnelInterface.

/**
 * Creates/Removes a tunnel interface in a given openstack node by vtap network information.
 *
 * @param osNode openstack node
 * @param vtapNetwork openstack vtap network for making
 */
private boolean setTunnelInterface(OpenstackNode osNode, OpenstackVtapNetwork vtapNetwork, boolean install) {
    String tunnelName = getTunnelName(vtapNetwork.mode());
    if (tunnelName == null) {
        return false;
    }
    if (!deviceService.isAvailable(osNode.ovsdb())) {
        log.warn("Not available osNode {} ovs {}", osNode.hostname(), osNode.ovsdb());
        return false;
    }
    if (install == isInterfaceEnabled(osNode.intgBridge(), tunnelName)) {
        log.warn("Already {} {} interface on osNode ovs {}, bridge {}", install ? "add" : "remove", tunnelName, osNode.ovsdb(), osNode.intgBridge());
        return true;
    }
    Device device = deviceService.getDevice(osNode.ovsdb());
    if (device == null || !device.is(InterfaceConfig.class)) {
        log.warn("Not able to get InterfaceConfig on osNode ovs {}", osNode.ovsdb());
        return false;
    }
    InterfaceConfig ifaceConfig = device.as(InterfaceConfig.class);
    if (install) {
        TunnelDescription.Builder tunnelDesc = DefaultTunnelDescription.builder().deviceId(INTEGRATION_BRIDGE).ifaceName(tunnelName).type(getTunnelType(vtapNetwork.mode())).key((vtapNetwork.networkId() == 0) ? null : new TunnelKey<>(vtapNetwork.networkId())).remote(TunnelEndPoints.ipTunnelEndpoint(vtapNetwork.serverIp()));
        if (!ifaceConfig.addTunnelMode(tunnelName, tunnelDesc.build())) {
            log.error("Fail to create {} interface on osNode ovs {}", tunnelName, osNode.ovsdb());
            return false;
        }
    } else {
        if (!ifaceConfig.removeTunnelMode(tunnelName)) {
            log.error("Fail to remove {} interface on osNode ovs {}", tunnelName, osNode.ovsdb());
            return false;
        }
    }
    // Wait for tunnel interface create/remove complete
    synchronized (syncInterface) {
        for (int i = 0; i < INTERFACE_MANIPULATION_RETRY; i++) {
            try {
                syncInterface.wait(INTERFACE_MANIPULATION_TIMEOUT);
                if (install == isInterfaceEnabled(osNode.intgBridge(), tunnelName)) {
                    log.debug("Success to {} {} interface on osNode ovs {}, bridge {}", install ? "add" : "remove", tunnelName, osNode.ovsdb(), osNode.intgBridge());
                    return true;
                }
            } catch (InterruptedException e) {
                break;
            }
        }
    }
    log.warn("Fail to {} {} interface on osNode ovs {}, bridge {}", install ? "add" : "remove", tunnelName, osNode.ovsdb(), osNode.intgBridge());
    return false;
}
Also used : InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) Device(org.onosproject.net.Device) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription)

Example 7 with InterfaceConfig

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

the class DefaultKubevirtNodeHandler method removePhysicalPatchPorts.

private void removePhysicalPatchPorts(KubevirtNode node, String network) {
    Device device = deviceService.getDevice(node.ovsdb());
    if (device == null || !device.is(InterfaceConfig.class)) {
        log.error("Failed to remove patch interface on {}", node.ovsdb());
        return;
    }
    String intToPhyPatchPort = structurePortName(INTEGRATION_TO_PHYSICAL_PREFIX + network);
    InterfaceConfig ifaceConfig = device.as(InterfaceConfig.class);
    ifaceConfig.removePatchMode(intToPhyPatchPort);
}
Also used : InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) Device(org.onosproject.net.Device)

Example 8 with InterfaceConfig

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

the class DefaultKubevirtNodeHandler method createPatchInterfaceBetweenBrIntBrTun.

private void createPatchInterfaceBetweenBrIntBrTun(KubevirtNode node) {
    Device device = deviceService.getDevice(node.ovsdb());
    if (device == null || !device.is(InterfaceConfig.class)) {
        log.error("Failed to create patch interface on {}", node.ovsdb());
        return;
    }
    InterfaceConfig ifaceConfig = device.as(InterfaceConfig.class);
    // int bridge -> tunnel bridge
    PatchDescription brIntTunPatchDesc = DefaultPatchDescription.builder().deviceId(INTEGRATION_BRIDGE).ifaceName(INTEGRATION_TO_TUNNEL).peer(TUNNEL_TO_INTEGRATION).build();
    ifaceConfig.addPatchMode(INTEGRATION_TO_TUNNEL, brIntTunPatchDesc);
    // tunnel bridge -> int bridge
    PatchDescription brTunIntPatchDesc = DefaultPatchDescription.builder().deviceId(TUNNEL_BRIDGE).ifaceName(TUNNEL_TO_INTEGRATION).peer(INTEGRATION_TO_TUNNEL).build();
    ifaceConfig.addPatchMode(TUNNEL_TO_INTEGRATION, brTunIntPatchDesc);
}
Also used : InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) Device(org.onosproject.net.Device) DefaultPatchDescription(org.onosproject.net.behaviour.DefaultPatchDescription) PatchDescription(org.onosproject.net.behaviour.PatchDescription)

Example 9 with InterfaceConfig

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

the class DefaultKubevirtNodeHandler method createPhysicalPatchPorts.

private void createPhysicalPatchPorts(KubevirtNode node, KubevirtPhyInterface phyInterface) {
    Device device = deviceService.getDevice(node.ovsdb());
    if (device == null || !device.is(InterfaceConfig.class)) {
        log.error("Failed to create patch interface on {}", node.ovsdb());
        return;
    }
    String physicalDeviceId = BRIDGE_PREFIX + phyInterface.network();
    String intToPhyPatchPort = structurePortName(INTEGRATION_TO_PHYSICAL_PREFIX + phyInterface.network());
    String phyToIntPatchPort = structurePortName(phyInterface.network() + PHYSICAL_TO_INTEGRATION_SUFFIX);
    // integration bridge -> physical bridge
    PatchDescription intToPhyPatchDesc = DefaultPatchDescription.builder().deviceId(INTEGRATION_BRIDGE).ifaceName(intToPhyPatchPort).peer(phyToIntPatchPort).build();
    // physical bridge -> integration bridge
    PatchDescription phyToIntPatchDesc = DefaultPatchDescription.builder().deviceId(physicalDeviceId).ifaceName(phyToIntPatchPort).peer(intToPhyPatchPort).build();
    InterfaceConfig ifaceConfig = device.as(InterfaceConfig.class);
    ifaceConfig.addPatchMode(INTEGRATION_TO_PHYSICAL_PREFIX + phyInterface.network(), intToPhyPatchDesc);
    ifaceConfig.addPatchMode(phyInterface.network() + PHYSICAL_TO_INTEGRATION_SUFFIX, phyToIntPatchDesc);
    addOrRemoveSystemInterface(node, physicalDeviceId, phyInterface.intf(), deviceService, true);
}
Also used : InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) Device(org.onosproject.net.Device) DefaultPatchDescription(org.onosproject.net.behaviour.DefaultPatchDescription) PatchDescription(org.onosproject.net.behaviour.PatchDescription)

Example 10 with InterfaceConfig

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

the class DeviceInterfacesListCommand method printDevice.

private void printDevice(DeviceService deviceService, DriverService driverService, Device device) {
    super.printDevice(deviceService, device);
    if (!device.is(InterfaceConfig.class)) {
        // The relevant behavior is not supported by the device.
        print(ERROR_RESULT);
        return;
    }
    DriverHandler h = driverService.createHandler(device.id());
    InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class);
    List<DeviceInterfaceDescription> interfaces = interfaceConfig.getInterfaces();
    if (interfaces == null) {
        print(ERROR_RESULT);
    } else if (interfaces.isEmpty()) {
        print(NO_INTERFACES);
    } else {
        interfaces.forEach(this::printInterface);
    }
}
Also used : InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) DeviceInterfaceDescription(org.onosproject.net.device.DeviceInterfaceDescription) DriverHandler(org.onosproject.net.driver.DriverHandler)

Aggregations

InterfaceConfig (org.onosproject.net.behaviour.InterfaceConfig)19 Device (org.onosproject.net.Device)16 DefaultPatchDescription (org.onosproject.net.behaviour.DefaultPatchDescription)8 PatchDescription (org.onosproject.net.behaviour.PatchDescription)8 DefaultTunnelDescription (org.onosproject.net.behaviour.DefaultTunnelDescription)5 TunnelDescription (org.onosproject.net.behaviour.TunnelDescription)5 DriverHandler (org.onosproject.net.driver.DriverHandler)3 DeviceId (org.onosproject.net.DeviceId)2 DriverService (org.onosproject.net.driver.DriverService)2 DeviceInterfaceDescription (org.onosproject.net.device.DeviceInterfaceDescription)1