a skeleton that compiles
authorAndy Grover <andy@groveronline.com>
Sun, 11 Mar 2012 00:51:49 +0000 (16:51 -0800)
committerAndy Grover <andy@groveronline.com>
Sun, 11 Mar 2012 00:51:49 +0000 (16:51 -0800)
Signed-off-by: Andy Grover <andy@groveronline.com>
libkmod.c

index 8039afe7319797e04b2a175485dad0614be077f9..0d16c76dc38004be74f35afa001db5789b6987bb 100644 (file)
--- a/libkmod.c
+++ b/libkmod.c
@@ -61,160 +61,9 @@ libkmod_dealloc(kmodobject *self)
 }
 
 static PyObject *
-liblvm_library_get_version(lvmobject *self)
+libkmod_library_get_version(kmodobject *self)
 {
-    return Py_BuildValue("s", lvm_library_get_version());
-}
-
-
-static PyObject *
-liblvm_close(lvmobject *self)
-{
-    /* if already closed, don't reclose it */
-    if (self->libh != NULL)
-        lvm_quit(self->libh);
-
-    self->libh = NULL;
-    Py_INCREF(Py_None);
-    return Py_None;
-}
-
-static PyObject *
-liblvm_lvm_list_vg_names(lvmobject *self)
-{
-    struct dm_list *vgnames;
-    const char *vgname;
-    struct lvm_str_list *strl;
-    PyObject * rv;
-    int i = 0;
-
-    if ((vgnames = lvm_list_vg_names(self->libh))== NULL)
-       goto error;
-
-    if (dm_list_empty(vgnames))
-       goto error;
-
-    rv = PyTuple_New(dm_list_size(vgnames));
-    if (rv == NULL)
-        return NULL;
-
-    dm_list_iterate_items(strl, vgnames) {
-       vgname = strl->str;
-        PyTuple_SET_ITEM(rv, i, PyString_FromString(vgname));
-        i++;
-    }
-
-    return rv;
-
-error:
-       PyErr_SetObject(LibLVMError,liblvm_get_last_error(self));
-       return NULL;
-}
-
-static PyObject *
-liblvm_lvm_list_vg_uuids(lvmobject *self)
-{
-    struct dm_list *uuids;
-    const char *uuid;
-    struct lvm_str_list *strl;
-    PyObject * rv;
-    int i = 0;
-
-    if ((uuids = lvm_list_vg_uuids(self->libh))== NULL)
-       goto error;
-
-    if (dm_list_empty(uuids))
-        goto error;
-
-    rv = PyTuple_New(dm_list_size(uuids));
-    if (rv == NULL)
-        return NULL;
-    dm_list_iterate_items(strl, uuids) {
-       uuid = strl->str;
-        PyTuple_SET_ITEM(rv, i, PyString_FromString(uuid));
-        i++;
-    }
-
-    return rv;
-
-error:
-    PyErr_SetObject(LibLVMError,liblvm_get_last_error(self));
-       return NULL;
-}
-
-static PyObject *
-liblvm_lvm_vgname_from_pvid(lvmobject *self, PyObject *arg)
-{
-    const char *pvid;
-    const char *vgname;
-    if (!PyArg_ParseTuple(arg, "s", &pvid))
-        return NULL;
-
-    if((vgname = lvm_vgname_from_pvid(self->libh, pvid)) == NULL) {
-       PyErr_SetObject(LibLVMError,liblvm_get_last_error(self));
-        return NULL;
-    }
-
-    return Py_BuildValue("s", vgname);
-}
-
-static PyObject *
-liblvm_lvm_vgname_from_device(lvmobject *self, PyObject *arg)
-{
-    const char *device;
-    const char *vgname;
-    if (!PyArg_ParseTuple(arg, "s", &device))
-        return NULL;
-
-    if((vgname = lvm_vgname_from_device(self->libh, device)) == NULL) {
-       PyErr_SetObject(LibLVMError,liblvm_get_last_error(self));
-        return NULL;
-    }
-
-    return Py_BuildValue("s", vgname);
-}
-
-static PyObject *
-liblvm_lvm_config_reload(lvmobject *self)
-{
-       int rval;
-
-    if((rval = lvm_config_reload(self->libh)) == -1) {
-       PyErr_SetObject(LibLVMError,liblvm_get_last_error(self));
-       return NULL;
-    }
-
-    return Py_BuildValue("i", rval);
-}
-
-
-static PyObject *
-liblvm_lvm_scan(lvmobject *self)
-{
-       int rval;
-
-    if((rval = lvm_scan(self->libh)) == -1) {
-       PyErr_SetObject(LibLVMError,liblvm_get_last_error(self));
-       return NULL;
-    }
-
-    return Py_BuildValue("i", rval);
-}
-
-static PyObject *
-liblvm_lvm_config_override(lvmobject *self, PyObject *arg)
-{
-    const char *config;
-    int rval;
-
-    if (!PyArg_ParseTuple(arg, "s", &config))
-       return NULL;
-
-    if ((rval = lvm_config_override(self->libh, config)) == -1) {
-       PyErr_SetObject(LibLVMError,liblvm_get_last_error(self));
-        return NULL;
-    }
-    return Py_BuildValue("i", rval);
+    return Py_BuildValue("s", "whatup dude v1.234");
 }
 
 /* ----------------------------------------------------------------------
@@ -223,39 +72,10 @@ liblvm_lvm_config_override(lvmobject *self, PyObject *arg)
 
 static PyMethodDef Libkmod_methods[] = {
     /* LVM methods */
-    { "getVersion",          (PyCFunction)liblvm_library_get_version, METH_NOARGS },
-    { "vgOpen",                (PyCFunction)liblvm_lvm_vg_open, METH_VARARGS },
-    { "vgCreate",                (PyCFunction)liblvm_lvm_vg_create, METH_VARARGS },
-    { "close",                  (PyCFunction)liblvm_close, METH_NOARGS },
-    { "configReload",          (PyCFunction)liblvm_lvm_config_reload, METH_NOARGS },
-    { "configOverride",        (PyCFunction)liblvm_lvm_config_override, METH_VARARGS },
-    { "scan",                   (PyCFunction)liblvm_lvm_scan, METH_NOARGS },
-    { "listVgNames",          (PyCFunction)liblvm_lvm_list_vg_names, METH_NOARGS },
-    { "listVgUuids",          (PyCFunction)liblvm_lvm_list_vg_uuids, METH_NOARGS },
-    { "vgNameFromPvid",        (PyCFunction)liblvm_lvm_vgname_from_pvid, METH_VARARGS },
-    { "vgNameFromDevice",        (PyCFunction)liblvm_lvm_vgname_from_device, METH_VARARGS },
-
+    { "getVersion",          (PyCFunction)libkmod_library_get_version, METH_NOARGS },
     { NULL,             NULL}           /* sentinel */
 };
 
-static PyObject *
-liblvm_vg_getattr(vgobject *self, char *name)
-{
-    return Py_FindMethod(liblvm_vg_methods, (PyObject *)self, name);
-}
-
-static PyObject *
-liblvm_lv_getattr(vgobject *self, char *name)
-{
-    return Py_FindMethod(liblvm_lv_methods, (PyObject *)self, name);
-}
-
-static PyObject *
-liblvm_pv_getattr(vgobject *self, char *name)
-{
-    return Py_FindMethod(liblvm_pv_methods, (PyObject *)self, name);
-}
-
 static PyTypeObject LibKmodType = {
     PyObject_HEAD_INIT(NULL)
     0,                         /*ob_size*/