python: Don't hardcode LXCPATH in python module

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
Stéphane Graber 2013-03-11 11:57:50 -04:00
parent 0d03360a77
commit 24fcdb395f
4 changed files with 14 additions and 5 deletions

1
.gitignore vendored
View File

@ -66,7 +66,6 @@ src/lxc/lxc-wait
src/lxc/legacy/lxc-ls
src/python-lxc/build/
src/python-lxc/lxc/__init__.py
src/python-lxc/lxc/__pycache__/
src/tests/lxc-test-containertests

View File

@ -383,7 +383,6 @@ AC_CONFIG_FILES([
src/lxc/lxc.functions
src/python-lxc/Makefile
src/python-lxc/lxc/__init__.py
src/lua-lxc/Makefile

View File

@ -95,6 +95,12 @@ Container_init(Container *self, PyObject *args, PyObject *kwds)
return 0;
}
static PyObject *
get_default_config_path(Container *self, PyObject *args, PyObject *kwds)
{
return PyUnicode_FromString(lxc_get_default_config_path());
}
// Container properties
static PyObject *
Container_config_file_name(Container *self, PyObject *args, PyObject *kwds)
@ -628,12 +634,18 @@ PyVarObject_HEAD_INIT(NULL, 0)
Container_new, /* tp_new */
};
static PyMethodDef LXC_methods[] = {
{"get_default_config_path", (PyCFunction)get_default_config_path, METH_NOARGS,
"Returns the current LXC config path"},
{NULL, NULL, 0, NULL}
};
static PyModuleDef _lxcmodule = {
PyModuleDef_HEAD_INIT,
"_lxc",
"Binding for liblxc in python",
-1,
NULL, NULL, NULL, NULL, NULL
LXC_methods
};
PyMODINIT_FUNC

View File

@ -26,14 +26,13 @@ import glob
import os
import subprocess
import stat
import tempfile
import time
import warnings
warnings.warn("The python-lxc API isn't yet stable "
"and may change at any point in the future.", Warning, 2)
default_config_path = "@LXCPATH@"
default_config_path = _lxc.get_default_config_path()
class ContainerNetwork():