def setUp(self):
     super(RouterGatewayIPQosAgentExtensionTestFramework, self).setUp()
     self.conf.set_override('extensions', ['gateway_ip_qos'], 'agent')
     self.agent = neutron_l3_agent.L3NATAgentWithStateReport(
         'agent1', self.conf)
     self._set_pull_mock()
     self.set_test_qos_rules(
         INGRESS_EGRESS_POLICY_ID,
         [self.test_bw_limit_rule_1, self.test_bw_limit_rule_2])
     self.set_test_qos_rules(INGRESS_POLICY_ID, [self.test_bw_limit_rule_3])
     self.set_test_qos_rules(EGRESS_POLICY_ID, [self.test_bw_limit_rule_4])
     self.gateway_ip_qos_ext = (
         gateway_ip_qos.RouterGatewayIPQosAgentExtension())
Ejemplo n.º 2
0
    def setUp(self):
        super(QosExtensionBaseTestCase, self).setUp()

        self.gw_ip_qos_ext = gateway_ip_qos.RouterGatewayIPQosAgentExtension()
        self.context = context.get_admin_context()
        self.connection = mock.Mock()

        self.policy = policy.QosPolicy(context=None, name='test1', id=_uuid())
        self.ingress_rule = (rule.QosBandwidthLimitRule(
            context=None,
            id=_uuid(),
            qos_policy_id=self.policy.id,
            max_kbps=1111,
            max_burst_kbps=2222,
            direction=lib_const.INGRESS_DIRECTION))
        self.egress_rule = (rule.QosBandwidthLimitRule(
            context=None,
            id=_uuid(),
            qos_policy_id=self.policy.id,
            max_kbps=3333,
            max_burst_kbps=4444,
            direction=lib_const.EGRESS_DIRECTION))
        self.policy.rules = [self.ingress_rule, self.egress_rule]

        self.new_ingress_rule = (rule.QosBandwidthLimitRule(
            context=None,
            id=_uuid(),
            qos_policy_id=self.policy.id,
            max_kbps=5555,
            max_burst_kbps=6666,
            direction=lib_const.INGRESS_DIRECTION))
        self.ingress_rule_only_has_max_kbps = (rule.QosBandwidthLimitRule(
            context=None,
            id=_uuid(),
            qos_policy_id=self.policy.id,
            max_kbps=5555,
            max_burst_kbps=0,
            direction=lib_const.INGRESS_DIRECTION))

        self.policy2 = policy.QosPolicy(context=None, name='test2', id=_uuid())
        self.policy2.rules = [self.ingress_rule]

        self.policy3 = policy.QosPolicy(context=None, name='test3', id=_uuid())
        self.policy3.rules = [self.egress_rule]

        self.policy4 = policy.QosPolicy(context=None, name='test4', id=_uuid())
        self.dscp = rule.QosDscpMarkingRule(context=None,
                                            id=_uuid(),
                                            qos_policy_id=self.policy4.id,
                                            dscp_mark=32)
        self.dscp.obj_reset_changes()
        self.policy4.rules = [self.dscp]

        self.qos_policies = {
            self.policy.id: self.policy,
            self.policy2.id: self.policy2,
            self.policy3.id: self.policy3,
            self.policy4.id: self.policy4
        }

        self.agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
        self.ex_gw_port = {
            'id': _uuid(),
            'fixed_ips': [{
                'ip_address': TEST_QOS_GW_IP
            }],
            'qos_policy_id': self.policy.id,
            'enable_snat': True
        }
        self.fip = {
            'id': _uuid(),
            'floating_ip_address': '172.24.4.9',
            'fixed_ip_address': '192.168.0.1',
            'floating_network_id': _uuid(),
            'port_id': _uuid(),
            'host': HOSTNAME,
            'qos_policy_id': self.policy.id
        }
        self.router = {
            'id': _uuid(),
            'gw_port': self.ex_gw_port,
            'ha': False,
            'distributed': False,
            lib_const.FLOATINGIP_KEY: [self.fip],
            'external_gateway_info': self.ex_gw_port
        }
        self.router_info = l3router.RouterInfo(self.agent, self.router['id'],
                                               self.router, **self.ri_kwargs)
        self.router_info.ex_gw_port = self.ex_gw_port
        self.agent.router_info[self.router['id']] = self.router_info

        def _mock_get_router_info(router_id):
            return self.router_info

        self.get_router_info = mock.patch(
            'neutron.agent.l3.l3_agent_extension_api.'
            'L3AgentExtensionAPI.get_router_info').start()
        self.get_router_info.side_effect = _mock_get_router_info

        self.agent_api = l3_ext_api.L3AgentExtensionAPI(None)
        self.gw_ip_qos_ext.consume_api(self.agent_api)