Exemple #1
0
    def delete(self, dpid=None, flow_id=None):
        logger.debug("requset url - %s", self.get_request_uri())
        logger.debug("request params - dpid: %s, flow_id: %s", dpid, flow_id)

        ret = {}
        res = None
        try:
            that_flow_id=None
            flow_list = mul.get_flow(int(dpid, 16))
            for flow in flow_list:
                that_flow_id = self.__make_flow_id(int(dpid,16), flow.flow, flow.mask, flow.priority)
                if that_flow_id == flow_id:
                    res = mul.delete_static_flow(flow.datapath_id,
                                         flow.flow,
                                         flow.mask,
                                         flow.priority)
                    if res != 0:
                        raise Exception, 'cannot delete this flow'
                    else:
                        ret.update({
                            "flow_id": flow_id
                        })
            #if not res:
            #    raise Exception, 'No such flow_id'
        except Exception, e:
            ret.update({'error_message' : 'Failed to delete flow', 'reason' : str(e)})
Exemple #2
0
    def delete(self, dpid=None, flow_id=None):
        logger.debug("requset url - %s", self.get_request_uri())
        logger.debug("request params - dpid: %s, flow_id: %s", dpid, flow_id)

        ret = {}
        res = None
        try:
            that_flow_id = None
            flow_list = mul.get_flow(int(dpid, 16))
            for flow in flow_list:
                that_flow_id = self.__make_flow_id(int(dpid, 16), flow.flow,
                                                   flow.mask, flow.priority)
                if that_flow_id == flow_id:
                    res = mul.delete_static_flow(flow.datapath_id, flow.flow,
                                                 flow.mask, flow.priority)
                    if res != 0:
                        raise Exception, 'cannot delete this flow'
                    else:
                        ret.update({"flow_id": flow_id})
            #if not res:
            #    raise Exception, 'No such flow_id'
        except Exception, e:
            ret.update({
                'error_message': 'Failed to delete flow',
                'reason': str(e)
            })
Exemple #3
0
 def __check_flow_realy_in_switch(self, dpid, new_flow, new_mask, new_prio):
     flow_id = None
     flow_list = mul.get_flow(dpid)
     for flow in flow_list:
         if mul.compare_flows(new_flow, flow.flow) == 0 and\
            mul.compare_flows(new_mask, flow.mask) == 0 and\
            new_prio == flow.priority:
             flow_id = self.__make_flow_id(dpid, flow.flow, flow.mask, flow.priority)
     return flow_id
Exemple #4
0
 def __check_flow_realy_in_switch(self, dpid, new_flow, new_mask, new_prio):
     flow_id = None
     flow_list = mul.get_flow(dpid)
     for flow in flow_list:
         if mul.compare_flows(new_flow, flow.flow) == 0 and\
            mul.compare_flows(new_mask, flow.mask) == 0 and\
            new_prio == flow.priority:
             flow_id = self.__make_flow_id(dpid, flow.flow, flow.mask,
                                           flow.priority)
     return flow_id
Exemple #5
0
 def __get_switch_flow(self, dpid, table_id=None):
     ret = []
     flows = mul.get_flow(int(dpid, 16))
     for flow in flows:
         if table_id==None or int(table_id)==flow.flow.table_id \
              or (table_id==-1 and flow.flags & mul.C_FL_ENT_GSTATS):
             flow_id = self.__make_flow_id(int(dpid, 16), flow.flow, flow.mask, flow.priority)
             flow_dict = self.__c_ofp_flow_info_serialization(flow)
             flow_dict.update({'flow_id': flow_id})
             flow_dict.update(self.__nbapi_action_serialization(flow))
             ret.append(flow_dict)
     return {'flows':ret}
Exemple #6
0
 def __get_switch_flow(self, dpid, table_id=None):
     ret = []
     flows = mul.get_flow(int(dpid, 16))
     for flow in flows:
         if table_id==None or int(table_id)==flow.flow.table_id \
              or (table_id==-1 and flow.flags & mul.C_FL_ENT_GSTATS):
             flow_id = self.__make_flow_id(int(dpid, 16), flow.flow,
                                           flow.mask, flow.priority)
             flow_dict = self.__c_ofp_flow_info_serialization(flow)
             flow_dict.update({'flow_id': flow_id})
             flow_dict.update(self.__nbapi_action_serialization(flow))
             ret.append(flow_dict)
     return {'flows': ret}
Exemple #7
0
 def delete(self, dpid=None, flow_id=None):
     ret = {}
     try:
         that_flow_id=None
         flow_list = mul.get_flow(int(dpid, 16))
         for flow in flow_list:
             that_flow_id = self.__make_flow_id(dpid, flow.flow, flow.mask, flow.priority)
             if that_flow_id == flow_id:
                 res = mul.delete_static_flow(flow.datapath_id,
                                      flow.flow,
                                      flow.mask,
                                      flow.priority)
                 if res != 0:
                     raise Exception, 'cannot delete this flow'
                 else:
                     ret.update({
                         "flow_id": flow_id
                     })
         if that_flow_id == None:
             raise Exception, 'No such flow_id'
     except Exception, e:
         ret.update({'error_message' : 'Failed to delete flow', 'reason' : str(e)})