0

私はコントローラー用に pox の L2_learning モジュールを開発しています。コードのスケルトンは次のとおりです。

class LearningSwitch (object):
  def __init__ (self, connection, transparent):
     self.connection = connection
     self.transparent = transparent
     connection.addListeners(self)

      .
      .
      .
  def flowtable_request (self):
    for connection in core.openflow._connections.values():
     connection.send(of.ofp_stats_request(body=of.ofp_flow_stats_request()))
    log.info("Sent %i flow/port stats request(s)",len(core.openflow._connections))



  def _handle_flowstats_received(self,event):
      .
      .
      .
  def _handle_PacketIn (self, event):
      .
      .
      .
class l2_learning (object):

  def __init__ (self, transparent):
    core.openflow.addListeners(self)
    self.transparent = transparent

  def _handle_ConnectionUp (self, event):
    log.debug("Connection %s" % (event.connection,))
    LearningSwitch(event.connection, self.transparent)


def launch (transparent=False, hold_down=_flood_delay):
  """
   Starts an L2 learning switch.
  """
   try:
     global _flood_delay
     _flood_delay = int(str(hold_down), 10)
     assert _flood_delay >= 0
  except:
     raise RuntimeError("Expected hold-down to be a number")

  core.registerNew(l2_learning, str_to_bool(transparent))

コードのどこかで「flowtable_request (self)」関数を呼び出します。「_handle_flowstats_received(self,event)」関数が適切に機能するようにするには、次の 2 行をコードの最後に追加する必要があることを知っています。

c=LearningSwitch(?,?)
core.openflow.addListenerByName("FlowStatsReceived", c._handle_flowstats_received)

しかし、LearningSwitch クラスのインスタンスを作成する方法がわかりません。「接続」と「透明」の引数にどの値を渡す必要がありますか?

どんな助けでも大歓迎です。

4

0 に答える 0