Metadata-Version: 2.0
Name: nsenter
Version: 0.2
Summary: Enter kernel namespaces from Python
Home-page: https://github.com/zalando/python-nsenter
Author: Henning Jacobs
Author-email: henning.jacobs@zalando.de
License: Apache License 2.0
Keywords: docker container namespace kernel setns
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Operating System :: POSIX :: Linux
Classifier: License :: OSI Approved :: Apache Software License
Requires-Dist: argparse
Requires-Dist: contextlib2
Requires-Dist: pathlib

=======
NSEnter
=======

.. image:: https://travis-ci.org/zalando/python-nsenter.svg?branch=master
   :target: https://travis-ci.org/zalando/python-nsenter
   :alt: Travis CI build status

This Python package allows entering Linux kernel namespaces (mount, IPC, net, PID, user and UTS) by doing the "setns" syscall.
The command line interface tries to be similar to the nsenter_ C program.

Requires Python 2.6 or higher

See the introductory `blog post "Entering Kernel Namespaces from Python"`_.

Install from PyPI::

    sudo pip3 install nsenter

Install from git source::

    python3 setup.py install

Example command line usage::

    docker run -d --name=redis -t redis
    sudo nsenter --all --target=`docker inspect --format '{{ .State.Pid }}' redis` /bin/bash


Example usage from Python:

.. code:: python

    import subprocess
    from nsenter import Namespace

    with Namespace(mypid, 'net'):
        # output network interfaces as seen from within the mypid's net NS:
        subprocess.check_output(['ip', 'a'])

    # or enter an arbitrary namespace:
    with Namespace('/var/run/netns/foo', 'net'):
        # output network interfaces as seen from within the net NS "foo":
        subprocess.check_output(['ip', 'a'])

.. _nsenter: http://man7.org/linux/man-pages/man1/nsenter.1.html
.. _blog post "Entering Kernel Namespaces from Python": http://tech.zalando.com/posts/entering-kernel-namespaces-with-python.html


