Commit d14c0e74 authored by Paul Graydon's avatar Paul Graydon

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

parent a6a2ad19
...@@ -14,8 +14,12 @@ ...@@ -14,8 +14,12 @@
# not need these here). # not need these here).
[instance-profile] [instance-profile]
filename = instance.cfg filename = instance.cfg
md5sum = a88ac58fc22e804a176e4d43f917179e md5sum = 0080d427bc3e21c34015dc18d1d22b71
[template-fluentd] [template-fluentd]
filename = instance-fluentd.cfg 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 = ...@@ -26,3 +26,4 @@ parts =
{%- endfor %} {%- endfor %}
extends = ${monitor-template:output} 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-frontend-url": {
"title": "Wendelin frontend URL",
"description": "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 ...@@ -9,14 +9,16 @@ offline = true
[switch-softwaretype] [switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype recipe = slapos.cookbook:switch-softwaretype
default = dynamic-template-fluentd:output default = dynamic-template-fluentd:output
wendelin-telecom-gateway = dynamic-template-fluentd-wendelin-telecom-gateway:output
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
home = $${buildout:directory} home = $${buildout:directory}
bin = $${:home}/bin
etc = $${:home}/etc etc = $${:home}/etc
var = $${:home}/var var = $${:home}/var
service = $${:etc}/service service = $${:etc}/service
bin = $${:home}/bin fluentd-buffer = $${:var}/fluentd-buffer
[slap-configuration] [slap-configuration]
recipe = slapos.cookbook:slapconfiguration recipe = slapos.cookbook:slapconfiguration
...@@ -26,25 +28,73 @@ url = $${slap_connection:server_url} ...@@ -26,25 +28,73 @@ url = $${slap_connection:server_url}
key = $${slap_connection:key_file} key = $${slap_connection:key_file}
cert = $${slap_connection:cert_file} cert = $${slap_connection:cert_file}
[dynamic-template-fluentd] [jinja2-template-base]
recipe = slapos.recipe.template:jinja2 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} url = ${template-fluentd:output}
output = $${buildout:directory}/instance-fluentd.cfg output = instance-fluentd.cfg
extensions = jinja2.ext.do extensions = jinja2.ext.do
context = extra-context =
key fluentd_agent_conf fluentd-agent-conf:output
key port_list fluentd-conf:port-list [dynamic-template-fluentd-wendelin-telecom-gateway]
section directory directory <= 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] [fluentd-conf]
recipe = slapos.recipe.build recipe = slapos.recipe.build
slapparameter-dict = $${slap-configuration:configuration} slapparameter-dict = $${slap-configuration:configuration}
software-type = $${slap-configuration:slap-software-type}
buffer-file-dir = $${directory:fluentd-buffer}
init = init =
import re 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_url = options['slapparameter-dict'].get('wendelin-frontend-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/erp5/portal_ingestion_policies/ors_enb_log_ingestion\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_url, username, password, buffer_file_dir)
options['port-list'] = re.findall(r'<source>.*port (\d+).*<\/source>', options['conf-text'], re.DOTALL)
[fluentd-agent-conf] [fluentd-agent-conf]
recipe = slapos.recipe.template recipe = slapos.recipe.template
inline = $${fluentd-conf:text} inline = $${fluentd-conf:conf-text}
output = $${directory:etc}/fluentd-agent.conf output = $${directory:etc}/fluentd-agent.conf
...@@ -21,6 +21,10 @@ output = ${buildout:directory}/template.cfg ...@@ -21,6 +21,10 @@ output = ${buildout:directory}/template.cfg
< = template-base < = template-base
output = ${buildout:directory}/template-fluentd.cfg output = ${buildout:directory}/template-fluentd.cfg
[template-fluentd-wendelin-telecom-gateway]
< = template-base
output = ${buildout:directory}/template-fluentd-wendelin-telecom-gateway.cfg
[fluentd] [fluentd]
gems += gems +=
fluent-plugin-wendelin==0.5 fluent-plugin-wendelin==0.5
......
...@@ -5,10 +5,17 @@ ...@@ -5,10 +5,17 @@
"software-type": { "software-type": {
"default": { "default": {
"title": "Default", "title": "Default",
"description": "Fluentd", "description": "Default Fluentd configuration",
"request": "instance-input-schema.json", "request": "instance-input-schema.json",
"response": "instance-output-schema.json", "response": "instance-output-schema.json",
"index": 0 "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