return PyFloat_FromDouble(rate);
}
+static PyObject *osdmap_build_simple(PyObject *cls, PyObject *args, PyObject *kwargs)
+{
+ static const char *kwlist[] = {"epoch", "uuid", "num_osd", nullptr};
+ int epoch = 1;
+ char* uuid_str = nullptr;
+ int num_osd = -1;
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "izi",
+ const_cast<char**>(kwlist),
+ &epoch, &uuid_str, &num_osd)) {
+ Py_RETURN_NONE;
+ }
+ uuid_d uuid;
+ if (uuid_str) {
+ if (!uuid.parse(uuid_str)) {
+ PyErr_Format(PyExc_ValueError, "bad uuid %s", uuid_str);
+ Py_RETURN_NONE;
+ }
+ } else {
+ uuid.generate_random();
+ }
+
+ auto osdmap = without_gil([&] {
+ OSDMap* osdmap = new OSDMap();
+ // negative osd is allowed, in that case i just count all osds in ceph.conf
+ osdmap->build_simple(g_ceph_context, epoch, uuid, num_osd);
+ return osdmap;
+ });
+ return construct_with_capsule("mgr_module", "OSDMap", reinterpret_cast<void*>(osdmap));
+}
PyMethodDef BasePyOSDMap_methods[] = {
{"_get_epoch", (PyCFunction)osdmap_get_epoch, METH_NOARGS, "Get OSDMap epoch"},
"Calculate up+acting OSDs for a PG ID"},
{"_pool_raw_used_rate", (PyCFunction)osdmap_pool_raw_used_rate, METH_VARARGS,
"Get raw space to logical space ratio"},
+ {"_build_simple", (PyCFunction)osdmap_build_simple, METH_VARARGS | METH_CLASS,
+ "Create a simple OSDMap"},
{NULL, NULL, 0, NULL}
};
def _map_pool_pgs_up(self, poolid):...
def _pg_to_up_acting_osds(self, pool_id, ps):...
def _pool_raw_used_rate(self, pool_id):...
+ @classmethod
+ def _build_simple(cls, epoch: int, uuid: Optional[str], num_osd: int) -> 'BasePyOSDMap' :...
class BasePyOSDMapIncremental(object):
def _get_epoch(self):...
def pool_raw_used_rate(self, pool_id: int) -> float:
return self._pool_raw_used_rate(pool_id)
+ @classmethod
+ def build_simple(cls, epoch: int = 1, uuid: Optional[str] = None, num_osd: int = -1):
+ return cls._build_simple(epoch, uuid, num_osd)
+
def get_ec_profile(self, name: str) -> Optional[List[Dict[str, str]]]:
# FIXME: efficient implementation
d = self._dump()