예제 #1
0
    def test_init(self, mocked_bagpipe_bgp_agent):
        int_br = self.br_int_cls("br-int")
        tun_br = self.br_tun_cls("br-tun")
        agent_extension_api = ovs_ext_agt.OVSAgentExtensionAPI(int_br,
                                                               tun_br)

        self.agent_ext.consume_api(agent_extension_api)
        self.agent_ext.initialize(self.connection,
                                  ovs_agt_constants.EXTENSION_DRIVER_TYPE,
                                  )

        mocked_bagpipe_bgp_agent.assert_called_once_with(
            const.AGENT_TYPE_OVS,
            self.connection,
            int_br=mock.ANY,
            tun_br=mock.ANY
            )

        call_kwargs = mocked_bagpipe_bgp_agent.call_args_list[0][1]

        self.assertIsInstance(call_kwargs['int_br'],
                              ovs_ext_agt.OVSCookieBridge)
        self.assertIs(call_kwargs['int_br'].bridge,
                      int_br)

        self.assertIsInstance(call_kwargs['tun_br'],
                              bagpipe_agt_ext.OVSBridgeIntercept)
        self.assertIs(call_kwargs['tun_br'].bridge,
                      tun_br)
예제 #2
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 test_request_phys_brs(self):
     agent_extension_api = ovs_ext_agt.OVSAgentExtensionAPI(
         self.br_int, self.br_tun, {
             'phys1': self.br_phys['br-phys1'],
             'phys2': self.br_phys['br-phys2']
         })
     for phys_br in agent_extension_api.request_phy_brs():
         self._test_bridge(self.br_phys[phys_br.br_name], phys_br)
예제 #4
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
예제 #5
0
 def initialize_ovs_fw_log(self):
     self.int_br = ovs_ext_api.OVSCookieBridge(
         self.of_helper.br_int_cls(self.tester.bridge.br_name))
     self.tun_br = self.of_helper.br_tun_cls('br-tun')
     agent_api = ovs_ext_api.OVSAgentExtensionAPI(
         self.int_br, self.tun_br,
         {'physnet1': self.of_helper.br_phys_cls('br-physnet1')})
     log_driver = ovs_fw_log.OVSFirewallLoggingDriver(agent_api)
     log_driver.initialize(self.resource_rpc)
     return log_driver
예제 #6
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()
예제 #7
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()
예제 #8
0
    def setUp(self):
        super(LocalIPAgentExtensionTestCase, self).setUp()
        self.context = context.get_admin_context_without_session()
        self.local_ip_ext = local_ip_ext.LocalIPAgentExtension()

        self.plugin_rpc = mock.Mock()
        self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(
            int_br=mock.Mock(),
            tun_br=mock.Mock(),
            phys_brs=None,
            plugin_rpc=self.plugin_rpc)
        self.local_ip_ext.consume_api(self.agent_api)
        with mock.patch.object(self.local_ip_ext,
                               '_pull_all_local_ip_associations'):
            self.local_ip_ext.initialize(mock.Mock(), 'ovs')
        self.int_br = self.local_ip_ext.int_br
예제 #9
0
 def setUp(self):
     super(DHCPAgentExtensionTestCase, self).setUp()
     cfg.CONF.set_override('enable_ipv6', True, group='DHCP')
     self.context = context.get_admin_context()
     self.int_br = mock.Mock()
     self.tun_br = mock.Mock()
     self.plugin_rpc = mock.Mock()
     self.remote_resource_cache = mock.Mock()
     self.plugin_rpc.remote_resource_cache = self.remote_resource_cache
     self.ovs_dhcp = ovs_dhcp.DHCPAgentExtension()
     self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(
         self.int_br,
         self.tun_br,
         phys_brs=None,
         plugin_rpc=self.plugin_rpc)
     self.ovs_dhcp.consume_api(self.agent_api)
     self.ovs_dhcp.initialize(None, None)
예제 #10
0
    def setUp(self):
        ovs_test_base.OVSOFCtlTestBase.setUp(self)
        BaseTestAgentExtension.setUp(self)

        self.int_br = self.br_int_cls("br-int")
        self.int_br.add_patch_port = mock.Mock(side_effect=add_patch_port_int)
        self.int_br.get_port_ofport = mock.Mock(
            side_effect=get_port_ofport_int_br)
        self.int_br.add_flow = mock.Mock()
        self.int_br.delete_flows = mock.Mock()
        self.int_br.use_at_least_protocol = mock.Mock()

        self.tun_br = self.br_tun_cls("br-tun")
        self.tun_br.add_patch_port = mock.Mock(side_effect=add_patch_port_tun)
        self.tun_br.get_port_ofport = mock.Mock(
            side_effect=get_port_ofport_tun_br)
        self.tun_br.add_flow = mock.Mock()
        self.tun_br.delete_flows = mock.Mock()

        agent_extension_api = ovs_ext_agt.OVSAgentExtensionAPI(
            self.int_br, self.tun_br)
        self.agent_ext.consume_api(agent_extension_api)

        br_exists_patcher = mock.patch(
            'neutron.agent.common.ovs_lib.OVSBridge.bridge_exists',
            return_value=True)
        br_exists_patcher.start()
        self.addCleanup(br_exists_patcher.stop)

        add_patch_patcher = mock.patch(
            'neutron.agent.common.ovs_lib.OVSBridge'
            '.add_patch_port',
            side_effect=add_patch_port_mpls)
        add_patch_patcher.start()
        self.addCleanup(add_patch_patcher.stop)

        self.agent_ext.initialize(self.connection,
                                  ovs_agt_constants.EXTENSION_DRIVER_TYPE)

        self.vlan_manager = vlanmanager.LocalVlanManager()
        for net_id, vlan in LOCAL_VLAN_MAP.items():
            try:
                self.vlan_manager.add(net_id, vlan, None, None, None)
            except vlanmanager.MappingAlreadyExists:
                pass
예제 #11
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()
예제 #12
0
    def setUp(self):
        super(DHCPResponderBaseTestCase, self).setUp()
        self.int_br = mock.Mock()
        self.tun_br = mock.Mock()
        self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(self.int_br,
                                                          self.tun_br,
                                                          phys_brs=None)
        self.ext_api = mock.Mock()
        self.base_responer = dhcp_resp_base.DHCPResponderBase(
            self.agent_api, self.ext_api)
        self.base_responer.int_br = self.int_br

        self.base_responer.get_dhcp_options = mock.Mock()
        self.base_responer.get_ret_packet = mock.Mock()
        self.base_responer.get_state = mock.Mock()
        self.base_responer.handle_dhcp = mock.Mock()

        self.port_info = PORT_INFO
예제 #13
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()
     os_ken_app = mock.Mock()
     self.agent_api = ovs_ext_api.OVSAgentExtensionAPI(
                      ovs_bridge.OVSAgentBridge(
                          'br-int', os_ken_app=os_ken_app),
                      ovs_bridge.OVSAgentBridge(
                          'br-tun', os_ken_app=os_ken_app),
                      {'phys1': ovs_bridge.OVSAgentBridge(
                          'br-phys1', os_ken_app=os_ken_app)})
     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_dp = mock.Mock(return_value=(mock.Mock(),
                                                             mock.Mock(),
                                                             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.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)
예제 #14
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)
예제 #15
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)
 def test_request_tun_br_tunneling_disabled(self):
     agent_extension_api = ovs_ext_agt.OVSAgentExtensionAPI(
         self.br_int, None, {'phys': self.br_phys['br-phys1']})
     self.assertIsNone(agent_extension_api.request_tun_br())
 def test_request_tun_br(self):
     agent_extension_api = ovs_ext_agt.OVSAgentExtensionAPI(
         self.br_int, self.br_tun, {'phys': self.br_phys['br-phys1']})
     new_tun_br = agent_extension_api.request_tun_br()
     self._test_bridge(self.br_tun, new_tun_br)
 def test_request_tun_br(self):
     agent_extension_api = ovs_ext_agt.OVSAgentExtensionAPI(
         self.br_int, self.br_tun)
     new_tun_br = agent_extension_api.request_tun_br()
     self._test_bridge(self.br_tun, new_tun_br)