def __get_switch_meter_with_id(self, dpid, meter_id): meters = None ret = {} try: if version == 0: raise Exception, 'no such switch' if version == 1: raise Exception, 'Not supported switch OFP version' meters = mul.get_meter(int(dpid, 16)) for meter in meters: if meter_id == meter.meter_id: ret = self.__c_ofp_meter_mod_serialization(meter) if ret is {}: raise Exception, 'No such meter_id' except Exception, e: ret = { 'error_message' : 'failed to get meter', 'reason' : str(e)}
def __get_switch_meter(self, dpid): ret = {} res = [] try: version = mul.nbapi_get_switch_version_with_id(int(dpid, 16)) if version == 0: raise Exception, 'no such switch' if version == 1: raise Exception, 'Not supported switch OPF version' try: meters = mul.get_meter(int(dpid, 16)) except: meters = [] for meter in meters: m_dict = self.__c_ofp_meter_mod_serialization(meter) res.append(m_dict) ret.update({'meters' : res}) except Exception, e: ret.update({'error_message' : 'Failed to get meter', 'reason':str(e)})