Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Commit

Permalink
use our custom YAML dumper for alerts and entities too
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Nov 30, 2015
1 parent 0f49e9f commit 945b0d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ junit.xml
*.egg*
.cache/
htmlcov/
*.swp
12 changes: 6 additions & 6 deletions zmon_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
from redis import StrictRedis

# fields to dump as literal blocks
LITERAL_FIELDS = set(['command', 'description'])
LITERAL_FIELDS = set(['command', 'condition', 'description'])

# custom sorting of YAML fields (i.e. we are not using the default lexical YAML ordering)
FIELD_ORDER = ['name', 'owning_team', 'description', 'command', 'interval', 'entities', 'status', 'last_modified_by']
FIELD_ORDER = ['id', 'check_definition_id', 'type', 'name', 'team', 'owning_team', 'responsible_team', 'description',
'condition',
'command', 'interval', 'entities', 'entities_exclude', 'status', 'last_modified_by']
FIELD_SORT_INDEX = {k: chr(i) for i, k in enumerate(FIELD_ORDER)}

DEFAULT_CONFIG_FILE = '~/.zmon-cli.yaml'
Expand Down Expand Up @@ -313,7 +315,7 @@ def getAlertDefinition(alert_id):
if data[k] is None:
del data[k]

print(yaml.safe_dump(data, default_flow_style=False, allow_unicode=True, encoding='utf-8').decode('utf-8'))
print(dump_yaml(data))


@alert_definitions.command("update")
Expand Down Expand Up @@ -510,9 +512,7 @@ def get_entity(ctx, entity_id):
try:
r = get('/entities/{}/'.format(urllib.parse.quote_plus(entity_id)))
if r.status_code == 200 and r.text != "":
print(yaml.safe_dump(r.json(), default_flow_style=False,
allow_unicode=True,
encoding='utf-8').decode('utf-8'))
print(dump_yaml(r.json()))
else:
action("getting entity " + entity_id + "...")
error("not found")
Expand Down

0 comments on commit 945b0d6

Please sign in to comment.