diff --git a/files/neomodel/docker_run.sh b/files/neomodel/docker_run.sh index 4da2bfc..592b46b 100644 --- a/files/neomodel/docker_run.sh +++ b/files/neomodel/docker_run.sh @@ -5,7 +5,8 @@ docker run \ -e NEO4J_apoc_export_file_enabled=true \ -e NEO4J_apoc_import_file_enabled=true \ -e NEO4J_apoc_import_file_use__neo4j__config=true \ - -e NEO4JLABS_PLUGINS=\[\"apoc\"\] \ --publish=7474:7474 --publish=7687:7687 \ --volume=`pwd`/plugins:/plugins \ neo4j:4.4.0 + +# -e NEO4JLABS_PLUGINS=\[\"apoc\"] \ diff --git a/inventory/targets/fvwm.yml b/inventory/targets/fvwm.yml index 3d8ec89..f865047 100644 --- a/inventory/targets/fvwm.yml +++ b/inventory/targets/fvwm.yml @@ -66,6 +66,8 @@ parameters: body: | Module FvwmMFL exec exec setxkbmap -layout 'us,ru' -option 'grp:caps_toggle,grp_led:caps' + Key L A M Exec exec i3lock + Key F12 A A exec exec import /home/bebebeko/Downloads/screenshot.png tmuxinator: windows: diff --git a/inventory/targets/kafka.yml b/inventory/targets/kafka.yml index 7aea55f..06c360e 100644 --- a/inventory/targets/kafka.yml +++ b/inventory/targets/kafka.yml @@ -60,7 +60,7 @@ parameters: strimzi_uninstall \${ns} kafka_helm_install: | - helm upgrade --install --namespace ${kafka_k8s_namespace} ${kafka_cluster_name} ${kapitan_root}/files/helm-charts/strimzi-kafka-operator + helm upgrade --install --create-namespace --namespace ${kafka_k8s_namespace} ${kafka_cluster_name} ${kapitan_root}/files/helm-charts/strimzi-kafka-operator kafka_helm_deinstall: helm uninstall --namespace ${kafka_k8s_namespace} ${kafka_cluster_name} diff --git a/jsonnet/tmuxinator.jsonnet b/jsonnet/tmuxinator.jsonnet index 850f078..a3dc02a 100644 --- a/jsonnet/tmuxinator.jsonnet +++ b/jsonnet/tmuxinator.jsonnet @@ -9,20 +9,34 @@ local pre = [ local arrayIf(arr, condition) = if condition then arr else []; + +// +//std.join("\n", [std.join("\n", nestedArray) for nestedArray in pre]) +local generate_pre(pre) = + if std.type(pre) == "array" then + if std.type(pre[0]) == "array" then + std.join("\n", [std.join("\n", nestedArray) for nestedArray in pre]) + else + std.join("\n", pre) + else if std.type(pre) == "string" then + pre + else + "XXX"; + + + { "tmuxinator": { name: p.target_name, root: p.compiled_dir, - windows: [ - { - [window_name]: { - pre: [ - "source " + p.compiled_dir + "/functions.bash" - ] + arrayIf(p.tmuxinator.windows[window_name].pre, std.objectHas(p.tmuxinator.windows[window_name], "pre")), - panes: p.tmuxinator.windows[window_name].panes, - } - } for window_name in std.objectFieldsAll(p.tmuxinator.windows) - ] + windows: if std.objectHas(p.tmuxinator, "windows") then [ + { + [window_name]: { + pre: "source " + p.compiled_dir + "/functions.bash\n" + if std.objectHas(p.tmuxinator.windows[window_name], "pre") then generate_pre(p.tmuxinator.windows[window_name]["pre"]) else "YY", + panes: p.tmuxinator.windows[window_name].panes + } + } for window_name in std.objectFieldsAll(p.tmuxinator.windows) + ] else [] } } diff --git a/templates/neomodel/Dockerfile b/templates/neomodel/Dockerfile new file mode 100644 index 0000000..acbd901 --- /dev/null +++ b/templates/neomodel/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:latest +RUN apk add --update \ + py3-pip \ + graphviz-dev \ + alpine-sdk +ADD . /processing/ +WORKDIR /processing +RUN pip3 install -r ./requirements.txt +ENTRYPOINT [ "python3", "/processing/processing.py" ] + diff --git a/templates/neomodel/Makefile b/templates/neomodel/Makefile new file mode 100644 index 0000000..053dbd3 --- /dev/null +++ b/templates/neomodel/Makefile @@ -0,0 +1,13 @@ +IMAGE_REPO := {{ processing_name }} +IMAGE_TAG := latest +IMAGE_NAME := $(IMAGE_REPO):$(IMAGE_TAG) + +build: + docker build -t $(IMAGE_NAME) . +run: build + $(eval NEO4J_PORT := $(shell kubectl get svc neo4j-admin -n neo4j -o jsonpath='{.spec.ports[?(@.name=="tcp-bolt")].nodePort}')) + $(eval NEO4J_HOST := $(shell minikube ip)) + $(eval NEO4J_URL := bolt://$(NEO4J_HOST):$(NEO4J_PORT)) + docker run --rm -it --network=host \ + -e NEO4J_URL="$(NEO4J_URL)" \ + $(IMAGE_NAME) diff --git a/templates/neomodel/classes.py b/templates/neomodel/classes.py new file mode 100644 index 0000000..de2c818 --- /dev/null +++ b/templates/neomodel/classes.py @@ -0,0 +1,12 @@ +{% set p = inventory.parameters %} +{% for class_name, class_data in p.knowledge_graph.items() %} +# {{ class_name }} +class {{ class_name }}(StructuredNode): +{% for property_name, property in class_data.items() %} + {{ property_name -}} = +{%- if "type" in property and property.type|lower == "string" %}StringProperty() +{% elif "rel_to" in property %} +RelationshipTo('{{ property.rel_to.class }}', '{{ property.rel_to.type }}') +{% endif %} +{% endfor %} +{% endfor %} diff --git a/templates/neomodel/processing.py b/templates/neomodel/processing.py new file mode 100644 index 0000000..4e8afb2 --- /dev/null +++ b/templates/neomodel/processing.py @@ -0,0 +1,47 @@ +{% set p = inventory.parameters %} +import pika +import pprint +import json +import os +from neomodel import config +from neo4j import GraphDatabase + +from neomodel import (config, StructuredNode, StringProperty, IntegerProperty, + UniqueIdProperty, RelationshipTo, One) + +rabbitmq_url = os.getenv("RABBITMQ_URL") +neo4j_url = os.getenv("NEO4J_URL") +neo4j_username = os.getenv("NEO4J_USERNAME") +neo4j_password = os.getenv("NEO4J_PASSWORD") + +config.DRIVER = GraphDatabase().driver(neo4j_url, auth=(neo4j_username, neo4j_password)) + +connection = pika.BlockingConnection(pika.URLParameters(rabbitmq_url)) +rabbitmq_channel = connection.channel() + +exchange_name = "io-context" +result = rabbitmq_channel.queue_declare(queue="", exclusive=True) +queue_name = result.method.queue + +rabbitmq_channel.queue_bind(exchange=exchange_name, queue=queue_name) + +{% for class_name, class_data in p.knowledge_graph.items() %} +# {{ class_name }} +class {{ class_name }}(StructuredNode): +{% for property_name, property in class_data.items() %} + {{ property_name -}} = +{%- if "type" in property and property.type|lower == "string" %}StringProperty() +{% elif "rel_to" in property %} +RelationshipTo('{{ property.rel_to.class }}', '{{ property.rel_to.type }}') +{% endif %} +{% endfor %} +{% endfor %} + +def callback(ch, method, properties, body): + {{ processing.code | indent(4) }} + +rabbitmq_channel.basic_consume(queue=queue_name, on_message_callback=callback, auto_ack=True) +print("Waiting for messages. To exit, press Ctrl+C") +rabbitmq_channel.start_consuming() + + diff --git a/templates/neomodel/requirements.txt b/templates/neomodel/requirements.txt new file mode 100644 index 0000000..9b5803b --- /dev/null +++ b/templates/neomodel/requirements.txt @@ -0,0 +1,4 @@ +{% for requirement in processing.requirements %} +{{ requirement }} +{% endfor %} +