Example #1
0
  @Override
  public String getSliceStats(String sliceName) throws SliceNotFound, PermissionDeniedException {

    if (!(doesSliceExist(sliceName))) {
      throw new SliceNotFound("Slice does not exist: " + sliceName);
    }

    FVSlicer fvSlicer = null;
    for (Iterator<FVEventHandler> it = FlowVisor.getInstance().getHandlersCopy().iterator();
        it.hasNext(); ) {
      FVEventHandler eventHandler = it.next();
      if (eventHandler instanceof FVClassifier) {
        FVClassifier classifier = (FVClassifier) eventHandler;
        if (!classifier.isIdentified()) // only print switches have have
          // been identified
          continue;
        fvSlicer = classifier.getSlicerByName(sliceName);
        if (fvSlicer != null) {
          break;
        }
      }
    }

    if (fvSlicer == null) return SendRecvDropStats.NO_STATS_AVAILABLE_MSG;

    return fvSlicer.getStats().combinedString();
  }
Example #2
0
  @Override
  public Map<String, String> getSliceInfo(String sliceName)
      throws PermissionDeniedException, SliceNotFound {

    /*
     * relaxed security -- anyone can read slice info for now String user =
     * APIUserCred.getUserName(); if (!FVConfig.isSupervisor(user) &&
     * !APIAuth.transitivelyCreated(user, sliceName)) throw new
     * PermissionDeniedException(
     * "not superuser or transitive slice creator");
     */
    if (!(doesSliceExist(sliceName))) {
      throw new SliceNotFound("Slice does not exist: " + sliceName);
    }

    HashMap<String, String> map = new HashMap<String, String>();

    synchronized (FVConfig.class) {
      try {
        map.put("contact_email", FVConfig.getSliceEmail(sliceName));
        map.put("controller_hostname", FVConfig.getSliceHost(sliceName));
        map.put("controller_port", String.valueOf(FVConfig.getSlicePort(sliceName)));
        map.put("creator", FVConfig.getSliceCreator(sliceName));
        map.put("drop_policy", FVConfig.getSlicePolicy(sliceName));
      } catch (ConfigError e) {
        FVLog.log(LogLevel.CRIT, null, "malformed slice: " + e);
        e.printStackTrace();
      }
    }
    long dpid;
    int connection = 1;

    // TODO: come back an architect this so we can walk the list of slicers,
    // not the list of classifiers, and then slicers
    for (Iterator<FVEventHandler> it = FlowVisor.getInstance().getHandlersCopy().iterator();
        it.hasNext(); ) {
      FVEventHandler eventHandler = it.next();
      if (eventHandler instanceof FVClassifier) {
        FVClassifier classifier = (FVClassifier) eventHandler;
        if (!classifier.isIdentified()) // only print switches have have
          // been identified
          continue;
        dpid = classifier.getDPID();
        FVSlicer fvSlicer = classifier.getSlicerByName(sliceName);
        if (fvSlicer != null) {
          map.put(
              "connection_" + connection++,
              FlowSpaceUtil.dpidToString(dpid) + "-->" + fvSlicer.getConnectionName());
        }
      }
    }

    return map;
  }
Example #3
0
 @Override
 public Map<String, List<Map<String, String>>> getSliceRewriteDB(String sliceName, String dpidStr)
     throws DPIDNotFound, SliceNotFound, PermissionDeniedException {
   long dpid = FlowSpaceUtil.parseDPID(dpidStr);
   FVSlicer fvSlicer = lookupSlicer(sliceName, dpid);
   Map<String, List<Map<String, String>>> ret = new HashMap<String, List<Map<String, String>>>();
   FlowRewriteDB flowRewriteDB = fvSlicer.getFlowRewriteDB();
   synchronized (flowRewriteDB) {
     for (FlowDBEntry original : flowRewriteDB.originals()) {
       Map<String, String> originalMap = original.toBracketMap();
       List<Map<String, String>> rewrites = new LinkedList<Map<String, String>>();
       for (FlowDBEntry rewrite : flowRewriteDB.getRewrites(original)) {
         rewrites.add(rewrite.toBracketMap());
       }
       ret.put(BracketParse.encode(originalMap), rewrites);
     }
   }
   return ret;
 }
Example #4
0
  private void lookupByFlowSpace(FVClassifier fvClassifier) {
    SliceAction sliceAction;
    int perms;
    // grab single matching rule: only one because it's a point in flowspace
    FlowEntry flowEntry =
        fvClassifier
            .getSwitchFlowMap()
            .matches(
                fvClassifier.getSwitchInfo().getDatapathId(),
                this.getInPort(),
                this.getPacketData());
    if (flowEntry == null) {
      FVLog.log(
          LogLevel.DEBUG, fvClassifier, "dropping unclassifiable msg: " + this.toVerboseString());
      return;
    }

    boolean foundHome = false;
    // foreach slice in that rule
    for (OFAction ofAction : flowEntry.getActionsList()) {
      sliceAction = (SliceAction) ofAction;
      perms = sliceAction.getSlicePerms();
      if ((perms & (SliceAction.READ | SliceAction.WRITE)) != 0) {
        // lookup slice and send msg to them
        // TODO record buffer id for later validation
        FVSlicer fvSlicer = fvClassifier.getSlicerByName(sliceAction.getSliceName());
        if (fvSlicer == null) {
          FVLog.log(
              LogLevel.WARN,
              fvClassifier,
              "tried to send msg to non-existant slice: "
                  + sliceAction.getSliceName()
                  + " corrupted flowspace?:: "
                  + this.toVerboseString());
          continue;
        }
        if (fvSlicer.isConnected()) {
          if ((perms & SliceAction.WRITE) != 0) fvSlicer.setBufferIDAllowed(this.getBufferId());
          fvSlicer.sendMsg(this, fvClassifier);
          /**
           * TODO : come back and decide if we should uncomment this i.e., should a rule get
           * squashed if it's only recipient is read only
           *
           * <p>if yes, then tests-readonly.py needs to be changed
           */

          // if ((perms & SliceAction.WRITE) != 0)
          foundHome = true;
        } else {
          sendDropRule(fvClassifier, flowEntry, fvSlicer.getSliceName(), (short) 0, (short) 1);
        }
        foundHome = true;
      }
      /*
       * ash: not sure if this is the intended behavior, but I am guessing
       * that if this packet hasn't gotten handled anywhere we should at least
       * default to adding a drop rule for unless we want to be flooded.
       */
      if (!foundHome) sendDropRule(fvClassifier, flowEntry, "exact", (short) 0, (short) 1);
    }
  }