Jump to: navigation, search


Spec for Templated Output Formatting

At the command-line, we currently select a subset of the discovery data and format it using a hard-coded output routine. Different users have expressed interest in different parts of the output. While we can provide access to the raw data, there may eventually be so much of it that it becomes less useful and harder for users to find the parts they are interested in.

This spec proposes:

  • support multiple output formats: JSON and text by default.
  • allow the customization of the output using a templating language.

Implementation Proposal

1. Support --format and -F as an argument. Use JSON Formatter to format JSON data online.

2. Support JSON and text as built-in formats. Text will be the default output using a standard template. JSON will be a built-in output (no template, because templates basically consume the JSON).

3. Use Jinja2 for output formatting (already part of OpenStack requirements).

4. Have the text output be generated by a default template that ships with satori

For example, in the satori repository:

 $ satori example.com                         # default format (uses text.jinja)
 $ satori example.com -F json                 # built-in json formatter, uses json.dumps(data, indent=2)
 $ satori example.com —format custom          # custom, packaged formatter (custom.jinja)
 $ satori example.com —format /etc/my/format  # format using an external template

We may include some default templates such as:

  • Template focused on package information (ex. satori example.com -F packages - would use satori/formats/packages.jinja)
  • Template focused on networking information (ex. satori example.com -F netinfo)
 # For example, using netinfo:
 $ satori example.com —format netinfo
 Interface: eth0
   IPv4 address:
   IPv6 address: 2001::808:9808
  Hostname: web01.example.com
  DNS servers: