Reputation: 15770
I need to write a script to deploy Databases/Collections/Indexes.
Boto gives me a list of IPs to connect to.
What is the preferred way to figure out which mongo instance from a list is primary
using pymongo
? Should I loop through them or is there a more elegant approach?
Upvotes: 1
Views: 345
Reputation: 15770
primary = ''
for inst in instances:
client = MongoClient(inst, 8000)
if client.is_primary:
primary = inst
return primary
Upvotes: 1