Commit ab2ba216 authored by Paul Graydon's avatar Paul Graydon

software/fluentd: Add wendelin-telecom-gateway software type

parent 06154499
......@@ -14,8 +14,12 @@
# not need these here).
[instance-profile]
filename = instance.cfg
md5sum = a88ac58fc22e804a176e4d43f917179e
md5sum = bb542e2eecbb4c6d5e3b74c9e7ca66fc
[template-fluentd]
filename = instance-fluentd.cfg
md5sum = 35f9d95f6a75e28bfeafc3568ca16f05
md5sum = 1b6f5b4fb0ec9e961e3c0a1ba0075a38
[template-fluentd-wendelin-telecom-gateway]
filename = instance-fluentd-wendelin-telecom-gateway.cfg
md5sum = 1dbc57f07a7d697c296611f4b889bea3
[fluentd-cert]
recipe = slapos.recipe.build
fluentd-agent-conf = {{ fluentd_agent_conf }}
key-file = $${ca-directory:certs}/fluentd.key
cert-file = $${ca-directory:certs}/fluentd.crt
init =
import os
fluentd_agent_conf = options['fluentd-agent-conf']
tls_config_text = (
" <transport tls>\n"
" cert_path %s\n"
" private_key_path %s\n"
" private_key_passphrase\n"
" </transport>\n"
) % (options['cert-file'], options['key-file'])
tls_tag = "<transport tls>"
add_tls_section = True
insert_index = 5
with open(fluentd_agent_conf, "r+") as conf:
contents = conf.readlines()
if any([tls_tag in line for line in contents]):
add_tls_section = False
if add_tls_section:
contents.insert(insert_index, tls_config_text)
conf.seek(0)
conf.writelines(contents)
conf.truncate()
[service-fluentd]
recipe = slapos.cookbook:wrapper
wrapper-path = {{ directory['bin'] }}/fluentd-service
command-line = ${fluentd:location}/bin/fluentd -v -c {{ fluentd_agent_conf }}
environment =
GEM_PATH=${fluentd:location}/lib/ruby/gems/
[ca-fluentd]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
key-file = $${fluentd-cert:key-file}
cert-file = $${fluentd-cert:cert-file}
executable = $${service-fluentd:wrapper-path}
wrapper = {{ directory['service'] }}/fluentd-service
{% set part_list = [] -%}
{% for port in port_list -%}
{% set promise_section_title = 'fluentd-port-' ~ port ~ '-listening' -%}
{% do part_list.append(promise_section_title) -%}
[{{ promise_section_title }}]
<= monitor-promise-base
promise = check_socket_listening
name = {{ promise_section_title }}.py
config-host = $${slap-configuration:ipv6-random}
config-port = {{ port }}
{% endfor %}
[buildout]
extends = ${monitor-template:output}
parts =
certificate-authority-service
ca-fluentd
{%- for part in part_list %}
{{ part }}
{%- endfor %}
......@@ -26,3 +26,4 @@ parts =
{%- endfor %}
extends = ${monitor-template:output}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "Parameters to instantiate Fluentd",
"additionalProperties": false,
"properties": {
"port": {
"title": "Port",
"description": "Port on which to listen for incoming data",
"type": "integer",
"default": 24224
},
"wendelin-ingestion-url": {
"title": "Wendelin ingestion URL",
"description": "Ingestion endpoint URL of the Wendelin Telecom instance to which the data is to be forwarded",
"type": "string"
},
"username": {
"title": "Wendelin account username",
"description": "The username of a valid account to authenticate with on the Wendelin instance",
"type": "string"
},
"password": {
"title": "Wendelin account password",
"description": "The password of the account to authenticate with on the Wendelin instance",
"type": "string"
}
}
}
......@@ -9,14 +9,16 @@ offline = true
[switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype
default = dynamic-template-fluentd:output
wendelin-telecom-gateway = dynamic-template-fluentd-wendelin-telecom-gateway:output
[directory]
recipe = slapos.cookbook:mkdirectory
home = $${buildout:directory}
bin = $${:home}/bin
etc = $${:home}/etc
var = $${:home}/var
service = $${:etc}/service
bin = $${:home}/bin
fluentd-buffer = $${:var}/fluentd-buffer
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration
......@@ -26,25 +28,73 @@ url = $${slap_connection:server_url}
key = $${slap_connection:key_file}
cert = $${slap_connection:cert_file}
[dynamic-template-fluentd]
[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
extra-context =
context =
section directory directory
key fluentd_agent_conf fluentd-agent-conf:output
key port_list fluentd-conf:port-list
$${:extra-context}
[dynamic-template-fluentd]
<= jinja2-template-base
url = ${template-fluentd:output}
output = $${buildout:directory}/instance-fluentd.cfg
output = instance-fluentd.cfg
extensions = jinja2.ext.do
context =
key fluentd_agent_conf fluentd-agent-conf:output
key port_list fluentd-conf:port-list
section directory directory
extra-context =
[dynamic-template-fluentd-wendelin-telecom-gateway]
<= jinja2-template-base
url = ${template-fluentd-wendelin-telecom-gateway:output}
output = instance-fluentd-wendelin-telecom-gateway.cfg
extensions = jinja2.ext.do
extra-context =
[fluentd-conf]
recipe = slapos.recipe.build
slapparameter-dict = $${slap-configuration:configuration}
software-type = $${slap-configuration:slap-software-type}
buffer-file-dir = $${directory:fluentd-buffer}
init =
import re
options['text'] = options['slapparameter-dict'].get('conf-text') or ' '
options['port-list'] = re.findall(r'<source>.*port (\d+).*<\/source>', options['text'], re.DOTALL)
software_type = options['software-type'] or 'RootSoftwareInstance'
if software_type in ['RootSoftwareInstance', 'default']:
options['conf-text'] = options['slapparameter-dict'].get('conf-text') or ' '
elif software_type == 'wendelin-telecom-gateway':
port = options['slapparameter-dict'].get('port') or '24224'
wendelin_telecom_ingestion_url = options['slapparameter-dict'].get('wendelin-ingestion-url')
username = options['slapparameter-dict'].get('username')
password = options['slapparameter-dict'].get('password')
buffer_file_dir = options['buffer-file-dir']
options['conf-text'] = (
"<source>\n"
" @type forward\n"
" port %s\n"
" bind ::0\n"
" add_tag_prefix ors\n"
"</source>\n"
"<match ors.**>\n"
" @type wendelin\n"
" streamtool_uri %s\n"
" user %s\n"
" password %s\n"
" <buffer>\n"
" flush_mode interval\n"
" flush_interval 1m\n"
" @type file\n"
" path %s/\n"
" </buffer>\n"
"</match>"
) % (port, wendelin_telecom_ingestion_url, username, password, buffer_file_dir)
options['port-list'] = re.findall(r'<source>.*port (\d+).*<\/source>', options['conf-text'], re.DOTALL)
[fluentd-agent-conf]
recipe = slapos.recipe.template
inline = $${fluentd-conf:text}
recipe = slapos.recipe.template
inline = $${fluentd-conf:conf-text}
output = $${directory:etc}/fluentd-agent.conf
......@@ -21,6 +21,10 @@ output = ${buildout:directory}/template.cfg
< = template-base
output = ${buildout:directory}/template-fluentd.cfg
[template-fluentd-wendelin-telecom-gateway]
< = template-base
output = ${buildout:directory}/template-fluentd-wendelin-telecom-gateway.cfg
[fluentd]
gems +=
fluent-plugin-wendelin==0.5
......
......@@ -5,10 +5,17 @@
"software-type": {
"default": {
"title": "Default",
"description": "Fluentd",
"description": "Default Fluentd configuration",
"request": "instance-input-schema.json",
"response": "instance-output-schema.json",
"index": 0
},
"wendelin-telecom-gateway": {
"title": "Wendelin Telecom Gateway",
"description": "Gateway configuration for forwarding ORS eNB Xlog data to Wendelin Telecom",
"request": "instance-wendelin-telecom-gateway-input-schema.json",
"response": "instance-output-schema.json",
"index": 0
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment