Example #1
0
 def _update_weight(self, dpid1, dpid2, weight="weight", value="1"):
     try:
         graph = core.overseer_topology.graph
         dpid1 = int(dpid1, 16)
         dpid2 = int(dpid2, 16)
         value = float(value)
         if graph.has_edge(dpid1, dpid2):
             graph[dpid1][dpid2][weight] = value
             return utils.create_response("")
         else:
             return make_error("Invalid link")
     except ValueError:
         return make_error("dpid must be hex and value must be float")
Example #2
0
 def _update_weight(self, dpid1, dpid2, weight="weight", value="1"):
   try:
     graph = core.overseer_topology.graph
     dpid1 = int(dpid1, 16)
     dpid2 = int(dpid2, 16)
     value = float(value)
     if graph.has_edge(dpid1, dpid2):
       graph[dpid1][dpid2][weight] = value
       return utils.create_response("")
     else:
       return make_error("Invalid link")
   except ValueError:
     return make_error("dpid must be hex and value must be float")
Example #3
0
 def _exec_set_entry(self, quintet, option):
   try:
     path_identifier = utils.deserialize_path_identifier(quintet)
     core.overseer.path_preference_table._table[path_identifier] = ApiHandler.OPTIONS[option]
     return utils.create_response("")
   except KeyError:
     return make_error("No such entry in path preference table")
Example #4
0
 def _exec_get_entry(self, quintet):
   try:
     path_identifier = utils.deserialize_path_identifier(quintet)
     entry = core.overseer.path_preference_table._table[path_identifier]
     return utils.create_response(ApiHandler.REVERSED_OPTIONS[entry])
   except KeyError:
     return make_error("No such entry in path preference table")
Example #5
0
  def _exec_get_flow_stats (self, dpid, *args, **kw):
    dpid = strToDPID(dpid)
    con = core.openflow.getConnection(dpid)
    if con is None:
      return make_error("No such switch")

    return OFFlowStatsRequest(con, *args, **kw).get_response()
Example #6
0
  def _exec_get_switch_desc (self, dpid):
    dpid = strToDPID(dpid)
    con = core.openflow.getConnection(dpid)
    if con is None:
      return make_error("No such switch")

    return OFSwitchDescRequest(con).get_response()
Example #7
0
  def _exec_set_table (self, dpid, flows):
    dpid = strToDPID(dpid)
    con = core.openflow.getConnection(dpid)
    if con is None:
      return make_error("No such switch")

    return OFSetTableRequest(con, flows).get_response()
Example #8
0
    def _exec_set_table(self, dpid, flows):
        dpid = strToDPID(dpid)
        con = core.openflow.getConnection(dpid)
        if con is None:
            return make_error("No such switch")

        return OFSetTableRequest(con, flows).get_response()
Example #9
0
    def _exec_get_switch_desc(self, dpid):
        dpid = strToDPID(dpid)
        con = core.openflow.getConnection(dpid)
        if con is None:
            return make_error("No such switch")

        return OFSwitchDescRequest(con).get_response()
Example #10
0
 def _exec_remove_entry(self, quintet):
     try:
         path_identifier = utils.deserialize_path_identifier(quintet)
         del core.overseer.path_preference_table._table[path_identifier]
         return utils.create_response("")
     except KeyError:
         return make_error("No such entry in path preference table")
Example #11
0
 def _exec_get_entry(self, quintet):
     try:
         path_identifier = utils.deserialize_path_identifier(quintet)
         entry = core.overseer.path_preference_table._table[path_identifier]
         return utils.create_response(ApiHandler.REVERSED_OPTIONS[entry])
     except KeyError:
         return make_error("No such entry in path preference table")
Example #12
0
 def _exec_remove_entry(self, quintet):
   try:
     path_identifier = utils.deserialize_path_identifier(quintet)
     del core.overseer.path_preference_table._table[path_identifier]
     return utils.create_response("")
   except KeyError:
     return make_error("No such entry in path preference table")
Example #13
0
    def _exec_get_flow_stats(self, dpid, *args, **kw):
        dpid = strToDPID(dpid)
        con = core.openflow.getConnection(dpid)
        if con is None:
            return make_error("No such switch")

        return OFFlowStatsRequest(con, *args, **kw).get_response()
Example #14
0
 def _exec_get_pstats (self, dpid, *args, **kw):
   dpid = strToDPID(dpid)
   con = core.openflow.getConnection(dpid)
   if con is None:
     return make_error("No such switch")
   params = OFPortStatsRequest(con, *args, **kw).get_response()
   params['ver'] = self.version
   return params
Example #15
0
 def _exec_set_entry(self, quintet, option):
     try:
         path_identifier = utils.deserialize_path_identifier(quintet)
         core.overseer.path_preference_table._table[
             path_identifier] = ApiHandler.OPTIONS[option]
         return utils.create_response("")
     except KeyError:
         return make_error("No such entry in path preference table")
Example #16
0
 def _exec_get_astats (self, dpid):
   dpid = strToDPID(dpid)
   con = core.openflow.getConnection(dpid)
   if con is None:
     return make_error("No such switch")
   params = OFAggregateStatsRequest(con).get_response()
   params['ver'] = self.version
   return params
  def _exec_send (self, session_id, msg, seq = None):
    """
    Send a message (or messages)

    If seq is specified, it is a sequence number.  This can help
    eliminate problems with ordering.
    """
    ses = self._get_session(session_id)
    if ses is None:
      return make_error("No such session")
    r = ses.rx(msg, seq)
    if isinstance(r, dict) and 'result' in r:
      r['result']['session'] = ses._session_id
    return r
Example #18
0
    def _exec_send(self, session_id, msg, seq=None):
        """
    Send a message (or messages)

    If seq is specified, it is a sequence number.  This can help
    eliminate problems with ordering.
    """
        ses = self._get_session(session_id)
        if ses is None:
            return make_error("No such session")
        r = ses.rx(msg, seq)
        if isinstance(r, dict) and 'result' in r:
            r['result']['session'] = ses._session_id
        return r
Example #19
0
 def _handle_ErrorIn (self, event):
   if event.ofp.xid != self.xid: return
   self._finish(make_error("OpenFlow Error", data=event.asString()))
Example #20
0
 def _handle_ErrorIn (self, event):
   if event.ofp.xid != self.xid: return
   if self.done: return
   self.clear_table()
   self.done = True
   self._finish(make_error("OpenFlow Error", data=event.asString()))
Example #21
0
 def _handle_ErrorIn(self, event):
     if event.ofp.xid != self.xid: return
     if self.done: return
     self.clear_table()
     self.done = True
     self._finish(make_error("OpenFlow Error", data=event.asString()))
Example #22
0
 def _handle_ErrorIn(self, event):
     if event.ofp.xid != self.xid: return
     self._finish(make_error("OpenFlow Error", data=event.asString()))