Esempio n. 1
0
  @Override
  public String getInterfaceUuid(String portUuid, String portName) {
    DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);

    Row portRow = getRow(OvsdbConstant.DATABASENAME, OvsdbConstant.PORT, portUuid);
    Port port = (Port) TableGenerator.getTable(dbSchema, portRow, OvsdbTable.PORT);

    if (port != null) {
      OvsdbSet setInterfaces = (OvsdbSet) port.getInterfacesColumn().data();
      @SuppressWarnings("unchecked")
      Set<UUID> interfaces = setInterfaces.set();

      if (interfaces == null || interfaces.size() == 0) {
        log.warn("The interface uuid is null");
        return null;
      }

      for (UUID uuid : interfaces) {
        Row intfRow = getRow(OvsdbConstant.DATABASENAME, OvsdbConstant.INTERFACE, uuid.value());
        Interface intf =
            (Interface) TableGenerator.getTable(dbSchema, intfRow, OvsdbTable.INTERFACE);
        if (intf != null && portName.equalsIgnoreCase(intf.getName())) {
          return uuid.value();
        }
      }
    }

    return null;
  }
Esempio n. 2
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;
  }