Skip to main content

es-riak

This is a helper script for interacting with Riak.

Before you begin using this utility, you should know that it was written to interact not just with Riak, but with a specific instantiaion of Riak used to support the Enstratius cloud management software suite.

There are methods available here, such as --elevate-api-key that have no meaning outside of the context of an installation of Riak to support the Enstratius cloud management software suite.

While this script was written to interact with Riak supporting Enstratius, the script itself is in no way endorsed or supported by Enstratius or Dell Software.

Word of warning

By using this script you are violating the datamunging warning set by John Vincent in his Riak overview. Proceed at your own risk.

Requirements

  1. Python

  2. [Requests Library](http://docs.python-requests.org/en/latest/user/install/#install)

Helpful: http://docs.python-requests.org/en/latest/user/quickstart

Installation

sudo easy_install riak-cli-tool

or

sudo pip install riak-cli-tool

Secondary Indices

Enstratius makes heavy use of secondary indices. This scrip is supposed to find, save, and utilize existing secondary indices when updating bucket contents that have them in place.

This is not well tested.

Configuration Files

None. You’ll want to add an export statement to your profile:

export riak_host='127.0.0.1'

and make sure it is sourced before attempting to use the utility.

The port is set to 8098.

Commands

List all buckets

THIS IS A BAD IDEA, USUALLY.

es-riak --list-buckets

{
    "buckets": [
        "content_template",
        "configuration_management_system",
        "frontend_configuration"
    ]
}

List all keys in a bucket

THIS IS A BAD IDEA, USUALLY.

es-riak --list-keys -b content_template

{
    "keys": [
        "passwordChangeSubject",
        "optimusEngineEmail",
        "changeAccountData_en"
    ]
}

Show the contents of a bucket

es-riak --show -b frontend_configuration -k 1

{
    "SCHEMA_VERSION": "0",
    "autoProvisionUsers": "true",
    "defaultAuthenticationMethod": "NATIVE",
    "defaultGroupIds": [],
    "forceDefaultAuthentication": "true",
    "forceDeny": [],
    "masterNetworkId": 999,
    "systemName": "Enstratius"
}

Save the contents of a bucket/key to a file:

es-riak --save save_file.json -b frontend_configuration -k 1

Saved contents of:

  http://172.16.243.131:8098/buckets/frontend_configuration/keys/1

to

  save_file.json

Checking the contents of the save file:

cat save_file.json  | python -mjson.tool

{
    "SCHEMA_VERSION": "0",
    "autoProvisionUsers": "true",
    "defaultAuthenticationMethod": "NATIVE",
    "defaultGroupIds": [],
    "forceDefaultAuthentication": "true",
    "forceDeny": [],
    "masterNetworkId": 1,
    "systemName": "Enstratius"
}

Update the contents of a bucket/key by passing in a json file

es-riak --update -b frontend_configuration -k 1 -i input.json
Valid JSON
updating!

Saved contents of:

  http://172.16.243.131:8098/buckets/frontend_configuration/keys/1

to

  input.json.original


 Done.

 To view your changes, call:

es-riak --show -b frontend_configuration -k 1

where the file input.json has contents:

cat input.json | python -mjson.tool

{
    "SCHEMA_VERSION": "0",
    "autoProvisionUsers": "true",
    "defaultAuthenticationMethod": "NATIVE",
    "defaultGroupIds": [],
    "forceDefaultAuthentication": "true",
    "forceDeny": [],
    "masterNetworkId": 999,
    "systemName": "Enstratius"
}

bucket contents post-update:

es-riak --show -b frontend_configuration -k 1

{
    "SCHEMA_VERSION": "0",
    "autoProvisionUsers": "true",
    "defaultAuthenticationMethod": "NATIVE",
    "defaultGroupIds": [],
    "forceDefaultAuthentication": "true",
    "forceDeny": [],
    "masterNetworkId": 999,
    "systemName": "Enstratius"
}

Doing a “PUT” to a bucket/key

A plain old “PUT” differs from an update in that there is no step of saving the current contents of a bucket/key (as there may be none) prior to putting the contents of the passed file to the bucket/key.

Futhermore, if there happen to be existing contents of a given bucket/key such as -b frontend_configuration -k 1 and a put is made to that combination, the existing contents will be immediately overwritten.

To put the contents of a file to a bucket/key, execute a call like this:

es-riak --put -b frontend_configuration -k 1 -i input.json

where the contents of input.json might be:

{
    "SCHEMA_VERSION": "0",
    "autoProvisionUsers": "true",
    "defaultAuthenticationMethod": "NATIVE",
    "forceDefaultAuthentication": "true",
    "masterNetworkId": 1,
    "systemName": "Enstratius Hosted",
    "systemReplyEmail": "systemreplyemail@enstratius.com",
    "systemSupportEmail": "systemsupportemail@enstratius.com",
    "systemSupportUrl": "http://system.support.url.com",
    "systemUserConsoleUrl": "https://system.user.console.url/test"
}

The --put flag will trigger the following checks before attempting to put the file contents to the bucket/key:

  1. Does the file exist?

  2. Is the file valid JSON?

So be it.

Valid JSON

Putting the contents of

input.json

to

http://127.0.0.1:8098/buckets/frontend_configuration/keys/1


 Done.

  To view the results of this action, call:

  es-riak --show -b frontend_configuration -k 1

Validating an input JSON file

Valid JSON:

es-riak --validate -i input.json

Valid JSON

Invalid JSON:

es-riak --validate -i invalid.txt

Invalid JSON

Where the contents of invalid.txt are:

{
    "SCHEMA_VERSION": "0",
    "autoProvisionUsers": "true",
    "defaultAuthenticationMethod": "NATIVE",
    "defaultGroupIds": [],
    "forceDefaultAuthentication": "true",
    "forceDeny": [],
    "masterNetworkId": 999,
    "systemName":
}

Elevating an API key

You can use this utility to elevate an API key to a “system” key.

es-riak --elevate-api-key -b api_key -k <your_api_access_key>

An example of this type of interaction is shown here:

es-riak --show -b api_key -k DJFLPQSDJAUHLMLPDJIO

{
    "SCHEMA_VERSION": "0",
    "accessKey": "DJFLPQSDJAUHLMLPDJIO",
    "activationTimestamp": 1368202730181,
    "billingAccount": 52901,
    "customer": 51400,
    "description": "test key",
    "encryption": "TWO",
    "name": "Test",
    "network": 50069,
    "secretKey": "ee235a772d0def0b069d6364cda6a34e8d6d9eca6afcd94d37770e12c6d6d735df9a75fb64bd0a1cb18911a7ed4744fb"
}

There is no need to issue the show command first, I’m just doing it to highlight the differences.

With this information issue the command:

es-riak --elevate-api-key -b api_key -k DJFLPQSDJAUHLMLPDJIO

There will be no output from this command.

bucket contents post-elevate:

es-riak --show -b api_key -k DJFLPQSDJAUHLMLPDJIO

{
    "SCHEMA_VERSION": "0",
    "accessKey": "DJFLPQSDJAUHLMLPDJIO",
    "activationTimestamp": 1368202730181,
    "billingAccount": 52901,
    "customer": 51400,
    "customerManagementKey": true,
    "description": "test key",
    "encryption": "TWO",
    "name": "Test",
    "network": 50069,
    "secretKey": "ee235a772d0def0b069d6364cda6a34e8d6d9eca6afcd94d37770e12c6d6d735df9a75fb64bd0a1cb18911a7ed4744fb",
    "systemManagementKey": true
}

Metadata

Release files for riak_cli_tool 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for riak_cli_tool 0.1.7
File Size Uploaded Provenance
riak_cli_tool-0.1.7.tar.gz 7.2 kB Without provenance Details

Release files / riak_cli_tool-0.1.7.tar.gz

Download URL riak_cli_tool-0.1.7.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
76e0cdaed00ef3c3d179b8c7836a66c2dc7070bf02784d768e6dd66504e28c11
BLAKE2b-256 checksum
How to use checksums
89b9119fd2e880f531fdef69707c80966e8e84cf9343e85feb531c48af4efe97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for riak_cli_tool 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page