コード例 #1
0
ファイル: base.py プロジェクト: hahaps/kuryr
 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
コード例 #2
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
コード例 #3
0
ファイル: test_leave.py プロジェクト: OCP-China/kuryr
    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
コード例 #4
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
コード例 #5
0
ファイル: controllers.py プロジェクト: mohan08p/kuryr
def network_driver_leave():
    """Unbinds a Neutron Port to a network interface attached to a container.

    This function takes the following JSON data and delete the veth pair
    corresponding to the given info. ::

        {
            "NetworkID": string,
            "EndpointID": string
        }
    """
    json_data = flask.request.get_json(force=True)
    app.logger.debug(
        "Received JSON data {0} for /NetworkDriver.DeleteEndpoint".format(
            json_data))
    jsonschema.validate(json_data, schemata.LEAVE_SCHEMA)
    neutron_network_name = json_data['NetworkID']
    endpoint_id = json_data['EndpointID']

    filtered_networks = _get_networks_by_attrs(name=neutron_network_name)

    if not filtered_networks:
        return flask.jsonify({
            'Err':
            "Neutron network associated with ID {0} doesn't exit.".format(
                neutron_network_name)
        })
    else:
        neutron_port_name = utils.get_neutron_port_name(endpoint_id)
        filtered_ports = _get_ports_by_attrs(name=neutron_port_name)
        if not filtered_ports:
            raise exceptions.NoResourceException(
                "The port doesn't exist for the name {0}".format(
                    neutron_port_name))
        neutron_port = filtered_ports[0]
        try:
            stdout, stderr = binding.port_unbind(endpoint_id, neutron_port)
            app.logger.debug(stdout)
            if stderr:
                app.logger.error(stderr)
        except processutils.ProcessExecutionError:
            with excutils.save_and_reraise_exception():
                app.logger.error(
                    'Could not unbind the Neutron port from the veth '
                    'endpoint.')
        except exceptions.VethDeletionFailure:
            with excutils.save_and_reraise_exception():
                app.logger.error('Cleaning the veth pair up was failed.')

    return flask.jsonify(constants.SCHEMA['SUCCESS'])
コード例 #6
0
ファイル: controllers.py プロジェクト: zbx/kuryr
def network_driver_leave():
    """Unbinds a Neutron Port to a network interface attached to a container.

    This function takes the following JSON data and delete the veth pair
    corresponding to the given info. ::

        {
            "NetworkID": string,
            "EndpointID": string
        }
    """
    json_data = flask.request.get_json(force=True)
    app.logger.debug("Received JSON data {0} for"
                     " /NetworkDriver.DeleteEndpoint"
                     .format(json_data))
    jsonschema.validate(json_data, schemata.LEAVE_SCHEMA)

    neutron_network_identifier = _make_net_identifier(json_data['NetworkID'],
                                                      tags=app.tag)
    endpoint_id = json_data['EndpointID']
    filtered_networks = _get_networks_by_identifier(neutron_network_identifier)

    if not filtered_networks:
        return flask.jsonify({
            'Err': "Neutron net associated with identifier {0} doesn't exit."
            .format(neutron_network_identifier)
        })
    else:
        neutron_port_name = utils.get_neutron_port_name(endpoint_id)
        filtered_ports = _get_ports_by_attrs(name=neutron_port_name)
        if not filtered_ports:
            raise exceptions.NoResourceException(
                "The port doesn't exist for the name {0}"
                .format(neutron_port_name))
        neutron_port = filtered_ports[0]
        try:
            stdout, stderr = binding.port_unbind(endpoint_id, neutron_port)
            app.logger.debug(stdout)
            if stderr:
                app.logger.error(stderr)
        except processutils.ProcessExecutionError:
            with excutils.save_and_reraise_exception():
                app.logger.error(_LE(
                    'Could not unbind the Neutron port from the veth '
                    'endpoint.'))
        except exceptions.VethDeletionFailure:
            with excutils.save_and_reraise_exception():
                app.logger.error(_LE('Cleaning the veth pair up was failed.'))

    return flask.jsonify(const.SCHEMA['SUCCESS'])