pynuoadmin Management Client Package Setup

The pynuoadmin client package enables the client management of a NuoDB database without the need to install the full NuoDB product on a client machine. To setup client management, follow pynuoadmin installation instructions located on the PyPi (Python Package Index) website.

Once installed, add the following lines to your Linux shell startup file, for example .bashrc if using Bash:

nuocmd () {
    python -m nuodb_cli "$@"
}
export -f nuocmd

Setting up Command Argument Completion

NuoDB recommends that you install command argument completion for NuoDB Command nuocmd.

To install using the pip package manager for python, run:

pip install pynuoadmin[completion]

Enable nuocmd argument completion in your Linux Bash environment by running the following command. Also, to enable this feature for every Bash session, then add the line to your .bashrc after the nuocmd function definition mentioned above.

eval "$(register-python-argcomplete nuocmd)"

Example

The pynuoadmin package includes the command-line tool described above, and also a Python client API that can be used programmatically.

Using a Python distribution that has the pynuoadmin package you can run the following script.

import nuodb_mgmt

# In this example two nuodb admin servers are used, 'server0' and 'server1'

# Get client object; the client key and server certificate are assumed to be configured according to the Unique Admin Key model
conn = nuodb_mgmt.AdminConnection(api_server='https://server0:8888', client_key='/etc/nuodb/keys/nuocmd.pem', verify='/etc/nuodb/keys/ca.cert')

# create an archive object for database 'db' on admin server 'server0'
archive = conn.create_archive(db_name='db', server_id='server0', archive_path='/var/opt/nuodb/archive/db')

# create a database object for 'db'
db = conn.create_database(db_name='db', dba_user='user', dba_password='secret')

# start an SM on 'server0' and a TE on 'server1'
sm = conn.start_process(db_name='db', engine_type='SM', server_id='server0', archive_id=archive.id)
te = conn.start_process(db_name='db', engine_type='TE', server_id='server1')