コード例 #1
0
    def setUp(self):
        cfg.CONF.set_override('apps_list', self.apps_list, group='df')
        super(DFAppTestBase, self).setUp()
        mock.patch('ryu.base.app_manager.AppManager.get_instance').start()
        self.controller = df_local_controller.DfLocalController('fake_host')
        self.nb_api = self.controller.nb_api = mock.MagicMock()
        self.vswitch_api = self.controller.vswitch_api = mock.MagicMock()
        kwargs = dict(nb_api=self.controller.nb_api,
                      vswitch_api=self.controller.vswitch_api,
                      db_store=self.controller.db_store)
        self.controller.open_flow_app = ryu_base_app.RyuDFAdapter(**kwargs)
        self.open_flow_app = self.controller.open_flow_app
        self.datapath = self.open_flow_app._datapath = mock.Mock()
        self.open_flow_app.load(self.controller.open_flow_app, **kwargs)
        self.controller.topology = topology.Topology(self.controller, False)

        # Add basic network topology
        self.controller.logical_switch_updated(fake_logic_switch1)
        self.controller.logical_switch_updated(fake_external_switch1)
        self.controller.router_updated(fake_logic_router1)

        self.arp_responder = mock.patch(
            'dragonflow.controller.common.arp_responder.ArpResponder').start()
        mock.patch(
            'dragonflow.controller.df_base_app.DFlowApp.mod_flow').start()
        mock.patch('dragonflow.controller.df_base_app.DFlowApp.'
                   'add_flow_go_to_table').start()
コード例 #2
0
 def setUp(self):
     super(TestDfController, self).setUp()
     dispatcher.AppDispatcher = mock.Mock()
     db_store.DbStore = mock.Mock()
     cfg.CONF = mock.Mock()
     self.controller = df_local_controller.DfLocalController('fakechassis')
     self.controller.nb_api = mock.Mock()
     self.controller.vswitch_api = mock.Mock()
コード例 #3
0
    def setUp(self, enable_selective_topo_dist=False):
        extra_apps = ['portbinding']
        cfg.CONF.set_override(
            'apps_list',
            self.apps_list + extra_apps,
            group='df',
        )
        cfg.CONF.set_override('host', fake_chassis1.id)
        super(DFAppTestBase, self).setUp()
        self.useFixture(log_fixture.SetLogLevel([None], logging.DEBUG))
        mock_app = mock.patch(
            'ryu.base.app_manager.AppManager.get_instance').start()
        self.addCleanup(mock_app.stop)
        mock_nb = mock.patch('dragonflow.db.api_nb.NbApi.get_instance')
        mock_nb.start()
        self.addCleanup(mock_nb.stop)
        mod_flow = mock.patch(
            'dragonflow.controller.df_base_app.DFlowApp.mod_flow')
        mod_flow_mock = mod_flow.start()
        self.addCleanup(mod_flow.stop)
        add_flow_go_to_table_mock_patch = mock.patch(
            'dragonflow.controller.df_base_app.DFlowApp.add_flow_go_to_table')
        add_flow_go_to_table = add_flow_go_to_table_mock_patch
        add_flow_go_to_table_mock = add_flow_go_to_table.start()
        self.addCleanup(add_flow_go_to_table_mock_patch.stop)
        execute = mock.patch('neutron.agent.common.utils.execute')
        execute_mock = execute.start()
        self.addCleanup(execute.stop)

        # CLear old objects from cache
        db_store.get_instance().clear()

        self.nb_api = api_nb.NbApi.get_instance(False)
        self.controller = df_local_controller.DfLocalController(
            fake_chassis1.id, self.nb_api)
        self.vswitch_api = self.controller.vswitch_api = mock.MagicMock()
        kwargs = dict(
            nb_api=self.controller.nb_api,
            vswitch_api=self.controller.vswitch_api,
        )
        self.controller.open_flow_app = ryu_base_app.RyuDFAdapter(**kwargs)
        self.open_flow_app = self.controller.open_flow_app
        self.datapath = self.open_flow_app._datapath = mock.Mock()
        self.open_flow_app.load(self.controller.open_flow_app, **kwargs)
        self.topology = self.controller.topology = topology.Topology(
            self.controller, enable_selective_topo_dist)

        # Add basic network topology
        self.controller.update(fake_logic_switch1)
        self.controller.update(fake_lswitch_default_subnets[0])
        self.controller.update(fake_external_switch1)
        self.controller.update(fake_logic_router1)
        self.controller.db_store.update(fake_chassis1)
        self.controller.db_store.update(fake_chassis2)

        mod_flow_mock.reset_mock()
        add_flow_go_to_table_mock.reset_mock()
        execute_mock.reset_mock()
コード例 #4
0
    def setUp(self, enable_selective_topo_dist=False):
        cfg.CONF.set_override('apps_list', self.apps_list, group='df')
        super(DFAppTestBase, self).setUp()
        mock.patch('ryu.base.app_manager.AppManager.get_instance').start()
        mock.patch('dragonflow.db.api_nb.NbApi.get_instance').start()
        mod_flow = mock.patch(
            'dragonflow.controller.df_base_app.DFlowApp.mod_flow').start()
        add_flow_go_to_table_mock_patch = mock.patch(
            'dragonflow.controller.df_base_app.DFlowApp.add_flow_go_to_table')
        add_flow_go_to_table = add_flow_go_to_table_mock_patch.start()
        execute = mock.patch('neutron.agent.common.utils.execute').start()

        # CLear old objects from cache
        db_store._instance = None

        nb_api = api_nb.NbApi.get_instance(False)
        self.controller = df_local_controller.DfLocalController(
            'fake_host', nb_api)
        self.nb_api = self.controller.nb_api = mock.MagicMock()
        self.vswitch_api = self.controller.vswitch_api = mock.MagicMock()
        kwargs = dict(
            nb_api=self.controller.nb_api,
            vswitch_api=self.controller.vswitch_api,
        )
        self.controller.open_flow_app = ryu_base_app.RyuDFAdapter(**kwargs)
        self.open_flow_app = self.controller.open_flow_app
        self.datapath = self.open_flow_app._datapath = mock.Mock()
        self.open_flow_app.load(self.controller.open_flow_app, **kwargs)
        self.topology = self.controller.topology = topology.Topology(
            self.controller, enable_selective_topo_dist)

        # Add basic network topology
        self.controller.update(fake_logic_switch1)
        self.controller.update(fake_external_switch1)
        self.controller.update(fake_logic_router1)
        self.controller.db_store.update(fake_chassis1)
        self.controller.db_store.update(fake_chassis2)

        mod_flow.reset_mock()
        add_flow_go_to_table.reset_mock()
        execute.reset_mock()