MCPcopy Create free account
hub / github.com/ceph/ceph / open_db

Method open_db

src/pybind/mgr/mgr_module.py:1345–1362  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1343 self._db = None
1344
1345 def open_db(self) -> Optional[sqlite3.Connection]:
1346 if not self.pool_exists(self.MGR_POOL_NAME):
1347 if not self.have_enough_osds():
1348 self.log.warning('not enough osds to create mgr pool')
1349 return None
1350 self.create_mgr_pool()
1351 uri = f"file:///{self.MGR_POOL_NAME}:{self.module_name}/main.db?vfs=ceph"
1352 self.log.debug(f"using uri {uri}")
1353 db = sqlite3.connect(uri, check_same_thread=False, uri=True, isolation_level=None) # type: ignore[call-arg]
1354 # if libcephsqlite reconnects, update the addrv for blocklist
1355 with db:
1356 cur = db.execute('SELECT json_extract(ceph_status(), "$.addr");')
1357 (addrv,) = cur.fetchone()
1358 assert addrv is not None
1359 self.log.debug(f"new libcephsqlite addrv = {addrv}")
1360 self._ceph_register_client("libcephsqlite", addrv, True)
1361 self.configure_db(db)
1362 return db
1363
1364 @API.expose
1365 def db_ready(self) -> bool:

Callers 2

dbMethod · 0.95
checkFunction · 0.80

Calls 8

pool_existsMethod · 0.95
have_enough_osdsMethod · 0.95
create_mgr_poolMethod · 0.95
configure_dbMethod · 0.95
warningMethod · 0.45
debugMethod · 0.45
connectMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected