示例#1
0
  @Override
  public String getControllerUuid(String controllerName, String controllerTarget) {
    DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
    OvsdbRowStore rowStore = getRowStore(OvsdbConstant.DATABASENAME, OvsdbConstant.CONTROLLER);
    if (rowStore == null) {
      log.debug("The controller uuid is null");
      return null;
    }

    ConcurrentMap<String, Row> controllerTableRows = rowStore.getRowStore();
    if (controllerTableRows != null) {
      for (String uuid : controllerTableRows.keySet()) {

        Controller controller =
            (Controller)
                TableGenerator.getTable(
                    dbSchema, controllerTableRows.get(uuid), OvsdbTable.CONTROLLER);
        String target = (String) controller.getTargetColumn().data();
        if (target.equalsIgnoreCase(controllerTarget)) {
          return uuid;
        }
      }
    }
    return null;
  }
示例#2
0
  @Override
  public String getBridgeUuid(String bridgeName) {
    DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);

    OvsdbRowStore rowStore = getRowStore(OvsdbConstant.DATABASENAME, OvsdbConstant.BRIDGE);
    if (rowStore == null) {
      log.debug("The bridge uuid is null");
      return null;
    }

    ConcurrentMap<String, Row> bridgeTableRows = rowStore.getRowStore();
    if (bridgeTableRows == null) {
      log.debug("The bridge uuid is null");
      return null;
    }

    for (String uuid : bridgeTableRows.keySet()) {
      Bridge bridge =
          (Bridge) TableGenerator.getTable(dbSchema, bridgeTableRows.get(uuid), OvsdbTable.BRIDGE);

      if (bridge.getName().equals(bridgeName)) {
        return uuid;
      }
    }
    return null;
  }
示例#3
0
 @Override
 public void removeRow(String dbName, String tableName, String uuid) {
   OvsdbTableStore tableStore = getTableStore(dbName);
   if (tableStore == null) {
     return;
   }
   OvsdbRowStore rowStore = tableStore.getRows(tableName);
   if (rowStore == null) {
     return;
   }
   rowStore.deleteRow(uuid);
 }
示例#4
0
 /**
  * Gets the ovsdb row.
  *
  * @param dbName the ovsdb database name
  * @param tableName the ovsdb table name
  * @param uuid the key of the row
  * @return row, empty if row is find
  */
 @Override
 public Row getRow(String dbName, String tableName, String uuid) {
   OvsdbTableStore tableStore = getTableStore(dbName);
   if (tableStore == null) {
     return null;
   }
   OvsdbRowStore rowStore = tableStore.getRows(tableName);
   if (rowStore == null) {
     return null;
   }
   return rowStore.getRow(uuid);
 }
示例#5
0
 @Override
 public void updateOvsdbStore(String dbName, String tableName, String uuid, Row row) {
   OvsdbTableStore tableStore = ovsdbStore.getOvsdbTableStore(dbName);
   if (tableStore == null) {
     tableStore = new OvsdbTableStore();
   }
   OvsdbRowStore rowStore = tableStore.getRows(tableName);
   if (rowStore == null) {
     rowStore = new OvsdbRowStore();
   }
   rowStore.insertRow(uuid, row);
   tableStore.createOrUpdateTable(tableName, rowStore);
   ovsdbStore.createOrUpdateOvsdbStore(dbName, tableStore);
 }
示例#6
0
 @Override
 public String getOvsUuid(String dbName) {
   OvsdbRowStore rowStore = getRowStore(OvsdbConstant.DATABASENAME, OvsdbConstant.DATABASENAME);
   if (rowStore == null) {
     log.debug("The bridge uuid is null");
     return null;
   }
   ConcurrentMap<String, Row> ovsTableRows = rowStore.getRowStore();
   if (ovsTableRows != null) {
     for (String uuid : ovsTableRows.keySet()) {
       Row row = ovsTableRows.get(uuid);
       String tableName = row.tableName();
       if (tableName.equals(dbName)) {
         return uuid;
       }
     }
   }
   return null;
 }
示例#7
0
 @Override
 public Set<OvsdbPort> getPorts() {
   Set<OvsdbPort> ovsdbPorts = new HashSet<OvsdbPort>();
   OvsdbTableStore tableStore = getTableStore(OvsdbConstant.DATABASENAME);
   if (tableStore == null) {
     return null;
   }
   OvsdbRowStore rowStore = tableStore.getRows(OvsdbConstant.INTERFACE);
   if (rowStore == null) {
     return null;
   }
   ConcurrentMap<String, Row> rows = rowStore.getRowStore();
   for (String uuid : rows.keySet()) {
     Row row = getRow(OvsdbConstant.DATABASENAME, OvsdbConstant.INTERFACE, uuid);
     OvsdbPort ovsdbPort = getOvsdbPort(row);
     if (ovsdbPort != null) {
       ovsdbPorts.add(ovsdbPort);
     }
   }
   return ovsdbPorts;
 }
示例#8
0
 @Override
 public Set<OvsdbBridge> getBridges() {
   Set<OvsdbBridge> ovsdbBridges = new HashSet<OvsdbBridge>();
   OvsdbTableStore tableStore = getTableStore(OvsdbConstant.DATABASENAME);
   if (tableStore == null) {
     return null;
   }
   OvsdbRowStore rowStore = tableStore.getRows(OvsdbConstant.BRIDGE);
   if (rowStore == null) {
     return null;
   }
   ConcurrentMap<String, Row> rows = rowStore.getRowStore();
   for (String uuid : rows.keySet()) {
     Row row = getRow(OvsdbConstant.DATABASENAME, OvsdbConstant.BRIDGE, uuid);
     OvsdbBridge ovsdbBridge = getOvsdbBridge(row);
     if (ovsdbBridge != null) {
       ovsdbBridges.add(ovsdbBridge);
     }
   }
   return ovsdbBridges;
 }