MongoDB database management

MongoDB database management

Enable MongoDB database management functionality.

Problem Description

The MongoDB datastore does not support database management features. Allowing the user to create, list, and delete databases through the API is essential.

Proposed Change

Three standard Trove commands will be enabled for MongoDB:

  1. database-create

  2. database-list

  3. database-delete

The changes will be confined to the guestagent code. The taskmanager, API, and conductor do not require any code changes. The code changes will be to implement a new class service.MongoDBAdmin and the corresponding methods as members of the class. The methods of manager.Manager will be updated to call the admin functions.

Calls to MongoDB will be done in Python via the PyMongo library, which is required to be pre-installed on the guest.


No changes will be made to any configuration files.


No new items will be added here.

Public API

No API changes.

Public API Security

No API Security changes.

Python API

None (empty section added after merging)

CLI (python-troveclient)

None (empty section added after merging)

Internal API

No Internal API changes.

Guest Agent

Modified files:

trove/guestagent/db/ - add a MongoDBSchema class.
trove/guestagent/datastore/experimental/mongodb/ - enable functions.
trove/guestagent/datastore/experimental/mongodb/ - add functions.

The Guest Agent will be changed to support the following manager functions:

  1. create_database - MongoDB does not have a method to explicitly create a database. The database to use is specified via ‘use <dbname>’, but this does not create the database. Databases are created when a ‘document’ is first inserted into them. To ensure a database is created, a dummy document will be inserted but then deleted.

  2. list_databases - Run ‘pymongo.MongoClient.database_names()’ and return the resulting list.

  3. delete_database - Drop the database with ‘pymongo.MongoClient.drop_database(“<dbname>”)’. Users associated with the database will have to be removed manually.


create_database could not create a dummy object in the database.



Matthew Van Dijk



Work Items

The changes will be implemented in a single commit. The scope is small and the functionality is linked.

Upgrade Implications

There will be no upgrade implications.


There are no dependencies on other work in progress.


Unit tests will be added to validate non-trivial code paths. Integration tests may be added as needed.

Documentation Impact

The MongoDB datastore documentation can be updated to reflect the enabled features.


There are no external references in this document.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

trove-specs 0.0.1.dev177