コード例 #1
0
 def setUp(self):
     super(L3AgentFipQoSExtensionTestFramework, self).setUp()
     self.conf.set_override('extensions', ['fip_qos'], 'agent')
     self.agent = neutron_l3_agent.L3NATAgentWithStateReport(
         'agent1', self.conf)
     self._set_pull_mock()
     self.set_test_qos_rules(
         TEST_POLICY_ID1,
         [self.test_bw_limit_rule_1, self.test_bw_limit_rule_2])
     self.set_test_qos_rules(TEST_POLICY_ID2, [self.test_bw_limit_rule_3])
     self.set_test_qos_rules(TEST_POLICY_ID3, [self.test_bw_limit_rule_4])
     self.fip_qos_ext = fip_qos.FipQosAgentExtension()
コード例 #2
0
    def setUp(self):
        super(QosExtensionBaseTestCase, self).setUp()

        self.fip_qos_ext = fip_qos.FipQosAgentExtension()
        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()}
        self.fip = {
            'id': _uuid(),
            'floating_ip_address': TEST_QOS_FIP,
            '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()
        self.router = {
            'id': self.router_id,
            'gw_port': self.ex_gw_port,
            'ha': False,
            'distributed': False,
            lib_const.FLOATINGIP_KEY: [self.fip]
        }
        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, None)
        self.fip_qos_ext.consume_api(self.agent_api)