Useful tools to handle Consul.
Project description
Consul Utils
============
# Introduction
[Consul](https://www.consul.io/) is a highly available and distributed service discovery and KV store designed with support for the modern data center. Consul provides a useful UI but it is not convenient for automation and batch processing. Consul-utils is a useful command line tool for these jobs based on Consul's API.
# Installation
Installation is easy by pip
```
pip install consul_utils
```
# Usage
Show help by
```
consul_utils --help
```
Consul-utils provides several useful tools to handle Consul.
## Configuration
First you should create a configuration file to save common settings like below:
```
# consul configuration
consul:
# consul host
host: "test.consul.com"
# consul port
port: 8500
# consul scheme
scheme: "http"
# consul ACL token
token: ""
# default root
root: ""
# cache configuration
cache:
# cache enabled or not
cache_enabled: true
# cache file
cache_dir: ".consul_cache"
# cache expire seconds
cache_ttl: 600
# log configuration
log:
# log level
log_level: "INFO"
# output configuration
reporter:
# result output type, text, json or csv
output_type: "text"
# result output file, leave empty to print to console
output_file: ""
# output all scan data
show_all_scan: false
# output filtered data
show_filtered: true
# output not filtered data
show_no_filtered: false
# output flags data
show_flags: false
# search command configuration
search:
# search results limit
limit: 10
# search fields, keys or values
fields: "keys"
# use regex for search or not
regex: false
```
Save this file to `config.yml`, remember it is not required and all settings can be specified by command line option. If same settings exists both in config file and options, the options value will override config file.
## Dump Consul key values
Dump key and values
```
consul_utils dump -c config.yml
```
Specify directory
```
consul_utils dump -c config.yml -r test/test_root
```
Change output type, text (default), json or csv
```
consul_utils dump -c config.yml -r test/test_root -x json
```
Output to file instead of console
```
consul_utils dump -c config.yml -r test/test_root -o out.txt
```
## Search in the Consul key values
Search keys that contains `test`
```
consul_utils search -c config.yml -q test
```
Search values that contains `test`
```
consul_utils search -c config.yml -q test -f values
```
Limit output result number, default 10
```
consul_utils search -c config.yml -q test --limit 5
```
Use regex to search
```
consul_utils search -c config.yml -q ^test$ -e
```
## Copy key values from one place to another
Copy key values under source root to target root
```
consul_utils copy -c config.yml --root test/source --target-root test/target
```
## Compare two key values
Compare two key values and all sub key values under two specified root
This command will compare all values for keys with the same relative path.
```
consul_utils diff -c config.yml --root1 test1/aa --root2 test2/bb
```
Compare key values from two different host. If not specified, will use the default (host, port, scheme, token) settings.
```
consul_utils diff -c config.yml --host1 test1.consul.com --root1 test1/aa --host2 test2.consul.com --root2 test2/bb
```
# Authors
Wu Wentao
============
# Introduction
[Consul](https://www.consul.io/) is a highly available and distributed service discovery and KV store designed with support for the modern data center. Consul provides a useful UI but it is not convenient for automation and batch processing. Consul-utils is a useful command line tool for these jobs based on Consul's API.
# Installation
Installation is easy by pip
```
pip install consul_utils
```
# Usage
Show help by
```
consul_utils --help
```
Consul-utils provides several useful tools to handle Consul.
## Configuration
First you should create a configuration file to save common settings like below:
```
# consul configuration
consul:
# consul host
host: "test.consul.com"
# consul port
port: 8500
# consul scheme
scheme: "http"
# consul ACL token
token: ""
# default root
root: ""
# cache configuration
cache:
# cache enabled or not
cache_enabled: true
# cache file
cache_dir: ".consul_cache"
# cache expire seconds
cache_ttl: 600
# log configuration
log:
# log level
log_level: "INFO"
# output configuration
reporter:
# result output type, text, json or csv
output_type: "text"
# result output file, leave empty to print to console
output_file: ""
# output all scan data
show_all_scan: false
# output filtered data
show_filtered: true
# output not filtered data
show_no_filtered: false
# output flags data
show_flags: false
# search command configuration
search:
# search results limit
limit: 10
# search fields, keys or values
fields: "keys"
# use regex for search or not
regex: false
```
Save this file to `config.yml`, remember it is not required and all settings can be specified by command line option. If same settings exists both in config file and options, the options value will override config file.
## Dump Consul key values
Dump key and values
```
consul_utils dump -c config.yml
```
Specify directory
```
consul_utils dump -c config.yml -r test/test_root
```
Change output type, text (default), json or csv
```
consul_utils dump -c config.yml -r test/test_root -x json
```
Output to file instead of console
```
consul_utils dump -c config.yml -r test/test_root -o out.txt
```
## Search in the Consul key values
Search keys that contains `test`
```
consul_utils search -c config.yml -q test
```
Search values that contains `test`
```
consul_utils search -c config.yml -q test -f values
```
Limit output result number, default 10
```
consul_utils search -c config.yml -q test --limit 5
```
Use regex to search
```
consul_utils search -c config.yml -q ^test$ -e
```
## Copy key values from one place to another
Copy key values under source root to target root
```
consul_utils copy -c config.yml --root test/source --target-root test/target
```
## Compare two key values
Compare two key values and all sub key values under two specified root
This command will compare all values for keys with the same relative path.
```
consul_utils diff -c config.yml --root1 test1/aa --root2 test2/bb
```
Compare key values from two different host. If not specified, will use the default (host, port, scheme, token) settings.
```
consul_utils diff -c config.yml --host1 test1.consul.com --root1 test1/aa --host2 test2.consul.com --root2 test2/bb
```
# Authors
Wu Wentao
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
consul_utils-0.1.2.tar.gz
(9.7 kB
view details)
Built Distribution
File details
Details for the file consul_utils-0.1.2.tar.gz
.
File metadata
- Download URL: consul_utils-0.1.2.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fb8fc1550d02536636702e35b1b914ceeeb827dca023bc4f3941ee405bd8dcf |
|
MD5 | 15af48462228dc75a1938ee2a0125406 |
|
BLAKE2b-256 | 5243d88b60ad34694b5d7a0353ac4c2c7de72d10d90346cd56a561cc85a45518 |
File details
Details for the file consul_utils-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: consul_utils-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71aad7e378a3972115a8f11b57063625378df00bf9310c54aab43cb9d2f6bd8c |
|
MD5 | 84705bc9b8ded1d6141ba418c0bff2b5 |
|
BLAKE2b-256 | 051499ef51aef69996e1aaea77f277b331a7fd2d25a27f5ccd78a0ca5e517a65 |