diff --git a/bundles/grafana/items.py b/bundles/grafana/items.py index 555a145..8d1d620 100644 --- a/bundles/grafana/items.py +++ b/bundles/grafana/items.py @@ -1,3 +1,66 @@ +c = '''##################### Grafana Configuration Example ##################### +# +# Everything has defaults so you only need to uncomment things you want to +# change + +# possible values : production, development +;app_mode = production + +# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty +;instance_name = ${HOSTNAME} + +#################################### Paths #################################### +[paths] +# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) +;data = /var/lib/grafana + +# Temporary files in `data` directory older than given duration will be removed +;temp_data_lifetime = 24h + +# Directory where grafana can store logs +;logs = /var/log/grafana + +# Directory where grafana will automatically scan and look for plugins +;plugins = /var/lib/grafana/plugins + +# folder that contains provisioning config files that grafana will apply on startup and while running. +;provisioning = conf/provisioning + +#################################### Server #################################### +[server] +# Protocol (http, https, h2, socket) +;protocol = http + +# The ip address to bind to, empty will bind to all interfaces +;http_addr = + +# The http port to use +;http_port = 3000 + +# The public facing domain name used to access grafana from a browser +;domain = localhost + +# Redirect to correct domain if host header does not match domain +# Prevents DNS rebinding attacks +;enforce_domain = false + +# The full public facing url you use in browser, used for redirects and emails +# If you use reverse proxy and sub path specify full url (with sub path) +;root_url = %(protocol)s://%(domain)s:%(http_port)s/ + +# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons. +;serve_from_sub_path = false + +# Log web requests +;router_logging = false + +# the path relative working path +;static_root_path = public + +# enable gzip +;enable_gzip = false +''' + files['/etc/grafana/test'] = { - 'content': repo.libs.ini.dumps({'HALLO': {'was': 'itlos', 'ich': 123}, 'YO': {}}), + 'content': repo.libs.ini.dumps(repo.libs.ini.parse(c)), } diff --git a/libs/ini.py b/libs/ini.py index cd283ee..792e52b 100644 --- a/libs/ini.py +++ b/libs/ini.py @@ -1,17 +1,23 @@ from configparser import ConfigParser +def parse(text): + config = ConfigParser() + config.read_string(text) + + return { + section: dict(config.items(section)) + for section in config.sections() + } + class Writable(): data = '' - + def write(self, line): self.data += line def dumps(dict): config = ConfigParser() - - for section, settings in dict.items(): - config[section] = settings - + config.read_dict(dict) writable = Writable() config.write(writable)