From 81efe277d14a9e06b65a1bb5065b7c8b9008d5b2 Mon Sep 17 00:00:00 2001 From: Amit Bawer Date: Aug 24 2020 15:41:06 +0000 Subject: python: Remove init_lockspace() deprecated API write_lockspace() is used to replace init_lockspace() functionality as far back as in commit: commit 3e17957 Author: Federico Simoncelli Date: Wed Apr 10 12:09:43 2013 -0400 python: use the write commands in example.py The init_lockspace/resource commands have been obsoleted, the new ones are write_lockspace/resource. The old API was kept to support legacy python2-sanlock consuming code. Now that python2 is officialy retired this API can be removed. Signed-off-by: Amit Bawer --- diff --git a/python/sanlock.c b/python/sanlock.c index 7c50aba..b0dfb57 100644 --- a/python/sanlock.c +++ b/python/sanlock.c @@ -420,53 +420,6 @@ convert_to_pybytes(PyObject* arg, void *addr) return 0; } -/* init_lockspace */ -PyDoc_STRVAR(pydoc_init_lockspace, "\ -init_lockspace(lockspace, path, offset=0, max_hosts=0, num_hosts=0, \ -use_aio=True)\n\ -*DEPRECATED* use write_lockspace instead.\n\ -Initialize a device to be used as sanlock lockspace."); - -static PyObject * -py_init_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds) -{ - int rv = -1, max_hosts = 0, num_hosts = 0, use_aio = 1; - PyObject *lockspace = NULL; - PyObject *path = NULL; - struct sanlk_lockspace ls = {0}; - - static char *kwlist[] = {"lockspace", "path", "offset", - "max_hosts", "num_hosts", "use_aio", NULL}; - - /* parse python tuple */ - if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&O&|kiii", kwlist, - convert_to_pybytes, &lockspace, pypath_converter, &path, &ls.host_id_disk.offset, - &max_hosts, &num_hosts, &use_aio)) { - goto finally; - } - - /* prepare sanlock names */ - strncpy(ls.name, PyBytes_AsString(lockspace), SANLK_NAME_LEN); - strncpy(ls.host_id_disk.path, PyBytes_AsString(path), SANLK_PATH_LEN - 1); - - /* init sanlock lockspace (gil disabled) */ - Py_BEGIN_ALLOW_THREADS - rv = sanlock_direct_init(&ls, NULL, max_hosts, num_hosts, use_aio); - Py_END_ALLOW_THREADS - - if (rv != 0) { - set_sanlock_error(rv, "Sanlock lockspace init failure"); - goto finally; - } - -finally: - Py_XDECREF(lockspace); - Py_XDECREF(path); - if (rv != 0) - return NULL; - Py_RETURN_NONE; -} - /* init_resource */ PyDoc_STRVAR(pydoc_init_resource, "\ init_resource(lockspace, resource, disks, max_hosts=0, num_hosts=0, \ @@ -1692,8 +1645,6 @@ static PyMethodDef sanlock_methods[] = { {"register", py_register, METH_NOARGS, pydoc_register}, {"get_alignment", py_get_alignment, METH_VARARGS, pydoc_get_alignment}, - {"init_lockspace", (PyCFunction) py_init_lockspace, - METH_VARARGS|METH_KEYWORDS, pydoc_init_lockspace}, {"init_resource", (PyCFunction) py_init_resource, METH_VARARGS|METH_KEYWORDS, pydoc_init_resource}, {"write_lockspace", (PyCFunction) py_write_lockspace, diff --git a/tests/python_test.py b/tests/python_test.py index 719bcb6..965bc06 100644 --- a/tests/python_test.py +++ b/tests/python_test.py @@ -691,15 +691,6 @@ def test_set_event_parse_args(no_sanlock_daemon, name): @pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES) @pytest.mark.parametrize("filename,encoding", FILE_NAMES) -def test_init_lockspace_parse_args( - no_sanlock_daemon, name, filename, encoding): - path = util.generate_path("/tmp/", filename, encoding) - with raises_sanlock_errno(errno.ENODEV): - sanlock.init_lockspace(name, path) - - -@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES) -@pytest.mark.parametrize("filename,encoding", FILE_NAMES) def test_init_resource_parse_args(no_sanlock_daemon, name, filename, encoding): path = util.generate_path("/tmp/", filename, encoding) disks = [(path, 0)]