Exemplo n.º 1
0
 def test_init_from_config_list(self, mock_fetch):
     self.cfg.config(odl_features_json=None, group='ml2_odl')
     self.cfg.config(odl_features=self.feature_list, group='ml2_odl')
     odl_features.init()
     self.assertTrue(odl_features.has('thing1'))
     self.assertTrue(odl_features.has('thing2'))
     mock_fetch.assert_not_called()
Exemplo n.º 2
0
 def test_init_from_json_overrides_list(self, mock_fetch):
     self.cfg.config(odl_features=self.feature_list, group='ml2_odl')
     self.cfg.config(odl_features_json=self.feature_json, group='ml2_odl')
     odl_features.init()
     self.assertFalse(odl_features.has('thing1'))
     self.assertTrue(odl_features.has('operational-port-status'))
     mock_fetch.assert_not_called()
Exemplo n.º 3
0
 def test_init_from_config_list(self, mock_fetch):
     self.cfg.config(odl_features_json=None, group='ml2_odl')
     self.cfg.config(odl_features=self.feature_list, group='ml2_odl')
     odl_features.init()
     self.assertTrue(odl_features.has('thing1'))
     self.assertTrue(odl_features.has('thing2'))
     mock_fetch.assert_not_called()
Exemplo n.º 4
0
 def test_init_from_json_overrides_list(self, mock_fetch):
     self.cfg.config(odl_features=self.feature_list, group='ml2_odl')
     self.cfg.config(odl_features_json=self.feature_json, group='ml2_odl')
     odl_features.init()
     self.assertFalse(odl_features.has('thing1'))
     self.assertTrue(odl_features.has('operational-port-status'))
     mock_fetch.assert_not_called()
Exemplo n.º 5
0
 def initialize(self):
     self.url = cfg.CONF.ml2_odl.url
     self.timeout = cfg.CONF.ml2_odl.timeout
     self.username = cfg.CONF.ml2_odl.username
     self.password = cfg.CONF.ml2_odl.password
     self.odl_drv = OpenDaylightDriver()
     self.trunk_driver = trunk_driver.OpenDaylightTrunkDriverV1.create()
     odl_features.init()
Exemplo n.º 6
0
    def test_default_values_for_supported_rules(self):
        self.cfg.config(odl_features='key', group='ml2_odl')
        odl_features.init()

        qos_driver_object = qos_driver.OpenDaylightQosDriver.create()

        self.assertDictEqual(qos_driver_object.supported_rules,
                             qos_driver.DEFAULT_QOS_RULES)
Exemplo n.º 7
0
    def test_init(self, mocked_client):
        response = mock.MagicMock()
        response.status_code = 200
        response.json = mock.MagicMock(
            return_value=jsonutils.loads(self.feature_json))
        mocked_client.return_value = response

        odl_features.init()
        self.assertTrue(odl_features.has(odl_features.OPERATIONAL_PORT_STATUS))
Exemplo n.º 8
0
    def _get_bgpvpn_driver_with_vni(self):
        feature_json = """{"features": {"feature":
                                        [{"service-provider-feature":
                                        "neutron-extensions:operational-port-status"},
                                        {"service-provider-feature":
                                        "neutron-extensions:bgpvpn-vni"}]}}"""

        self.cfg.config(odl_features_json=feature_json, group='ml2_odl')
        odl_features.init()
        bgpvpn_driver = driverv2.OpenDaylightBgpvpnDriver(service_plugin=None)
        return bgpvpn_driver
Exemplo n.º 9
0
    def _get_bgpvpn_driver_with_vni(self):
        feature_json = """{"features": {"feature":
                                        [{"service-provider-feature":
                                        "neutron-extensions:operational-port-status"},
                                        {"service-provider-feature":
                                        "neutron-extensions:bgpvpn-vni"}]}}"""

        self.cfg.config(odl_features_json=feature_json, group='ml2_odl')
        odl_features.init()
        bgpvpn_driver = driverv2.OpenDaylightBgpvpnDriver(service_plugin=None)
        return bgpvpn_driver
Exemplo n.º 10
0
 def test_prepare_inital_port_status_with_websocket(
         self, mocked_add_provisioning_component):
     feature_json = """{"features": {"feature":
                         [{"service-provider-feature":
                         "neutron-extensions:operational-port-status"}]}}"""
     self.cfg.config(odl_features_json=feature_json, group='ml2_odl')
     self.addCleanup(odl_features.deinit)
     odl_features.init()
     port_ctx = self._fake_port_context(
         fake_segments=[self.test_valid_segment])
     initial_port_status = self.mgr._prepare_initial_port_status(port_ctx)
     self.assertEqual(initial_port_status, n_const.PORT_STATUS_DOWN)
     mocked_add_provisioning_component.assert_called()
Exemplo n.º 11
0
 def initialize(self):
     LOG.debug("Initializing OpenDaylight ML2 driver")
     cfg.CONF.register_opts(odl_conf.odl_opts, "ml2_odl")
     self.sg_handler = callback.OdlSecurityGroupsHandler(
         self.sync_from_callback_precommit,
         self.sync_from_callback_postcommit)
     self.journal = journal.OpenDaylightJournalThread()
     self.port_binding_controller = port_binding.PortBindingManager.create()
     self.trunk_driver = trunk_driver.OpenDaylightTrunkDriverV2.create()
     if odl_const.ODL_QOS in cfg.CONF.ml2.extension_drivers:
         qos_driver.OpenDaylightQosDriver.create()
     self._start_maintenance_thread()
     odl_features.init()
Exemplo n.º 12
0
 def _setUp(self):
     super(OpenDaylightFeaturesFixture, self)._setUp()
     self.cfg = self.useFixture(config_fixture.Config())
     if cfg.CONF.ml2_odl.url is None:
         self.cfg.config(url='http://127.0.0.1:9999', group='ml2_odl')
     if cfg.CONF.ml2_odl.username is None:
         self.cfg.config(username='******', group='ml2_odl')
     if cfg.CONF.ml2_odl.password is None:
         self.cfg.config(password='******', group='ml2_odl')
     # make sure _fetch_features is not called, it'll block the main thread
     self.cfg.config(odl_features_json='{"features": {"feature": []}}',
                     group='ml2_odl')
     odl_features.init()
     self.addCleanup(odl_features.deinit)
Exemplo n.º 13
0
 def _setUp(self):
     super(OpenDaylightFeaturesFixture, self)._setUp()
     self.cfg = self.useFixture(config_fixture.Config())
     if cfg.CONF.ml2_odl.url is None:
         self.cfg.config(url='http://127.0.0.1:9999', group='ml2_odl')
     if cfg.CONF.ml2_odl.username is None:
         self.cfg.config(username='******', group='ml2_odl')
     if cfg.CONF.ml2_odl.password is None:
         self.cfg.config(password='******', group='ml2_odl')
     # make sure _fetch_features is not called, it'll block the main thread
     self.cfg.config(odl_features_json='{"features": {"feature": []}}',
                     group='ml2_odl')
     odl_features.init()
     self.addCleanup(odl_features.deinit)
Exemplo n.º 14
0
    def test_qos_supported_rules_are_fetched_from_odl_feature(self):
        feature_json = """{"features": {"feature":
                                [{"service-provider-feature":
                                "neutron-extensions:operational-port-status"},
                                {"service-provider-feature":
                                "neutron-extensions:qos-rules",
                                "configuration": {"key": "value"}}]}}"""

        self.cfg.config(odl_features_json=feature_json, group='ml2_odl')
        odl_features.init()

        qos_driver_object = qos_driver.OpenDaylightQosDriver.create()

        self.assertDictEqual(qos_driver_object.supported_rules,
                             {'key': 'value'})
Exemplo n.º 15
0
    def initialize(self):
        LOG.debug("Initializing OpenDaylight ML2 driver")
        cfg.CONF.register_opts(odl_conf.odl_opts, "ml2_odl")
        self.sg_handler = callback.OdlSecurityGroupsHandler(
            self.sync_from_callback_precommit,
            self.sync_from_callback_postcommit)
        self.journal = journal.OpenDaylightJournalThread()
        self.port_binding_controller = port_binding.PortBindingManager.create()
        self.trunk_driver = trunk_driver.OpenDaylightTrunkDriverV2.create()
        if odl_const.ODL_QOS in cfg.CONF.ml2.extension_drivers:
            qos_driver.OpenDaylightQosDriver.create()
        if cfg.CONF.ml2_odl.enable_dhcp_service:
            self.dhcp_driver = dhcp_driver.OdlDhcpDriver()

        full_sync.register(nlib_const.CORE, L2_RESOURCES)
        odl_features.init()
Exemplo n.º 16
0
    def initialize(self):
        LOG.debug("Initializing OpenDaylight ML2 driver")
        cfg.CONF.register_opts(odl_conf.odl_opts, "ml2_odl")
        self.sg_handler = callback.OdlSecurityGroupsHandler(
            self.sync_from_callback_precommit,
            self.sync_from_callback_postcommit)
        self.journal = journal.OpenDaylightJournalThread()
        self.port_binding_controller = port_binding.PortBindingManager.create()
        self.trunk_driver = trunk_driver.OpenDaylightTrunkDriverV2.create()
        if cfg.CONF.ml2_odl.enable_dhcp_service:
            self.dhcp_driver = dhcp_driver.OdlDhcpDriver()

        full_sync.register(nlib_const.CORE, self.RESOURCES)
        odl_features.init()

        if odl_const.ODL_QOS in cfg.CONF.ml2.extension_drivers:
            qos_driver.OpenDaylightQosDriver.create()
Exemplo n.º 17
0
 def _assert_odl_feature_config(self, features):
     odl_features.init()
     for k, v in features.items():
         self.assertTrue(odl_features.has(k))
         self.assertEqual(odl_features.get_config(k), v)
Exemplo n.º 18
0
 def test_init_without_config_calls__fetch_features(self, mock_fetch):
     self.cfg.config(odl_features_json=None, group='ml2_odl')
     self.cfg.config(odl_features=None, group='ml2_odl')
     odl_features.init()
     mock_fetch.assert_called_once()
Exemplo n.º 19
0
 def test_init_from_config(self):
     cfg.CONF.set_override('odl_features', 'thing1,thing2', 'ml2_odl')
     odl_features.init()
     self.assertTrue(odl_features.has('thing1'))
     self.assertTrue(odl_features.has('thing2'))
Exemplo n.º 20
0
 def test_init_with_config_does_not_call__fetch_features(self, mock_fetch):
     self.cfg.config(odl_features_json=self.feature_json, group='ml2_odl')
     odl_features.init()
     mock_fetch.assert_not_called()
Exemplo n.º 21
0
 def test_init_from_config(self):
     self.cfg.config(odl_features='thing1,thing2', group='ml2_odl')
     odl_features.init()
     self.assertTrue(odl_features.has('thing1'))
     self.assertTrue(odl_features.has('thing2'))
Exemplo n.º 22
0
 def test_init_with_config_does_not_call__fetch_features(self, mock_fetch):
     self.cfg.config(odl_features_json=self.feature_json, group='ml2_odl')
     odl_features.init()
     mock_fetch.assert_not_called()
Exemplo n.º 23
0
 def test_init_without_config_calls__fetch_features(self, mock_fetch):
     self.cfg.config(odl_features_json=None, group='ml2_odl')
     self.cfg.config(odl_features=None, group='ml2_odl')
     odl_features.init()
     mock_fetch.assert_called_once()
Exemplo n.º 24
0
 def _assert_odl_feature_config(self, features):
     odl_features.init()
     for k, v in features.items():
         self.assertTrue(odl_features.has(k))
         self.assertEqual(odl_features.get_config(k), v)