Beispiel #1
0
  @Override
  public List<String> listDevices() {
    FVLog.log(LogLevel.DEBUG, null, "API listDevices() by: " + APIUserCred.getUserName());
    FlowVisor fv = FlowVisor.getInstance();
    // get list from main flowvisor instance
    List<String> dpids = new ArrayList<String>();
    String dpidStr;

    /*
     * if (TopologyController.isConfigured()) { for (Long dpid :
     * TopologyController.getRunningInstance() .listDevices()) { dpidStr =
     * HexString.toHexString(dpid); if (!dpids.contains(dpidStr))
     * dpids.add(dpidStr); else FVLog.log(LogLevel.WARN, TopologyController
     * .getRunningInstance(), "duplicate dpid detected: " + dpidStr); } }
     * else {
     */
    // only list a device is we have a features reply for it
    for (FVEventHandler handler : fv.getHandlersCopy()) {
      if (handler instanceof FVClassifier) {
        OFFeaturesReply featuresReply = ((FVClassifier) handler).getSwitchInfo();
        if (featuresReply != null) {
          dpidStr = FlowSpaceUtil.dpidToString(featuresReply.getDatapathId());
          if (!dpids.contains(dpidStr)) dpids.add(dpidStr);
          else FVLog.log(LogLevel.WARN, handler, "duplicate dpid detected: " + dpidStr);
        }
      }
    }
    // }
    return dpids;
  }
Beispiel #2
0
 /** The topologyController handles LLDP messages and ignores everything else */
 @Override
 public void topologyController(TopologyConnection topologyConnection) {
   synchronized (topologyConnection) {
     DPIDandPort dpidandport = TopologyConnection.parseLLDP(this.getPacketData());
     if (dpidandport == null) {
       FVLog.log(
           LogLevel.DEBUG,
           topologyConnection,
           "ignoring non-lldp packetin: " + this.toVerboseString());
       return;
     }
     OFFeaturesReply featuresReply = topologyConnection.getFeaturesReply();
     if (featuresReply == null) {
       FVLog.log(LogLevel.WARN, topologyConnection, "ignoring packet_in: no features_reply yet");
       return;
     }
     LinkAdvertisement linkAdvertisement =
         new LinkAdvertisement(
             dpidandport.getDpid(),
             dpidandport.getPort(),
             featuresReply.getDatapathId(),
             this.inPort);
     topologyConnection.getTopologyController().reportProbe(linkAdvertisement);
     topologyConnection.signalFastPort(this.inPort);
   }
 }
 @Override
 @JsonIgnore
 public void setFeaturesReply(OFFeaturesReply featuresReply) {
   synchronized (portLock) {
     if (stringId == null) {
       /* ports are updated via port status message, so we
        * only fill in ports on initial connection.
        */
       for (OFPhysicalPort port : featuresReply.getPorts()) {
         setPort(port);
       }
     }
     this.datapathId = featuresReply.getDatapathId();
     this.capabilities = featuresReply.getCapabilities();
     this.buffers = featuresReply.getBuffers();
     this.actions = featuresReply.getActions();
     this.tables = featuresReply.getTables();
     this.stringId = HexString.toHexString(this.datapathId);
   }
 }
Beispiel #4
0
 /*
  * (non-Javadoc)
  *
  * @see org.flowvisor.api.FVUserAPI#getDeviceInfo()
  */
 @Override
 public Map<String, String> getDeviceInfo(String dpidStr) throws DPIDNotFound {
   Map<String, String> map = new HashMap<String, String>();
   long dpid = HexString.toLong(dpidStr);
   FVClassifier fvClassifier = null;
   for (FVEventHandler handler : FlowVisor.getInstance().getHandlersCopy()) {
     if (handler instanceof FVClassifier) {
       OFFeaturesReply featuresReply = ((FVClassifier) handler).getSwitchInfo();
       if (featuresReply != null && featuresReply.getDatapathId() == dpid) {
         fvClassifier = (FVClassifier) handler;
         break;
       }
     }
   }
   if (fvClassifier == null)
     throw new DPIDNotFound("dpid does not exist: " + dpidStr + " ::" + String.valueOf(dpid));
   OFFeaturesReply config = fvClassifier.getSwitchInfo();
   map.put("dpid", FlowSpaceUtil.dpidToString(dpid));
   if (config != null) {
     map.put("nPorts", String.valueOf(config.getPorts().size()));
     String portList = "";
     String portNames = "";
     int p;
     for (Iterator<OFPhysicalPort> it = config.getPorts().iterator(); it.hasNext(); ) {
       OFPhysicalPort port = it.next();
       p = U16.f(port.getPortNumber());
       portList += p;
       portNames += port.getName() + "(" + p + ")";
       if (it.hasNext()) {
         portList += ",";
         portNames += ",";
       }
     }
     map.put("portList", portList);
     map.put("portNames", portNames);
   } else {
     FVLog.log(LogLevel.WARN, null, "null config for: " + dpidStr);
   }
   map.put("remote", String.valueOf(fvClassifier.getConnectionName()));
   return map;
 }