def _get_vsd_qos_options(db_context, policy_id):
        vsd_qos_options = {
            'dscp_options': {},
            'bandwidth_options': {},
        }
        if policy_id is None:
            return vsd_qos_options

        # The policy might not have any rules
        all_rules = qos_rule.get_rules(qos_policy.QosPolicy,
                                       db_context, policy_id)
        for rule in all_rules:
            if isinstance(rule, qos_rule.QosBandwidthLimitRule):
                vsd_qos_options['bandwidth_options'][
                    'rateLimitingActive'] = True
                if rule.max_kbps:
                    vsd_qos_options['bandwidth_options'][
                        'peak'] = float(rule.max_kbps) / 1000
                if rule.max_burst_kbps:
                    vsd_qos_options['bandwidth_options'][
                        'burst'] = rule.max_burst_kbps
            elif isinstance(rule, qos_rule.QosDscpMarkingRule):
                vsd_qos_options['dscp_options']['dscp_mark'] = rule.dscp_mark

        return vsd_qos_options
Exemplo n.º 2
0
    def _qos_rules(context, policy_id):
        """QoS Neutron rules classified per direction and type

        :param context: (context) Neutron request context
        :param policy_id: (string) Neutron QoS policy ID
        :return: (dict) nested dictionary of QoS rules, classified per
                 direction and rule type
                 {egress: {bw_limit: {max_kbps, max_burst_kbps},
                           dscp: {dscp_mark}
                  ingress: {...} }
        """
        qos_rules = {constants.EGRESS_DIRECTION: {},
                     constants.INGRESS_DIRECTION: {}}
        if policy_id is None:
            return qos_rules

        # The policy might not have any rule
        all_rules = qos_rule.get_rules(qos_policy.QosPolicy,
                                       context, policy_id)
        for rule in all_rules:
            if isinstance(rule, qos_rule.QosBandwidthLimitRule):
                r = {rule.rule_type: {'max_kbps': rule.max_kbps}}
                if rule.max_burst_kbps:
                    r[rule.rule_type]['max_burst_kbps'] = rule.max_burst_kbps
                qos_rules[rule.direction].update(r)
            elif isinstance(rule, qos_rule.QosDscpMarkingRule):
                r = {rule.rule_type: {'dscp_mark': rule.dscp_mark}}
                qos_rules[constants.EGRESS_DIRECTION].update(r)
            else:
                LOG.warning('Rule type %(rule_type)s from QoS policy '
                            '%(policy_id)s is not supported in OVN',
                            {'rule_type': rule.rule_type,
                             'policy_id': policy_id})
        return qos_rules
Exemplo n.º 3
0
 def _qos_get_ovn_options(self, admin_context, policy_id):
     all_rules = qos_rule.get_rules(admin_context, policy_id)
     options = {}
     for rule in all_rules:
         if isinstance(rule, qos_rule.QosBandwidthLimitRule):
             if rule.max_kbps:
                 options['policing_rate'] = str(rule.max_kbps)
             if rule.max_burst_kbps:
                 options['policing_burst'] = str(rule.max_burst_kbps)
     return options
Exemplo n.º 4
0
 def _qos_get_ovn_options(self, admin_context, policy_id):
     all_rules = qos_rule.get_rules(admin_context, policy_id)
     options = {}
     for rule in all_rules:
         if isinstance(rule, qos_rule.QosBandwidthLimitRule):
             if rule.max_kbps:
                 options['policing_rate'] = str(rule.max_kbps)
             if rule.max_burst_kbps:
                 options['policing_burst'] = str(rule.max_burst_kbps)
     return options
Exemplo n.º 5
0
 def _generate_port_options(self, context, policy_id):
     if policy_id is None:
         return {}
     options = {}
     # The policy might not have any rules
     all_rules = qos_rule.get_rules(context, policy_id)
     for rule in all_rules:
         if isinstance(rule, qos_rule.QosBandwidthLimitRule):
             if rule.max_kbps:
                 options['qos_max_rate'] = str(rule.max_kbps * 1000)
             if rule.max_burst_kbps:
                 options['qos_burst'] = str(rule.max_burst_kbps * 1000)
     return options
Exemplo n.º 6
0
 def _generate_port_options(self, context, policy_id):
     if policy_id is None:
         return {}
     options = {}
     # The policy might not have any rules
     all_rules = qos_rule.get_rules(context, policy_id)
     for rule in all_rules:
         if isinstance(rule, qos_rule.QosBandwidthLimitRule):
             if rule.max_kbps:
                 options["policing_rate"] = str(rule.max_kbps)
             if rule.max_burst_kbps:
                 options["policing_burst"] = str(rule.max_burst_kbps)
     return options
Exemplo n.º 7
0
 def _get_network_ports_for_policy(self, admin_context, network_id,
                                   policy_id):
     all_rules = qos_rule.get_rules(admin_context, policy_id)
     ports = self._plugin.get_ports(admin_context,
                                    filters={"network_id": [network_id]})
     port_ids = []
     for port in ports:
         include = True
         for rule in all_rules:
             if not rule.should_apply_to_port(port):
                 include = False
                 break
         if include:
             port_ids.append(port['id'])
     return port_ids
Exemplo n.º 8
0
 def _get_network_ports_for_policy(self, admin_context,
                                   network_id, policy_id):
     all_rules = qos_rule.get_rules(admin_context, policy_id)
     ports = self._plugin.get_ports(
         admin_context, filters={"network_id": [network_id]})
     port_ids = []
     for port in ports:
         include = True
         for rule in all_rules:
             if not rule.should_apply_to_port(port):
                 include = False
                 break
         if include:
             port_ids.append(port['id'])
     return port_ids
Exemplo n.º 9
0
 def _generate_port_options(self, context, policy_id):
     if policy_id is None:
         return {}
     options = {}
     # The policy might not have any rules
     all_rules = qos_rule.get_rules(qos_policy.QosPolicy, context,
                                    policy_id)
     for rule in all_rules:
         if isinstance(rule, qos_rule.QosBandwidthLimitRule):
             options['qos_max_rate'] = rule.max_kbps
             if rule.max_burst_kbps:
                 options['qos_burst'] = rule.max_burst_kbps
             options['direction'] = rule.direction
         if isinstance(rule, qos_rule.QosDscpMarkingRule):
             options['dscp_mark'] = rule.dscp_mark
             options['direction'] = constants.EGRESS_DIRECTION
     return options
Exemplo n.º 10
0
 def _generate_port_options(self, context, policy_id):
     if policy_id is None:
         return {}
     options = {}
     # The policy might not have any rules
     all_rules = qos_rule.get_rules(qos_policy.QosPolicy,
                                    context, policy_id)
     for rule in all_rules:
         if isinstance(rule, qos_rule.QosBandwidthLimitRule):
             if rule.max_kbps:
                 options['qos_max_rate'] = str(rule.max_kbps)
             if rule.max_burst_kbps:
                 options['qos_burst'] = str(rule.max_burst_kbps)
             # OVN could support both directions
             if rule.direction:
                 options['direction'] = rule.direction
             # Add dscp_mark support
             if isinstance(rule, qos_rule.QosDscpMarkingRule):
                 if rule.dscp_mark:
                     options['dscp_mark'] = rule.dscp_mark
                     options['direction'] = 'egress'
     return options
Exemplo n.º 11
0
 def _reload_rules(self):
     rules = rule_obj_impl.get_rules(self.obj_context, self.id)
     setattr(self, 'rules', rules)
     self.obj_reset_changes(['rules'])
Exemplo n.º 12
0
 def _reload_rules(self):
     rules = rule_obj_impl.get_rules(self.obj_context, self.id)
     setattr(self, 'rules', rules)
     self.obj_reset_changes(['rules'])
Exemplo n.º 13
0
 def reload_rules(self):
     rules = rule_obj_impl.get_rules(self._context, self.id)
     setattr(self, "rules", rules)
     self.obj_reset_changes(["rules"])
Exemplo n.º 14
0
 def _reload_rules(self):
     LOG.info('%s(): caller(): %s', log_utils.get_fname(1),
              log_utils.get_fname(2))
     rules = rule_obj_impl.get_rules(self, self.obj_context, self.id)
     setattr(self, 'rules', rules)
     self.obj_reset_changes(['rules'])