Example #1
0
  @Override
  public String getPortUuid(String portName, String bridgeUuid) {
    DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);

    Row bridgeRow = getRow(OvsdbConstant.DATABASENAME, OvsdbConstant.BRIDGE, bridgeUuid);

    Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
    if (bridge != null) {
      OvsdbSet setPorts = (OvsdbSet) bridge.getPortsColumn().data();
      @SuppressWarnings("unchecked")
      Set<UUID> ports = setPorts.set();
      if (ports == null || ports.size() == 0) {
        log.warn("The port uuid is null");
        return null;
      }

      for (UUID uuid : ports) {
        Row portRow = getRow(OvsdbConstant.DATABASENAME, OvsdbConstant.PORT, uuid.value());
        Port port = (Port) TableGenerator.getTable(dbSchema, portRow, OvsdbTable.PORT);
        if (port != null && portName.equalsIgnoreCase(port.getName())) {
          return uuid.value();
        }
      }
    }
    return null;
  }