def extend_port_dict(self, session, model, result): """Implementation of abstract method from ExtensionDriver class.""" LOG.debug("RK: extend_port_dict()") port_id = result.get('id') with session.begin(subtransactions=True): try: res = rk_db.get_vif_profile(port_id, session) result[rk_const.RK_MIN_RATE] = res.min_rate result[rk_const.RK_MAX_RATE] = res.max_rate except Exception as e: # Do nothing if the port is not found. LOG.debug("RK: do nothing... port not found: %s" % e) LOG.debug("RK: extended result: %s", result)
def process_update_port(self, context, data, result): """Implementation of abstract method from ExtensionDriver class.""" LOG.debug("RK: process_update_port(). data: %s", data) port_id = result.get('id') port_min_attr = data.get(rk_const.RK_MIN_RATE) port_max_attr = data.get(rk_const.RK_MAX_RATE) with context.session.begin(subtransactions=True): try: res = rk_db.get_vif_profile(port_id, context.session) port_min_attr = res.min_rate if not port_min_attr else port_min_attr port_max_attr = res.max_rate if not port_max_attr else port_max_attr rk_db.update_vif_rate_limit(port_id, port_min_attr, port_max_attr, context.session) except Exception as e: # Do nothing if the port is not found. LOG.debug("RK: do nothing... port not found: %s", e)
def get_port_rates(self, rpc_context, **kwargs): """RPC for getting port rate info. This method provides information about the ratekeeper rates a given port. """ result = {} port_id = kwargs.get('port_id') LOG.debug("RK: get_port_rates_list: %s", port_id) try: res = rk_db.get_vif_profile(port_id) result = { rk_const.RK_MIN_RATE:res.min_rate, rk_const.RK_MAX_RATE:res.max_rate } except Exception as e: # Do nothing if the port is not found. LOG.debug("RK: do nothing... port not found: %s", e) return result