Re: [PATCH] Add documentation to the dm and dmraid pythong bindings. As well as to the

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Joel Granados Moreno wrote:
---
 __init__.py |   12 ++++++++++++
 dm.c        |   33 +++++++++++++++++++++++++++------
 dmraid.c    |   33 +++++++++++++++++++++++++++------
 3 files changed, 66 insertions(+), 12 deletions(-)


Looks good to me now,

Regards,

Hans


diff --git a/__init__.py b/__init__.py
index 943e127..fa3b3d7 100644
--- a/__init__.py
+++ b/__init__.py
@@ -63,6 +63,10 @@ def load(name):
def getDevice(name):
+    """Retrieve a major and minor number for a specific path/name.
+
+    The last word after the '/' in name is used to search for the device.
+    """
     name = name.split('/')[-1]
     maps = dm.maps()
     for map in maps:
@@ -70,6 +74,10 @@ def getDevice(name):
             return (map.dev.major, map.dev.minor)
def getMPaths(disks, logger=None):
+    """Retrieve all the Multi path devices in the system.
+
+    Returns a list of Multi path  objects.
+    """
     old = disks
     disks = []
     for disk in old:
@@ -157,6 +165,10 @@ def getMPaths(disks, logger=None):
     return mpList
def getRaidSets(*disks):
+    """Retrieve all the raid sets in the system.
+
+    Returns a list of RaidSet objects.
+    """
     # make it so you don't have to apply() to pass a list
     old = disks
     disks = []
diff --git a/dm.c b/dm.c
index 2aa3a50..beb15ae 100644
--- a/dm.c
+++ b/dm.c
@@ -378,7 +378,8 @@ static struct PyGetSetDef pydm_dev_getseters[] = {
 };
static struct PyMethodDef pydm_dev_methods[] = {
-	{"mknod", (PyCFunction) pydm_dev_mknod, PYDM_ARGS},
+	{"mknod", (PyCFunction) pydm_dev_mknod, PYDM_ARGS,
+		"Create the node for the current device"},
 	{NULL}
 };
@@ -396,6 +397,8 @@ PyTypeObject PydmDevice_Type = {
 	.tp_init = pydm_dev_init_method,
 	.tp_str = pydm_dev_str_method,
 	.tp_new = PyType_GenericNew,
+	.tp_doc =	"The device mapper device.  "
+			"Contains device file information.",
 };
PyObject *
@@ -614,6 +617,7 @@ PyTypeObject PydmTable_Type = {
 	.tp_str = pydm_table_str_method,
 	.tp_new = PyType_GenericNew,
 	.tp_compare = (cmpfunc)pydm_table_compare,
+	.tp_doc = "The device mapper device table",
 };
PyObject *
@@ -1359,6 +1363,8 @@ PyTypeObject PydmMap_Type = {
 #endif
 	.tp_init = pydm_map_init_method,
 	.tp_new = PyType_GenericNew,
+	.tp_doc =	"The device mapper device map.  "
+			"Has most of the related metadata.",
 };
/* map stuff end */
@@ -1441,6 +1447,7 @@ PyTypeObject PydmTarget_Type = {
 		    Py_TPFLAGS_BASETYPE,
 	.tp_str = pydm_target_str_method,
 	.tp_new = PyType_GenericNew,
+	.tp_doc = "The device mapper type",
 };
 /* target stuff end */
@@ -1698,11 +1705,25 @@ out:
 }
static PyMethodDef pydm_functions[] = {
-	{"scanparts", (PyCFunction)pydm_scan_parts, PYDM_ARGS},
-	{"rmpart", (PyCFunction)pydm_rmpart, PYDM_ARGS},
-	{"set_logger", (PyCFunction)pydm_log_init, PYDM_ARGS},
-	{"maps", (PyCFunction)pydm_maps, METH_NOARGS},
-	{"targets", (PyCFunction)pydm_targets, METH_NOARGS},
+	{"scanparts", (PyCFunction)pydm_scan_parts, PYDM_ARGS,
+		"Rescans the partition talbe for the specified device.  "
+		"Expects a string representing the device with the keyword "
+		"dev_path. returns None on success and NULL on failure."},
+	{"rmpart", (PyCFunction)pydm_rmpart, PYDM_ARGS,
+		"Deletes a partition from the specified device.  "
+		"Expects a string representing the device with the keyword "
+		"dev_path and an long representing the partition number "
+		"with the keyword partno.  Returns None on success and NULL "
+		"on failure."},
+	{"set_logger", (PyCFunction)pydm_log_init, PYDM_ARGS,
+		"Defines the log function to be used.  Expects a callable "
+		"object.  Will return None on success and NULL on failure. "},
+	{"maps", (PyCFunction)pydm_maps, METH_NOARGS,
+		"Scans the system for mapped devices.  It does not expect any "
+		"arguments.  It returns a list of map objects."},
+	{"targets", (PyCFunction)pydm_targets, METH_NOARGS,
+		"Scans for suppoerted targets.  It does not expect any args.  "
+		"It returns a list of target objects."},
 	{NULL, NULL}
 };
diff --git a/dmraid.c b/dmraid.c
index e693512..20310c7 100644
--- a/dmraid.c
+++ b/dmraid.c
@@ -265,10 +265,12 @@ pydmraid_dev_scanparts(PyObject *self, PyObject *args, PyObject *kwds)
 static struct PyMethodDef pydmraid_dev_methods[] = {
 	{"rmpart",
 		(PyCFunction)pydmraid_dev_rmpart,
-		METH_VARARGS | METH_KEYWORDS},
+		METH_VARARGS | METH_KEYWORDS,
+		"Removes the partition defined by the partno argument"},
 	{"scanparts",
 		(PyCFunction)pydmraid_dev_scanparts,
-		METH_NOARGS},
+		METH_NOARGS,
+		"(Re)scans all partitions for the current device"},
 	{NULL},
 };
@@ -284,6 +286,7 @@ PyTypeObject PydmraidDevice_Type = {
 	.tp_str = pydmraid_dev_str_method,
 	.tp_methods = pydmraid_dev_methods,
 	.tp_new = PyType_GenericNew,
+	.tp_doc = "The system device",
 };
PyObject *
@@ -457,6 +460,7 @@ PyTypeObject PydmraidRaidDev_Type = {
 	.tp_str = pydmraid_raiddev_str_method,
 	.tp_repr = pydmraid_raiddev_repr_method,
 	.tp_new = PyType_GenericNew,
+	.tp_doc = "The raid device.  These are devices that contain raid sets.",
 };
PyObject *
@@ -986,6 +990,7 @@ PyTypeObject PydmraidRaidSet_Type = {
 	.tp_str = pydmraid_raidset_str_method,
 	.tp_repr = pydmraid_raidset_repr_method,
 	.tp_new = PyType_GenericNew,
+	.tp_doc = "The raid set.  Metadata for dmraid devices.",
 };
PyObject *
@@ -1309,16 +1314,30 @@ out:
 static struct PyMethodDef pydmraid_ctx_methods[] = {
 	{"discover_disks",
 		(PyCFunction)pydmraid_ctx_discover_disks,
-		METH_VARARGS | METH_KEYWORDS},
+		METH_VARARGS | METH_KEYWORDS,
+		"Discover all disks in the system. Expects a list of "
+		"filesystem nodes where the disks should be searched.  "
+		"It will search in sysfs if no list is given.  Returns "
+		"number of disks found."},
 	{"discover_raiddevs",
 		(PyCFunction)pydmraid_ctx_discover_raiddevs,
-		METH_VARARGS | METH_KEYWORDS},
+		METH_VARARGS | METH_KEYWORDS,
+		"Identifies which disks are part of a raid set. Expects a "
+		"list of devices and returns the number of raid devices "
+		"found.  It will search all devices if no list is provided."},
 	{"discover_raidsets",
 		(PyCFunction)pydmraid_ctx_discover_raidsets,
-		METH_NOARGS},
+		METH_NOARGS,
+		"Discovers the raid sets in the system"},
 	{"get_raidsets",
 		(PyCFunction)pydmraid_ctx_get_raidsets,
-		METH_VARARGS | METH_KEYWORDS},
+		METH_VARARGS | METH_KEYWORDS,
+		"Returns a list of raid sets in the system.  This "
+		"function identifies all the disks in the system, identifies "
+		"what disks are part of raid sets and identifies these raid "
+		"sets.  It expects a list of devices and/or nodes where to "
+		"search for disks and raid devs.  If not list is provided all "
+		"the raidsets in the system are returned."},
 	{NULL},
 };
@@ -1333,6 +1352,8 @@ PyTypeObject PydmraidContext_Type = {
 	.tp_init = pydmraid_ctx_init_method,
 	.tp_methods = pydmraid_ctx_methods,
 	.tp_new = PyType_GenericNew,
+	.tp_doc =	"The dmraid context.  Is needed for all the dmraid "
+			"actions. It mainly contains the dmraid lib context.",
 };
static int

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux