def setUp(self):
        # Set URL/user/pass so init doesn't throw a cfg required error.
        # They are not used in these tests since sendjson is overwritten.
        config.cfg.CONF.set_override('url', 'http://127.0.0.1:9999', 'ml2_odl')
        config.cfg.CONF.set_override('username', 'someuser', 'ml2_odl')
        config.cfg.CONF.set_override('password', 'somepass', 'ml2_odl')

        super(OpenDaylightTestCase, self).setUp()
        self.port_create_status = 'DOWN'
        self.mech = mech_driver.OpenDaylightMechanismDriver()
        mock.patch.object(client.OpenDaylightRestClient,
                          'sendjson',
                          new=self.check_sendjson).start()

        # Prevent test from accidentally connecting to any web service
        mock.patch.object(
            network_topology,
            'NetworkTopologyClient',
            return_value=mock.Mock(
                specs=network_topology.NetworkTopologyClient,
                get=mock.Mock(side_effect=requests.HTTPError))).start()

        # Prevent hosts resolution from changing the behaviour of tests
        mock.patch.object(network_topology.utils,
                          'get_addresses_by_name',
                          side_effect=socket.gaierror).start()
 def setUp(self):
     super(OpenDaylightMechanismDriverTestCase, self).setUp()
     self.useFixture(odl_base.OpenDaylightRestClientFixture())
     config.cfg.CONF.set_override('mechanism_drivers',
                                  ['logger', 'opendaylight'], 'ml2')
     self.mech = mech_driver.OpenDaylightMechanismDriver()
     self.mech.initialize()
Example #3
0
    def test_bind_port_from_mech_driver_with_vhostuser(self):

        given_client = self.mock_client('vhostuser_topology.json')
        self.mock_get_addresses_by_name(['127.0.0.1', '192.168.66.1'])
        given_network_topology = network_topology.NetworkTopologyManager(
            vif_details={'some': 'detail'},
            client=given_client)
        self.patch(
            network_topology, 'NetworkTopologyManager',
            return_value=given_network_topology)

        given_driver = mech_driver.OpenDaylightMechanismDriver()
        given_driver.odl_drv = mech_driver.OpenDaylightDriver()
        given_port_context = self.given_port_context()

        # when port is bound
        given_driver.bind_port(given_port_context)

        expected_vif_details = {
            'vhostuser_socket': '/var/run/openvswitch/vhuCURRENT_CON',
            'vhostuser_ovs_plug': True,
            'some': 'detail',
            'vhostuser_mode': 'client'}

        # then context binding is setup with returned vif_type and valid
        # segment api ID
        given_port_context.set_binding.assert_called_once_with(
            self.valid_segment[api.ID],
            portbindings.VIF_TYPE_VHOST_USER,
            expected_vif_details, status=n_constants.PORT_STATUS_ACTIVE)
Example #4
0
    def test_bind_port_front_end(self):
        given_front_end = mech_driver.OpenDaylightMechanismDriver()
        if hasattr(given_front_end, 'check_segment'):
            self.skip(
                "Old version of driver front-end doesn't delegate bind_port to"
                " back-end.")

        given_vif_type = "MY_VIF_TYPE"
        given_port_context = self.given_port_context()
        given_back_end = mech_driver.OpenDaylightDriver()
        given_back_end._get_vif_type = mock.Mock(return_value=given_vif_type)
        given_front_end.odl_drv = given_back_end

        # when port is bound
        given_front_end.bind_port(given_port_context)

        # then vif type is got calling _get_vif_type
        given_back_end._get_vif_type.assert_called_once_with(
            given_port_context)

        # then context binding is setup wit returned vif_type and valid
        # segment api ID
        given_port_context.set_binding.assert_called_once_with(
            self.valid_segment[api.ID],
            given_vif_type,
            given_back_end.vif_details,
            status=n_constants.PORT_STATUS_ACTIVE)
 def setUp(self):
     super(OpenDaylightMechanismDriverTestCase, self).setUp()
     config.cfg.CONF.set_override('mechanism_drivers',
                                  ['logger', 'opendaylight'], 'ml2')
     config.cfg.CONF.set_override('url', 'http://127.0.0.1:9999', 'ml2_odl')
     config.cfg.CONF.set_override('username', 'someuser', 'ml2_odl')
     config.cfg.CONF.set_override('password', 'somepass', 'ml2_odl')
     self.mech = mech_driver.OpenDaylightMechanismDriver()
     self.mech.initialize()
 def setUp(self):
     self.useFixture(odl_base.OpenDaylightRestClientFixture())
     self.useFixture(odl_base.OpenDaylightFeaturesFixture())
     self.useFixture(odl_base.OpenDaylightPseudoAgentPrePopulateFixture())
     super(OpenDaylightMechanismDriverTestCase, self).setUp()
     cfg.CONF.set_override('mechanism_drivers', ['logger', 'opendaylight'],
                           'ml2')
     self.mech = mech_driver.OpenDaylightMechanismDriver()
     self.mech.initialize()
 def setUp(self):
     self.useFixture(odl_base.OpenDaylightRestClientFixture())
     self.useFixture(odl_base.OpenDaylightFeaturesFixture())
     super(OpenDaylightTestCase, self).setUp()
     self.port_create_status = 'DOWN'
     self.mech = mech_driver.OpenDaylightMechanismDriver()
     mock.patch.object(client.OpenDaylightRestClient,
                       'sendjson',
                       new=self.check_sendjson).start()
 def setUp(self):
     self.useFixture(odl_base.OpenDaylightRestClientFixture())
     self.useFixture(odl_base.OpenDaylightFeaturesFixture())
     self.useFixture(odl_base.OpenDaylightPseudoAgentPrePopulateFixture())
     self.cfg = self.useFixture(config_fixture.Config())
     super(OpenDaylightMechanismDriverTestCase, self).setUp()
     self.cfg.config(mechanism_drivers=[
                     'logger', 'opendaylight'], group='ml2')
     self.mech = mech_driver.OpenDaylightMechanismDriver()
     self.mech.initialize()
Example #9
0
    def setUp(self):
        # Set URL/user/pass so init doesn't throw a cfg required error.
        # They are not used in these tests since sendjson is overwritten.
        config.cfg.CONF.set_override('url', 'http://127.0.0.1:9999', 'ml2_odl')
        config.cfg.CONF.set_override('username', 'someuser', 'ml2_odl')
        config.cfg.CONF.set_override('password', 'somepass', 'ml2_odl')

        super(OpenDaylightTestCase, self).setUp()
        self.port_create_status = 'DOWN'
        self.mech = mech_driver.OpenDaylightMechanismDriver()
        mock.patch.object(client.OpenDaylightRestClient,
                          'sendjson',
                          new=self.check_sendjson).start()
    def test_bind_port_front_end(self):
        given_front_end = mech_driver.OpenDaylightMechanismDriver()
        given_port_context = self.given_port_context()
        given_back_end = mech_driver.OpenDaylightDriver()
        given_front_end.odl_drv = given_back_end

        # when port is bound
        given_front_end.bind_port(given_port_context)

        # then context binding is setup with returned vif_type and valid
        # segment API ID
        given_port_context.set_binding.assert_called_once_with(
            self.valid_segment[api.ID],
            portbindings.VIF_TYPE_OVS,
            given_back_end.vif_details,
            status=n_constants.PORT_STATUS_ACTIVE)
    def setUp(self):
        self.useFixture(odl_base.OpenDaylightRestClientFixture())
        super(OpenDaylightTestCase, self).setUp()
        self.port_create_status = 'DOWN'
        self.mech = mech_driver.OpenDaylightMechanismDriver()
        mock.patch.object(client.OpenDaylightRestClient,
                          'sendjson',
                          new=self.check_sendjson).start()

        # Prevent test from accidentally connecting to any web service
        mock.patch.object(
            network_topology,
            'NetworkTopologyClient',
            return_value=mock.Mock(
                specs=network_topology.NetworkTopologyClient,
                get=mock.Mock(side_effect=requests.HTTPError))).start()

        # Prevent hosts resolution from changing the behaviour of tests
        mock.patch.object(network_topology.utils,
                          'get_addresses_by_name',
                          side_effect=socket.gaierror).start()
Example #12
0
    def test_bind_port_from_mech_driver_with_ovs(self):

        given_client = self.mock_client('ovs_topology.json')
        self.mock_get_addresses_by_name(['127.0.0.1', '10.237.214.247'])
        given_network_topology = network_topology.NetworkTopologyManager(
            vif_details={'some': 'detail'},
            client=given_client)
        self.patch(
            network_topology, 'NetworkTopologyManager',
            return_value=given_network_topology)

        given_driver = mech_driver.OpenDaylightMechanismDriver()
        given_driver.odl_drv = mech_driver.OpenDaylightDriver()
        given_port_context = self.given_port_context()

        # when port is bound
        given_driver.bind_port(given_port_context)

        # then context binding is setup with returned vif_type and valid
        # segment api ID
        given_port_context.set_binding.assert_called_once_with(
            self.valid_segment[api.ID], portbindings.VIF_TYPE_OVS,
            {'some': 'detail'}, status=n_constants.PORT_STATUS_ACTIVE)
Example #13
0
 def setUp(self):
     super(TestODLShim, self).setUp()
     self.context = context.get_admin_context()
     self.plugin = mock.Mock()
     self.driver = driver.OpenDaylightMechanismDriver()
     self.driver.odl_drv = mock.Mock()