'Create a QoS policy rule.
:param context: neutron api request context
:type context: neutron.context.Context
:param rule_cls: the rule object class
:type rule_cls: a class from the rule_object (qos.objects.rule) module
:param policy_id: the id of the QosPolicy for which to create the rule
:type policy_id: str uuid
:param rule_data: the rule data to be applied
:type rule_data: dict
:returns: a QoS policy rule object'

@db_base_plugin_common.convert_result_to_dict
def create_policy_rule(self, context, rule_cls, policy_id, rule_data):

    rule_type = rule_cls.rule_type
    rule_data = rule_data[(rule_type + '_rule')]
    with db_api.autonested_transaction(context.session):
        policy = self._get_policy_obj(context, policy_id)
        checker.check_bandwidth_rule_conflict(policy, rule_data)
        rule = rule_cls(context, qos_policy_id=policy_id, **rule_data)
        rule.create()
        policy.obj_load_attr('rules')
        self.validate_policy(context, policy)
        self.driver_manager.call(qos_consts.UPDATE_POLICY_PRECOMMIT, context, policy)
    self.driver_manager.call(qos_consts.UPDATE_POLICY, context, policy)
    return rule
