use of org.onosproject.ovsdb.rfc.table.Interface.InterfaceColumn.EXTERNALIDS in project onos by opennetworkinglab.
the class OpenstackRecoverPortsCommand method recoverOvsPort.
/**
* Recovers the openvswitch port from conf.db corruption.
*
* @param controller ovsdb controller
* @param ovsdbPort ovsdb port number
* @param node openstack node
* @param osPort an openstack port
* @param ovsPorts set of openvswitch ports
*
* @return a set of recovered port name
*/
private Set<String> recoverOvsPort(OvsdbController controller, int ovsdbPort, OpenstackNode node, Port osPort, List<org.onosproject.net.Port> ovsPorts) {
OvsdbClientService client = getOvsdbClient(node, ovsdbPort, controller);
if (client == null) {
return ImmutableSet.of();
}
Set<String> portNames = ovsPorts.stream().filter(ovsPort -> ovsPort.annotations() != null || ovsPort.annotations().keys().contains(PORT_NAME)).map(ovsPort -> ovsPort.annotations().value(PORT_NAME)).collect(Collectors.toSet());
String tapPort = ifaceNameFromOsPortId(osPort.getId());
Set<String> recoveredPortNames = Sets.newConcurrentHashSet();
if (!portNames.contains(tapPort)) {
Map<String, String> extIdMap = ImmutableMap.of(ATTACHED_MAC, osPort.getMacAddress(), IFACE_ID, osPort.getId(), IFACE_STATUS, StringUtils.lowerCase(osPort.getState().name()), VM_ID, osPort.getDeviceId());
OvsdbInterface ovsIface = OvsdbInterface.builder().name(tapPort).options(ImmutableMap.of()).data(ImmutableMap.of(EXTERNALIDS, extIdMap)).build();
client.createInterface(INTEGRATION_BRIDGE, ovsIface);
recoveredPortNames.add(tapPort);
}
return ImmutableSet.copyOf(recoveredPortNames);
}
Aggregations