Bridge between container framework networking and storage models to OpenStack networking and storage abstractions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_nested.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  2. # not use this file except in compliance with the License. You may obtain
  3. # a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations
  11. # under the License.
  12. import mock
  13. from oslo_utils import uuidutils
  14. from kuryr.lib.binding.drivers import nested
  15. from kuryr.lib import constants
  16. from kuryr.lib import utils
  17. from kuryr.tests.unit import base
  18. class TestNestedDriver(base.TestCase):
  19. """Unit tests for nested driver"""
  20. @mock.patch('kuryr.lib.binding.drivers.utils.remove_device')
  21. def test_port_unbind(self, mock_remove_device):
  22. fake_docker_endpoint_id = utils.get_hash()
  23. fake_docker_network_id = utils.get_hash()
  24. fake_port_id = uuidutils.generate_uuid()
  25. fake_neutron_v4_subnet_id = uuidutils.generate_uuid()
  26. fake_neutron_v6_subnet_id = uuidutils.generate_uuid()
  27. fake_vif_details = {"port_filter": True, "ovs_hybrid_plug": False}
  28. fake_vif_type = "ovs"
  29. fake_port = self._get_fake_port(
  30. fake_docker_endpoint_id, fake_docker_network_id,
  31. fake_port_id, constants.PORT_STATUS_ACTIVE,
  32. fake_neutron_v4_subnet_id, fake_neutron_v6_subnet_id,
  33. vif_details=fake_vif_details, vif_type=fake_vif_type)
  34. nested.port_unbind(fake_docker_endpoint_id, fake_port['port'])
  35. mock_remove_device.assert_called_once()