This repository has been archived by the owner on Aug 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding a 2 second sleep in the playbook to make the region annotation visible. * Adding a Makefile and tools allowing to trigger tests.
- Loading branch information
Showing
8 changed files
with
96 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,3 +99,6 @@ ENV/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# vim undo files | ||
*.un~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: python | ||
sudo: required | ||
python: | ||
- "2.7" | ||
install: | ||
- pip install -r requirements.txt | ||
script: | ||
- make check | ||
services: | ||
- docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
syntax: | ||
pycodestyle --ignore=E265,E501 callback_plugins/grafana_annotations.py | ||
|
||
container: | ||
tools/start_grafana.sh | ||
|
||
check: container | ||
GRAFANA_API_TOKEN='$(shell python tools/get_or_create_token.py)' ansible-playbook test.yml | ||
#TODO: Check annotations are available in grafana | ||
#TODO: use a test framework like unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ansible==2.4 | ||
pycodestyle==2.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
tasks: | ||
- debug: | ||
msg: "Hello world" | ||
- command: sleep 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import httplib | ||
import sys | ||
import json | ||
import argparse | ||
from base64 import b64encode | ||
|
||
URI = "/api/auth/keys" | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--user", default="admin", help="login for basic authentication") | ||
parser.add_argument("--passwd", default="admin", help="password for basic authentication") | ||
parser.add_argument("--host", default="127.0.0.1", help="Grafana host address") | ||
parser.add_argument("--port", default="3000", help="Grafana listen port") | ||
args = parser.parse_args() | ||
|
||
cred = "%s:%s" % (args.user, args.passwd) | ||
HEADERS = {"Content-Type": "application/json", "Authorization": "Basic %s" % b64encode(cred).decode('ascii')} | ||
|
||
http = httplib.HTTPConnection(args.host, args.port) | ||
http.request("GET", URI, headers=HEADERS) | ||
response = http.getresponse() | ||
if response.status != 200: | ||
print response.read() | ||
tokens = json.loads(response.read()) | ||
|
||
token_id = None | ||
for token in tokens: | ||
if token.get("name") == "ansible-module": | ||
token_id = token.get('id') | ||
if token_id: | ||
http = httplib.HTTPConnection(args.host, args.port) | ||
http.request("DELETE", "%s/%d" % (URI, token_id), headers=HEADERS) | ||
response = http.getresponse() | ||
if response.status != 200: | ||
print "Failed to remove 'ansible-module' token [%s]" % response.read() | ||
sys.exit(1) | ||
|
||
http = httplib.HTTPConnection(args.host, args.port) | ||
http.request("POST", URI, '{"name": "ansible-module", "role": "Editor"}', headers=HEADERS) | ||
response = http.getresponse() | ||
if response.status != 200: | ||
print "Failed to create 'ansible-module' token" | ||
sys.exit(1) | ||
print json.loads(response.read())["key"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
CONTAINER=$(docker ps | grep 'grafana/grafana'|awk '{print $1}') | ||
[ -n "$CONTAINER" ] && echo "Container already running" && exit 0 | ||
|
||
docker pull grafana/grafana | ||
[ $? -ne 0 ] && exit 1 | ||
|
||
docker run -d --name=grafana -p 3000:3000 grafana/grafana | ||
sleep 2 | ||
exit $? |