Exemplo n.º 1
0
 def _mock_out_unbinding(self, endpoint_id, neutron_port):
     self.mox.StubOutWithMock(binding, 'port_unbind')
     fake_unbinding_response = ('fake stdout', '')
     binding.port_unbind(endpoint_id, neutron_port).AndReturn(
         fake_unbinding_response)
     self.mox.ReplayAll()
     return fake_unbinding_response
Exemplo n.º 2
0
    def _port_unbind_with_exception(self, docker_endpoint_id,
                                    neutron_port, ex):
        fake_unbinding_response = ('fake stdout', '')
        self.mox.StubOutWithMock(binding, 'port_unbind')
        if ex:
            binding.port_unbind(docker_endpoint_id, neutron_port).AndRaise(ex)
        else:
            binding.port_unbind(docker_endpoint_id, neutron_port).AndReturn(
                fake_unbinding_response)
        self.mox.ReplayAll()

        return fake_unbinding_response
Exemplo n.º 3
0
 def test_port_unbind(self, mock_execute, mock_remove_device):
     fake_docker_network_id = utils.get_hash()
     fake_docker_endpoint_id = utils.get_hash()
     fake_port_id = uuidutils.generate_uuid()
     fake_neutron_v4_subnet_id = uuidutils.generate_uuid()
     fake_neutron_v6_subnet_id = uuidutils.generate_uuid()
     fake_port = self._get_fake_port(
         fake_docker_endpoint_id, fake_docker_network_id,
         fake_port_id, constants.PORT_STATUS_ACTIVE,
         fake_neutron_v4_subnet_id, fake_neutron_v6_subnet_id)
     binding.port_unbind(fake_docker_endpoint_id, fake_port['port'])
     mock_execute.assert_called_once()
     mock_remove_device.assert_called_once()
Exemplo n.º 4
0
 def test_port_unbind(self, mock_execute, mock_cleanup_veth):
     fake_docker_network_id = utils.get_hash()
     fake_docker_endpoint_id = utils.get_hash()
     fake_port_id = str(uuid.uuid4())
     fake_neutron_v4_subnet_id = str(uuid.uuid4())
     fake_neutron_v6_subnet_id = str(uuid.uuid4())
     fake_port = self._get_fake_port(
         fake_docker_endpoint_id, fake_docker_network_id,
         fake_port_id, constants.PORT_STATUS_ACTIVE,
         fake_neutron_v4_subnet_id, fake_neutron_v6_subnet_id)
     binding.port_unbind(fake_docker_endpoint_id, fake_port['port'])
     mock_execute.assert_called_once()
     mock_cleanup_veth.assert_called_once()
Exemplo n.º 5
0
 def test_port_unbind(self, mock_execute, mock_remove_device):
     fake_docker_network_id = utils.get_hash()
     fake_docker_endpoint_id = utils.get_hash()
     fake_port_id = str(uuid.uuid4())
     fake_neutron_v4_subnet_id = str(uuid.uuid4())
     fake_neutron_v6_subnet_id = str(uuid.uuid4())
     fake_port = self._get_fake_port(fake_docker_endpoint_id,
                                     fake_docker_network_id, fake_port_id,
                                     constants.PORT_STATUS_ACTIVE,
                                     fake_neutron_v4_subnet_id,
                                     fake_neutron_v6_subnet_id)
     binding.port_unbind(fake_docker_endpoint_id, fake_port['port'])
     mock_execute.assert_called_once()
     mock_remove_device.assert_called_once()
Exemplo n.º 6
0
    def delete_host_iface(self, endpoint_id, neutron_port):
        """Deletes a host interface after unbinding it from the host.

        The host Slave interface associated to the Neutron port will be deleted
        by delegating to the selected kuryr-lib driver.
        This driver will also remove the IP and MAC address pairs of the
        Endpoint to the allowed_address_pairs list of the Neutron port
        associated to the underlying host interface.

        :param endpoint_id:  the ID of the endpoint as string
        :param neutron_port: a port dictionary returned from
                             python-neutronclient
        :returns: the tuple of stdout and stderr returned
                  by processutils.execute invoked with the executable script
                  for unbinding
        :raises: exceptions.VethDeletionFailure,
                 exceptions.KuryrException,
                 n_exceptions.NeutronClientException,
                 processutils.ProcessExecutionError,
        """
        vm_port = self._get_port_from_host_iface(self.link_iface)
        container_ips = neutron_port['fixed_ips']

        self._remove_from_allowed_address_pairs(vm_port, container_ips)
        return binding.port_unbind(endpoint_id, neutron_port)
Exemplo n.º 7
0
    def delete_host_iface(self, endpoint_id, neutron_port):
        """Deletes a host interface after unbinding it from the host.

        The host Slave interface associated to the Neutron port will be deleted
        by delegating to the selected kuryr-lib driver.
        This driver will also remove the IP and MAC address pairs of the
        Endpoint to the allowed_address_pairs list of the Neutron port
        associated to the underlying host interface.

        :param endpoint_id:  the ID of the endpoint as string
        :param neutron_port: a port dictionary returned from
                             python-neutronclient
        :returns: the tuple of stdout and stderr returned
                  by processutils.execute invoked with the executable script
                  for unbinding
        :raises: exceptions.VethDeletionFailure,
                 exceptions.KuryrException,
                 n_exceptions.NeutronClientException,
                 processutils.ProcessExecutionError,
        """
        vm_port = self._get_port_from_host_iface(self.link_iface)
        container_ips = neutron_port['fixed_ips']

        self._remove_from_allowed_address_pairs(vm_port, container_ips)
        return binding.port_unbind(endpoint_id, neutron_port)
Exemplo n.º 8
0
    def delete_host_iface(self, endpoint_id, neutron_port):
        """Deletes a host interface after unbinding it from the host.

        The host Slave interface associated to the Neutron port will be deleted
        by delegating to the selected kuryr-lib driver.
        This driver will also remove the subport attached to the trunk port
        and will release its segmentation id

        :param endpoint_id:  the ID of the endpoint as string
        :param neutron_port: a port dictionary returned from
                             python-neutronclient
        :returns: the tuple of stdout and stderr returned
                  by processutils.execute invoked with the executable script
                  for unbinding
        :raises: exceptions.VethDeletionFailure,
                 exceptions.KuryrException,
                 n_exceptions.NeutronClientException,
                 processutils.ProcessExecutionError,
        """
        vm_port = self._get_port_from_host_iface(self.link_iface)

        stdout, stderr = binding.port_unbind(endpoint_id, neutron_port)

        subports = [{'port_id': neutron_port['id']}]
        try:
            app.neutron.trunk_remove_subports(
                vm_port['trunk_details']['trunk_id'],
                {'sub_ports': subports})
        except n_exceptions.NeutronClientException as ex:
            LOG.error("Error happened during subport deletion "
                      "%(port_id)s: %(ex)s",
                      {'port_id': neutron_port['id'], 'ex': ex})
            raise
        self._release_segmentation_id(neutron_port['id'])
        return stdout, stderr
Exemplo n.º 9
0
    def delete_host_iface(self, endpoint_id, neutron_port):
        """Deletes a host interface after unbinding it from the host.

        The host veth interface associated to the Neutron port will be unbound
        from its vitual bridge and deleted by delegating to the selected
        kuryr-lib driver.

        :param endpoint_id:  the ID of the endpoint as string
        :param neutron_port: a port dictionary returned from
               python-neutronclient
        :returns: the tuple of stdout and stderr returned by
                  processutils.execute invoked with the executable script for
                  unbinding
        :raises: kuryr.lib.exceptions.VethDeletionFailure,
                 processutils.ProcessExecutionError
        """
        return binding.port_unbind(endpoint_id, neutron_port)
Exemplo n.º 10
0
    def delete_host_iface(self, endpoint_id, neutron_port):
        """Deletes a host interface after unbinding it from the host.

        The host veth interface associated to the Neutron port will be unbound
        from its vitual bridge and deleted by delegating to the selected
        kuryr-lib driver.

        :param endpoint_id:  the ID of the endpoint as string
        :param neutron_port: a port dictionary returned from
               python-neutronclient
        :returns: the tuple of stdout and stderr returned by
                  processutils.execute invoked with the executable script for
                  unbinding
        :raises: kuryr.lib.exceptions.VethDeletionFailure,
                 processutils.ProcessExecutionError
        """
        return binding.port_unbind(endpoint_id, neutron_port)
Exemplo n.º 11
0
    def delete_host_iface(self, endpoint_id, neutron_port):
        """Deletes a host interface after unbinding it from the host.

        The host veth interface associated to the Neutron port will be unbound
        from its vitual bridge and deleted by delegating to the selected
        kuryr-lib driver.

        :param endpoint_id:  the ID of the Docker container as string
        :param neutron_port: a port dictionary returned from
               python-neutronclient
        :returns: the tuple of stdout and stderr returned by
                  processutils.execute invoked with the executable script for
                  unbinding
        :raises: processutils.ProcessExecutionError
        """
        binding_driver = 'kuryr.lib.binding.drivers.hw_veb'
        pci_addr = neutron_port[const.BINDING_PROFILE]['pci_slot']
        pf_ifname = get_ifname_by_pci_address(pci_addr,
                                              pf_interface=True)
        vf_num = get_vf_num_by_pci_address(pci_addr)
        return binding.port_unbind(endpoint_id, neutron_port,
                                   pf_ifname=pf_ifname,
                                   vf_num=vf_num, driver=binding_driver)