Пример #1
0
 def setUp(self):
     super(QosOVSAgentDriverTestCase, self).setUp()
     conn_patcher = mock.patch('neutron.agent.ovsdb.impl_idl._connection')
     conn_patcher.start()
     self.addCleanup(conn_patcher.stop)
     self.context = context.get_admin_context()
     self.qos_driver = qos_driver.QosOVSAgentDriver()
     self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(
         ovs_bridge.OVSAgentBridge('br-int'),
         ovs_bridge.OVSAgentBridge('br-tun'))
     self.qos_driver.consume_api(self.agent_api)
     self.qos_driver.initialize()
     self.qos_driver.br_int = mock.Mock()
     self.qos_driver.br_int.get_egress_bw_limit_for_port = mock.Mock(
         return_value=(1000, 10))
     self.qos_driver.br_int.dump_flows_for = mock.Mock(return_value=None)
     self.get = self.qos_driver.br_int.get_egress_bw_limit_for_port
     self.qos_driver.br_int.del_egress_bw_limit_for_port = mock.Mock()
     self.delete = self.qos_driver.br_int.delete_egress_bw_limit_for_port
     self.qos_driver.br_int.create_egress_bw_limit_for_port = mock.Mock()
     self.create = self.qos_driver.br_int.create_egress_bw_limit_for_port
     self.rules = [
         self._create_bw_limit_rule_obj(),
         self._create_dscp_marking_rule_obj()
     ]
     self.qos_policy = self._create_qos_policy_obj(self.rules)
     self.port = self._create_fake_port(self.qos_policy.id)
 def setUp(self):
     super(base.BaseTestCase, self).setUp()
     conn_patcher = mock.patch(
         'neutron.agent.ovsdb.native.connection.Connection.start')
     conn_patcher.start()
     self.addCleanup(conn_patcher.stop)
     self.br_int = ovs_bridge.OVSAgentBridge("br-int")
     self.br_tun = ovs_bridge.OVSAgentBridge("br-tun")
Пример #3
0
 def initialize_ovs_fw_log(self):
     mock.patch('ryu.base.app_manager.AppManager.get_instance').start()
     agent_api = ovs_ext_api.OVSAgentExtensionAPI(
         ovs_bridge.OVSAgentBridge(self.tester.bridge.br_name),
         ovs_bridge.OVSAgentBridge('br-tun'))
     log_driver = ovs_fw_log.OVSFirewallLoggingDriver(agent_api)
     log_driver.initialize(self.resource_rpc)
     return log_driver
Пример #4
0
 def setUp(self):
     super(LoggingExtensionBaseTestCase, self).setUp()
     conn_patcher = mock.patch('neutron.agent.ovsdb.impl_idl._connection')
     conn_patcher.start()
     self.agent_ext = log_ext.LoggingExtension()
     self.context = context.get_admin_context()
     self.connection = mock.Mock()
     agent_api = ovs_ext_api.OVSAgentExtensionAPI(
         ovs_bridge.OVSAgentBridge('br-int'),
         ovs_bridge.OVSAgentBridge('br-tun'))
     self.agent_ext.consume_api(agent_api)
     mock.patch(
         'neutron.manager.NeutronManager.load_class_for_provider').start()
Пример #5
0
    def setUp(self):
        super(QosExtensionBaseTestCase, self).setUp()
        self.qos_ext = qos.QosAgentExtension()
        self.context = context.get_admin_context()
        self.connection = mock.Mock()
        self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(
            ovs_bridge.OVSAgentBridge('br-int'),
            ovs_bridge.OVSAgentBridge('br-tun'))
        self.qos_ext.consume_api(self.agent_api)

        # Don't rely on used driver
        mock.patch(
            'neutron.manager.NeutronManager.load_class_for_provider',
            return_value=lambda: mock.Mock(spec=qos.QosAgentDriver)).start()
Пример #6
0
 def setUp(self):
     super(TestBRCookieOpenflow, self).setUp()
     conn_patcher = mock.patch(
         'neutron.agent.ovsdb.native.connection.Connection.start')
     conn_patcher.start()
     self.addCleanup(conn_patcher.stop)
     self.br = ovs_bridge.OVSAgentBridge('br-int')
Пример #7
0
 def initialize_ovs_fw_log(self):
     int_br = ovs_ext_api.OVSCookieBridge(
         ovs_bridge.OVSAgentBridge(self.tester.bridge.br_name))
     mock.patch('ryu.base.app_manager.AppManager.get_instance').start()
     mock.patch('neutron.agent.ovsdb.api.API.transaction').start()
     log_driver = ovs_fw_log.OVSFirewallLoggingDriver(int_br)
     log_driver.initialize(self.resource_rpc)
     return log_driver
 def setUp(self):
     super(TestOVSCookieBridge, self).setUp()
     conn_patcher = mock.patch(
         'neutron.agent.ovsdb.native.connection.Connection.start')
     conn_patcher.start()
     self.addCleanup(conn_patcher.stop)
     self.bridge = ovs_bridge.OVSAgentBridge("br-foo")
     self.bridge.do_action_flows = mock.Mock()
     self.tested_bridge = ovs_ext_agt.OVSCookieBridge(self.bridge)
Пример #9
0
    def setUp(self):
        super(QosExtensionBaseTestCase, self).setUp()
        conn_patcher = mock.patch('neutron.agent.ovsdb.impl_idl._connection')
        conn_patcher.start()
        self.addCleanup(conn_patcher.stop)
        self.qos_ext = qos.QosAgentExtension()
        self.context = context.get_admin_context()
        self.connection = mock.Mock()
        self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(
            ovs_bridge.OVSAgentBridge('br-int'),
            ovs_bridge.OVSAgentBridge('br-tun'))
        self.qos_ext.consume_api(self.agent_api)

        # Don't rely on used driver
        mock.patch.object(manager.NeutronManager,
                          'load_class_for_provider',
                          return_value=lambda: mock.Mock(
                              spec=qos_linux.QosLinuxAgentDriver)).start()
Пример #10
0
    def test_set_agent_uuid_stamp(self):
        self.br = ovs_bridge.OVSAgentBridge('br-int')
        def_cookie = self.br.default_cookie
        new_cookie = ovs_lib.generate_random_cookie()

        self.br.set_agent_uuid_stamp(new_cookie)

        self.assertEqual(new_cookie, self.br.default_cookie)
        self.assertIn(new_cookie, self.br.reserved_cookies)
        self.assertNotIn(def_cookie, self.br.reserved_cookies)
Пример #11
0
 def setUp(self):
     super(QosOVSAgentDriverTestCase, self).setUp()
     self.context = context.get_admin_context()
     self.qos_driver = qos_driver.QosOVSAgentDriver()
     self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(
                      ovs_bridge.OVSAgentBridge('br-int'),
                      ovs_bridge.OVSAgentBridge('br-tun'))
     self.qos_driver.consume_api(self.agent_api)
     self.qos_driver.initialize()
     self.qos_driver.br_int = mock.Mock()
     self.qos_driver.br_int.get_egress_bw_limit_for_port = mock.Mock(
         return_value=(1000, 10))
     self.get = self.qos_driver.br_int.get_egress_bw_limit_for_port
     self.qos_driver.br_int.del_egress_bw_limit_for_port = mock.Mock()
     self.delete = self.qos_driver.br_int.delete_egress_bw_limit_for_port
     self.qos_driver.br_int.create_egress_bw_limit_for_port = mock.Mock()
     self.create = self.qos_driver.br_int.create_egress_bw_limit_for_port
     self.rule = self._create_bw_limit_rule_obj()
     self.qos_policy = self._create_qos_policy_obj([self.rule])
     self.port = self._create_fake_port(self.qos_policy.id)
Пример #12
0
    def test_set_agent_uuid_stamp_with_reserved_cookie(self):
        self.br = ovs_bridge.OVSAgentBridge('br-int')
        def_cookie = self.br.default_cookie
        new_cookie = self.br.request_cookie()

        self.br.set_agent_uuid_stamp(new_cookie)

        self.assertEqual(new_cookie, self.br.default_cookie)
        self.assertIn(new_cookie, self.br.reserved_cookies)
        self.assertNotIn(def_cookie, self.br.reserved_cookies)
        self.assertEqual(set([new_cookie]), self.br.reserved_cookies)
Пример #13
0
    def setUp(self):
        super(SfcAgentExtensionTestCase, self).setUp()

        conn_patcher = mock.patch('neutron.agent.ovsdb.impl_idl._connection')
        conn_patcher.start()
        self.addCleanup(conn_patcher.stop)

        self.sfc_ext = sfc.SfcAgentExtension()
        self.context = context.get_admin_context()
        self.connection = mock.Mock()
        self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(
            ovs_bridge.OVSAgentBridge('br-int'),
            ovs_bridge.OVSAgentBridge('br-tun'))
        self.sfc_ext.consume_api(self.agent_api)

        # Don't rely on used driver
        mock.patch(
            'neutron.manager.NeutronManager.load_class_for_provider',
            return_value=lambda: mock.Mock(spec=sfc.SfcAgentDriver)).start()

        self.sfc_ext.initialize(self.connection,
                                constants.EXTENSION_DRIVER_TYPE)
Пример #14
0
 def setUp(self):
     super(QosOVSAgentDriverTestCase, self).setUp()
     conn_patcher = mock.patch('neutron.agent.ovsdb.impl_idl._connection')
     conn_patcher.start()
     self.addCleanup(conn_patcher.stop)
     self.context = context.get_admin_context()
     self.qos_driver = qos_driver.QosOVSAgentDriver()
     self.mock_clear_minimum_bandwidth_qos = mock.patch.object(
         self.qos_driver, '_minimum_bandwidth_initialize').start()
     self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(
         ovs_bridge.OVSAgentBridge('br-int'),
         ovs_bridge.OVSAgentBridge('br-tun'),
         {'phys1': ovs_bridge.OVSAgentBridge('br-phys1')})
     self.qos_driver.consume_api(self.agent_api)
     self.qos_driver.initialize()
     self.qos_driver.br_int = mock.Mock()
     self.qos_driver.br_int.get_egress_bw_limit_for_port = mock.Mock(
         return_value=(1000, 10))
     self.get_egress = self.qos_driver.br_int.get_egress_bw_limit_for_port
     self.get_ingress = self.qos_driver.br_int.get_ingress_bw_limit_for_port
     self.qos_driver.br_int.dump_flows_for = mock.Mock(return_value=None)
     self.qos_driver.br_int.del_egress_bw_limit_for_port = mock.Mock()
     self.delete_egress = (
         self.qos_driver.br_int.delete_egress_bw_limit_for_port)
     self.delete_ingress = (
         self.qos_driver.br_int.delete_ingress_bw_limit_for_port)
     self.create_egress = (
         self.qos_driver.br_int.create_egress_bw_limit_for_port)
     self.update_ingress = (
         self.qos_driver.br_int.update_ingress_bw_limit_for_port)
     self.rules = [
         self._create_bw_limit_rule_obj(constants.EGRESS_DIRECTION),
         self._create_bw_limit_rule_obj(constants.INGRESS_DIRECTION),
         self._create_dscp_marking_rule_obj()
     ]
     self.qos_policy = self._create_qos_policy_obj(self.rules)
     self.port = self._create_fake_port(self.qos_policy.id)
Пример #15
0
    def setUp(self):
        super(TestCookieContext, self).setUp()
        # Don't attempt to connect to ovsdb
        mock.patch('neutron.agent.ovsdb.api.from_config').start()
        # Don't trigger iptables -> ovsfw migration
        mock.patch('neutron.agent.linux.openvswitch_firewall.iptables.Helper'
                   ).start()

        self.execute = mock.patch.object(utils, "execute",
                                         spec=utils.execute).start()
        bridge = ovs_bridge.OVSAgentBridge('foo')
        mock.patch.object(ovsfw.OVSFirewallDriver,
                          'initialize_bridge',
                          return_value=bridge.deferred(
                              full_ordered=True, use_bundle=True)).start()

        self.firewall = ovsfw.OVSFirewallDriver(bridge)
        # Remove calls from firewall initialization
        self.execute.reset_mock()
 def setUp(self):
     super(base.BaseTestCase, self).setUp()
     self.br_int = ovs_bridge.OVSAgentBridge("br-int")
     self.br_tun = ovs_bridge.OVSAgentBridge("br-tun")
Пример #17
0
 def setUp(self):
     super(TestBRCookieOpenflow, self).setUp()
     self.br = ovs_bridge.OVSAgentBridge('br-int')
 def setUp(self):
     super(TestOVSCookieBridge, self).setUp()
     self.bridge = ovs_bridge.OVSAgentBridge("br-foo")
     self.bridge.do_action_flows = mock.Mock()
     self.tested_bridge = ovs_ext_agt.OVSCookieBridge(self.bridge)