Skip to content

Commit 7afd43d

Browse files
authored
Update to make getNamespaces() API at par with the get_ns_list() swssdk-py API. (#455)
Update to make getNamespaces() API at par with the get_ns_list() in swsssdk. So this API 1. Will give back all namespaces including the global namespace ('') 2. Will not preload the Global database_config.json. The application should call SonicDBConfig::initializeGlobalConfig explicity.
1 parent 9e91e0d commit 7afd43d

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

common/dbconnector.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,12 @@ vector<string> SonicDBConfig::getNamespaces()
363363
vector<string> list;
364364
std::lock_guard<std::recursive_mutex> guard(m_db_info_mutex);
365365

366-
if (!m_global_init)
367-
initializeGlobalConfig();
366+
if (!m_init)
367+
initialize(DEFAULT_SONIC_DB_CONFIG_FILE);
368368

369-
// This API returns back non-empty namespaces.
369+
// This API returns back all namespaces including '' representing global ns.
370370
for (auto it = m_inst_info.cbegin(); it != m_inst_info.cend(); ++it) {
371-
if(!((it->first).empty()))
372-
list.push_back(it->first);
371+
list.push_back(it->first);
373372
}
374373

375374
return list;

tests/redis_multi_ns_ut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ TEST(DBConnector, multi_ns_test)
6767
else
6868
{
6969
ns_name = element["namespace"];
70-
namespaces.push_back(ns_name);
7170
}
71+
namespaces.push_back(ns_name);
7272

7373
// parse config file
7474
ifstream i(local_file);

0 commit comments

Comments
 (0)