Skip to content

Latest commit

 

History

History
248 lines (167 loc) · 6.54 KB

commands.rst

File metadata and controls

248 lines (167 loc) · 6.54 KB

Gohan Commands

Run gohan -h to list available commands

NAME:
   gohan - Gohan

USAGE:
   gohan [global options] command [command options] [arguments...]

VERSION:
   0.0.0

COMMANDS:
   validate, v          Validate Json Schema file
   init-db, id          Init DB
   convert, conv        Convert DB
   server, srv          Run API Server
   help, h              Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --version, -v        print the version
   --help, -h           show help

Validate

NAME:
   validate - Validate Json Schema file

USAGE:
   command validate [command options] [arguments...]

DESCRIPTION:


OPTIONS:
   --schema, -s '../schema/core.json'   Json schema path
   --json, -i '../example/example.json' json path

Template

NAME:
    template - Convert gohan schema using pongo2 template

USAGE:
    command template [command options] [arguments...]

DESCRIPTION:
    Convert gohan schema using pongo2 template

OPTIONS:
    --config-file "gohan.yaml"      Server config File
    --template, -t          Template File

OpenAPI

NAME:
    openapi - Convert gohan schema to OpenAPI

USAGE:
    command openapi [command options] [arguments...]

DESCRIPTION:
    Convert gohan schema to OpenAPI

OPTIONS:
    --config-file "gohan.yaml"                              Server config File
    --template, -t "embed://etc/templates/openapi.tmpl"     Template File

MarkDown

NAME:
    markdown - Convert gohan schema using pongo2 template

USAGE:
    command markdown [command options] [arguments...]

DESCRIPTION:
    Convert gohan schema using pongo2 template

OPTIONS:
    --config-file "gohan.yaml"                              Server config File
    --template, -t "embed://etc/templates/markdown.tmpl"    Template File

CLI Client

You can use gohan client command to connect to gohan.

Gohan client will show quick help for sub command for current server schema.

Configuration

Gohan CLI Client is configured though environment variables. Configuration can be divided into few sections.

You can use default configuraion for client with: source ./etc/gohan_client.rc

Keystone

To configure keystone access for Gohan Client CLI, only few options should be set (they are compatible with those from rackspace/gophercloud:

  • OS_AUTH_URL - keystone url
  • OS_USERNAME - keystone username
  • OS_PASSWORD - keystone password
  • OS_TENANT_NAME or OS_TENANT_ID - keystone tenant name or id
  • OS_DOMAIN_NAME or OS_DOMAIN_ID - keystone domain name or id (for keystone v3 only)
  • OS_TOKEN_ID - token ID used to authenticate requests

Endpoint

Gohan enpoint url can be specified directly or Gohan Client can get it from configured keystone.

To specify endpoint directly, just set GOHAN_ENDPOINT_URL to proper url.

When using keystone:

  • GOHAN_SERVICE_NAME - Gohan service name in keystone
  • GOHAN_REGION - Gohan region name in keystone

Note: setting all above options will result in using GOHAN_ENDPOINT_URL!

Schemas

Gohan CLI Client is fetching available schemas from Gohan endpoint and can cache them in temp file for performance:

  • GOHAN_SCHEMA_URL - Gohan schema url
  • GOHAN_CACHE_SCHEMAS - should cache schemas (default - true)
  • GOHAN_CACHE_TIMEOUT - how long cache is valid, uses 1h20m10s format (default - 5m)
  • GOHAN_CACHE_PATH - where to store cache schemas (default - /tmp/.cached_gohan_schemas)

Usage

Usage can be briefly described with:

gohan client schema_id command [arguments...] [resource_identifier]

Each part of above command is described below.

Schema_id

schema_id determines which resource type we want to manage.

If used schema_id is not defined in Gohan, Gohan CLI Client will return Command not found error.

Command

Commands are identical for each resources:

  • list - List all resources
  • show - Show resource details
  • create - Create resource
  • set - Update existing resource
  • delete - Delete resource

Arguments

Arguments should be specified in --name value format.

Passing JSON null value: --name "<null>"

Passing JSON not null value: --name '{"name": [{"name": "value"}, {"name": "value"}]}'

Common arguments

In addition to resource related commands, some formatting commands are available:

  • --output-format [json/table] - specifies in which format results should be shown. Can also be specified with GOHAN_OUTPUT_FORMAT environment variable.

    • json, e.g:

      {
        "name": "Resource name",
        "description": "Resource very long and meaningful description",
        "some_list": [
          "list_element_1",
          "list_element_2"
        ]
      }
    • table, e.g:

      +-------------+--------------------------------------+
      |    FIELD    |               TYPE                   |
      +-------------+--------------------------------------+
      | name        | Resource name                        |
      | description | Resource description                 |
      | some_list   | ["list_element_1", "list_element_2"] |
      +-------------+--------------------------------------+
  • --verbosity [0-3] - specifies how much information Gohan Client should show - handy for dubugging. Can also be specified with GOHAN_VERBOSITY environment variable.

    • 0 - no additional debug information is shown
    • 1 - Sent request url and method is shown
    • 2 - same as level 1 + request & response body
    • 3 - same as level 2 + used auth token

Resource identifier

Some commands (show, set, delete) are executed on one resource only. To identify whis reource, it's name or id could be used:

gohan client network show network-id
gohan client network show "Network Name"
gohan client subnet create --network "Network Name"
gohan client subnet create --network network-id
gohan client subnet create --network_id network-id