Use the check_backend_available function.
Eliminates the spurrious syslog messages and is a cleaner mechanism for querying all of the available backends on a system.
This commit is contained in:
parent
f44df21404
commit
4f278195a4
@ -26,6 +26,7 @@ from .enum import Enum
|
||||
from .enum import unique
|
||||
from .utils import create_instance
|
||||
from .utils import positive_int_value
|
||||
from pyeclib_c import check_backend_available
|
||||
|
||||
|
||||
def PyECLibVersion(z, y, x):
|
||||
@ -476,18 +477,14 @@ ALL_EC_TYPES = [
|
||||
def _PyECLibValidECTypes():
|
||||
available_ec_types = []
|
||||
for _type in ALL_EC_TYPES:
|
||||
driver = None
|
||||
try:
|
||||
if _type is 'shss':
|
||||
_m = 4
|
||||
if _type.startswith('flat_xor_hd'):
|
||||
int_type = PyECLib_EC_Types.get_by_name('flat_xor_hd')
|
||||
else:
|
||||
_m = 5
|
||||
driver = ECDriver(k=10, m=_m, ec_type=_type, validate=True)
|
||||
if driver:
|
||||
available_ec_types.append(_type)
|
||||
except:
|
||||
# ignore any errors, assume backend not available
|
||||
int_type = PyECLib_EC_Types.get_by_name(_type)
|
||||
if not int_type:
|
||||
continue
|
||||
if check_backend_available(int_type.value):
|
||||
available_ec_types.append(_type)
|
||||
return available_ec_types
|
||||
|
||||
|
||||
|
@ -1172,6 +1172,22 @@ exit:
|
||||
return ret_obj;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
pyeclib_c_check_backend_available(PyObject *self, PyObject *args)
|
||||
{
|
||||
const ec_backend_id_t backend_id;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &backend_id)) {
|
||||
pyeclib_c_seterr(-EINVALIDPARAMS, "pyeclib_c_check_backend_available ERROR: ");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (liberasurecode_backend_available(backend_id)) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static PyMethodDef PyECLibMethods[] = {
|
||||
{"init", pyeclib_c_init, METH_VARARGS, "Initialize a new erasure encoder/decoder"},
|
||||
@ -1182,6 +1198,7 @@ static PyMethodDef PyECLibMethods[] = {
|
||||
{"get_segment_info", pyeclib_c_get_segment_info, METH_VARARGS, "Return segment and fragment size information needed when encoding a segmented stream"},
|
||||
{"get_metadata", pyeclib_c_get_metadata, METH_VARARGS, "Get the integrity checking metadata for a fragment"},
|
||||
{"check_metadata", pyeclib_c_check_metadata, METH_VARARGS, "Check the integrity checking metadata for a set of fragments"},
|
||||
{"check_backend_available", pyeclib_c_check_backend_available, METH_VARARGS, "Check if a backend is available"},
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user