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