summaryrefslogtreecommitdiffstats
path: root/vpp-api/python/vpp_papi
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2016-10-05 11:10:50 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2016-10-05 11:39:14 +0000
commitb8602b595fc89fe8b8fb00cef4820eedf225a93e (patch)
tree275111a5e3a1011b91939f5347a5aef0dae016b3 /vpp-api/python/vpp_papi
parentd4bc9af55fc9a7bb5133da8c863569497cb92cd0 (diff)
Python API: Add support for shared memory prefix
Recheck. This is to support multiple VPP instances on same host. Change-Id: Ibe511b1f790fc8771900085577423f7e71dc45df Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'vpp-api/python/vpp_papi')
-rw-r--r--vpp-api/python/vpp_papi/pneum_wrap.c8
-rw-r--r--vpp-api/python/vpp_papi/vpp_papi.py8
2 files changed, 10 insertions, 6 deletions
diff --git a/vpp-api/python/vpp_papi/pneum_wrap.c b/vpp-api/python/vpp_papi/pneum_wrap.c
index 7a511974..18c4f233 100644
--- a/vpp-api/python/vpp_papi/pneum_wrap.c
+++ b/vpp-api/python/vpp_papi/pneum_wrap.c
@@ -44,11 +44,11 @@ wrap_pneum_callback (char *data, int len)
static PyObject *
wrap_connect (PyObject *self, PyObject *args)
{
- char *name;
+ char * name, * chroot_prefix = NULL;
int rv;
- PyObject *temp;
+ PyObject * temp;
- if (!PyArg_ParseTuple(args, "sO:set_callback", &name, &temp))
+ if (!PyArg_ParseTuple(args, "sO|s:wrap_connect", &name, &temp, &chroot_prefix))
return (NULL);
if (!PyCallable_Check(temp)) {
@@ -61,7 +61,7 @@ wrap_connect (PyObject *self, PyObject *args)
pneum_callback = temp; /* Remember new callback */
Py_BEGIN_ALLOW_THREADS
- rv = pneum_connect(name);
+ rv = pneum_connect(name, chroot_prefix);
Py_END_ALLOW_THREADS
return PyLong_FromLong(rv);
}
diff --git a/vpp-api/python/vpp_papi/vpp_papi.py b/vpp-api/python/vpp_papi/vpp_papi.py
index 42ddcdc3..9c2d2b2b 100644
--- a/vpp-api/python/vpp_papi/vpp_papi.py
+++ b/vpp-api/python/vpp_papi/vpp_papi.py
@@ -86,12 +86,16 @@ def handler(signum, frame):
print('Signal handler called with signal', signum)
raise IOError("Couldn't connect to VPP!")
-def connect(name):
+def connect(name, chroot_prefix = None):
# Set the signal handler
signal.signal(signal.SIGALRM, handler)
signal.alarm(3) # 3 second
- rv = vpp_api.connect(name, msg_handler)
+ if not chroot_prefix:
+ rv = vpp_api.connect(name, msg_handler)
+ else:
+ rv = vpp_api.connect(name, msg_handler, chroot_prefix)
+
signal.alarm(0)
#