On Tue, Apr 30, 2019 at 5:34 PM Vojtech Juranek <vjuranek@redhat.com> wrote:
Previous patch switched from accepting align and sector flags to values.
Exposing internal sanlock flags doesn't make sense now. Tuples with
supported sector size and alignment values should be exposed instead.
---
 python/sanlock.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/python/sanlock.c b/python/sanlock.c
index b57b51d..6319931 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1736,13 +1736,21 @@ initsanlock(void)
     PYSNLK_INIT_ADD_CONSTANT(SANLK_SETEV_REPLACE_EVENT,  "SETEV_REPLACE_EVENT");
     PYSNLK_INIT_ADD_CONSTANT(SANLK_SETEV_ALL_HOSTS,      "SETEV_ALL_HOSTS");

-    /* Sector and align size flags */
-    PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR512, "SECTOR512");
-    PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_SECTOR4K, "SECTOR4K");
-    PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN1M, "ALIGN1M");
-    PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN2M, "ALIGN2M");
-    PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN4M, "ALIGN4M");
-    PYSNLK_INIT_ADD_CONSTANT(SANLK_RES_ALIGN8M, "ALIGN8M");
-
 #undef PYSNLK_INIT_ADD_CONSTANT
+
+    /* Tuples with supported sector size and alignment values */
+    PyObject *sector = PyTuple_New(2);
+    PyTuple_SetItem(sector, 0, PyInt_FromLong(SECTOR512));
+    PyTuple_SetItem(sector, 1, PyInt_FromLong(SECTOR4K));
+    if (PyModule_AddObject(py_module, "SECTOR", sector))
+        Py_DECREF(sector);

Another issue I forgot to mention, maybe use sanlock.ALIGN_SIZE and
sanlock.SECTOR_SIZE for the tuples?

This makes it more clear that it is not related to SANLK_XXX_ALIGNXX 
and SANLK_XXX_SECTORXX flags.

 
+
+    PyObject *align = PyTuple_New(4);
+    PyTuple_SetItem(align, 0, PyInt_FromLong(ALIGN1M));
+    PyTuple_SetItem(align, 1, PyInt_FromLong(ALIGN2M));
+    PyTuple_SetItem(align, 2, PyInt_FromLong(ALIGN4M));
+    PyTuple_SetItem(align, 3, PyInt_FromLong(ALIGN8M));
+    if (PyModule_AddObject(py_module, "ALIGN", align))
+        Py_DECREF(align);
+
 }
--
2.20.1
_______________________________________________
sanlock-devel mailing list -- sanlock-devel@lists.fedorahosted.org
To unsubscribe send an email to sanlock-devel-leave@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/sanlock-devel@lists.fedorahosted.org