summaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/acme-planner/classpath.txt90
-rw-r--r--module/acme-planner/pom.xml38
-rw-r--r--module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudBalance.java48
-rw-r--r--module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudBalancingEasyScoreCalculator.java45
-rw-r--r--module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudComputer.java16
-rw-r--r--module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudPlaningMain.java52
-rw-r--r--module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudPlanner.java22
-rw-r--r--module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudProcess.java48
-rw-r--r--module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudProcessDifficultyComparator.java15
-rw-r--r--module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/ScalewayInstance.java25
-rw-r--r--module/acme-planner/src/main/resources/io/trygvis/acme/planning/machine/solver-config.xml18
-rw-r--r--module/acme/classpath.txt29
-rw-r--r--module/acme/pom.xml29
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/AcmeAppsMain.java14
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/VpnMain.java21
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/apps/AcmeMyApp.java6
-rw-r--r--module/acme/src/main/java/io/trygvis/acme/apps/AcmeOps.java4
-rw-r--r--module/acme/src/main/resources/META-INF/kmodule.xml17
-rw-r--r--module/acme/src/main/resources/io/trygvis/acme/acme.drl81
-rw-r--r--module/acme/src/main/resources/io/trygvis/acme/apps/apps.drl44
-rw-r--r--module/ri-base/classpath.txt27
-rw-r--r--module/ri-base/pom.xml32
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/core/Problem.java11
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/dba/Cluster.java15
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/dba/Container.java59
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/dns/DnsEntry.java27
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/dns/DnsEntryTerraformExpression.java21
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/dns/DnsZone.java9
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/engine/KeyValue.java14
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/machine/Machine.java29
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/machine/MachineSpecification.java21
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/network/IpCalc.java6
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/network/Ipv4Address.java58
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java150
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformInputVariable.java41
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformMain.java21
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformProvider.java22
-rw-r--r--module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformResource.java213
-rw-r--r--module/ri-base/src/main/resources/META-INF/kmodule.xml12
-rw-r--r--module/ri-base/src/main/resources/io/trygvis/rules/dba/dba.drl69
-rw-r--r--module/ri-base/src/main/resources/io/trygvis/rules/engine/init.drl17
-rw-r--r--module/ri-base/src/main/resources/io/trygvis/rules/machine/machine.drl1
-rw-r--r--module/ri-base/src/main/resources/io/trygvis/rules/scaleway/terraform.drl81
-rw-r--r--module/ri-base/src/main/resources/io/trygvis/rules/terraform/terraform-resources.drl28
-rw-r--r--module/ri-base/src/main/resources/templates/dba/cluster.j219
-rw-r--r--module/ri-base/src/main/resources/templates/platform-ansible.j26
-rw-r--r--module/ri-base/src/main/resources/templates/terraform/machine-outputs.j27
-rw-r--r--module/ri-base/src/main/resources/templates/terraform/machine.j219
-rw-r--r--module/ri-base/src/main/resources/templates/terraform/main-scaleway-machine.j219
-rw-r--r--module/ri-base/src/main/resources/templates/terraform/main.j210
-rw-r--r--module/ri-base/src/main/resources/templates/terraform/record-set.j28
-rw-r--r--module/ri-base/src/main/resources/templates/terraform/resource.j21
-rw-r--r--module/ri-base/src/main/resources/templates/terraform/variables.j210
-rw-r--r--module/ri-base/src/test/java/io/trygvis/rules/network/Ipv4CidrTest.txt37
-rw-r--r--module/ri-engine/classpath.txt62
-rw-r--r--module/ri-engine/pom.xml191
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/DbIo.java365
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/DbObject.java16
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java172
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/JinjavaTemplateEngine.java51
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/Main.java21
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/TemplateLoader.java7
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/DatabaseCommand.java20
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/EngineFile.java18
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/NinjaCommand.java156
-rw-r--r--module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java82
-rw-r--r--module/ri-engine/src/test/java/io/trygvis/rules/engine/AcmeAppsTestMain.java19
-rw-r--r--module/ri-engine/src/test/java/io/trygvis/rules/engine/AcmeWireguardTestMain.java27
-rw-r--r--module/ri-engine/src/test/java/io/trygvis/rules/engine/NinjaTestMain.java16
-rw-r--r--module/ri-module-api/classpath.txt23
-rw-r--r--module/ri-module-api/pom.xml16
-rw-r--r--module/ri-module-api/src/main/java/io/trygvis/rules/engine/TemplateEngine.java10
-rw-r--r--module/ri-module-parent/classpath.txt23
-rw-r--r--module/ri-module-parent/pom.xml128
-rw-r--r--module/ri-wireguard/classpath.txt28
-rw-r--r--module/ri-wireguard/pom.xml25
-rw-r--r--module/ri-wireguard/src/main/resources/META-INF/kmodule.xml9
-rw-r--r--module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl185
-rw-r--r--module/ri-wireguard/src/main/resources/logback.xml13
-rw-r--r--module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j212
-rw-r--r--module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j27
-rw-r--r--module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j213
82 files changed, 0 insertions, 3497 deletions
diff --git a/module/acme-planner/classpath.txt b/module/acme-planner/classpath.txt
deleted file mode 100644
index 411ee43..0000000
--- a/module/acme-planner/classpath.txt
+++ /dev/null
@@ -1,90 +0,0 @@
-io.trygvis.rules-sandbox:acme-planner:1.0-SNAPSHOT:jar
-ch.obermuhlner:big-math:2.0.0:jar
-ch.qos.logback:logback-classic:1.2.3:jar
-ch.qos.logback:logback-core:1.2.3:jar
-com.fasterxml.jackson.core:jackson-annotations:2.12.0:jar
-com.fasterxml.jackson.core:jackson-core:2.12.0:jar
-com.fasterxml.jackson.core:jackson-databind:2.12.0:jar
-com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.0:jar
-com.github.javaparser:javaparser-core:3.13.10:jar
-com.github.virtuald:curvesapi:1.06:jar
-com.google.code.findbugs:annotations:3.0.1:jar
-com.google.errorprone:error_prone_annotations:2.1.3:jar
-com.google.guava:guava:25.0-jre:jar
-com.google.j2objc:j2objc-annotations:1.1:jar
-com.google.re2j:re2j:1.2:jar
-com.googlecode.java-ipv6:java-ipv6:0.17:jar
-com.hubspot.jinjava:jinjava:2.5.6:jar
-com.sun.activation:jakarta.activation:1.2.2:jar
-com.sun.istack:istack-commons-runtime:3.0.8:jar
-com.thoughtworks.xstream:xstream:1.4.14:jar
-com.zaxxer:SparseBitSet:1.2:jar
-commons-codec:commons-codec:1.14:jar
-commons-io:commons-io:2.8.0:jar
-commons-net:commons-net:3.3:jar
-info.picocli:picocli:4.6.1:jar
-io.trygvis.rules-sandbox:ri-engine:1.0-SNAPSHOT:jar
-io.trygvis.rules-sandbox.module:ri-module-api:1.0-SNAPSHOT:jar
-jakarta.activation:jakarta.activation-api:1.2.2:jar
-jakarta.xml.bind:jakarta.xml.bind-api:2.3.3:jar
-org.antlr:antlr-runtime:3.5.2:jar
-org.apache.commons:commons-collections4:4.4:jar
-org.apache.commons:commons-compress:1.19:jar
-org.apache.commons:commons-lang3:3.10:jar
-org.apache.commons:commons-math3:3.4.1:jar
-org.apache.poi:poi:4.1.2:jar
-org.apache.poi:poi-ooxml:4.1.2:jar
-org.apache.poi:poi-ooxml-schemas:4.1.2:jar
-org.apache.xmlbeans:xmlbeans:3.1.0:jar
-org.checkerframework:checker-compat-qual:2.0.0:jar
-org.codehaus.mojo:animal-sniffer-annotations:1.14:jar
-org.drools:drools-canonical-model:7.48.0.Final:jar
-org.drools:drools-compiler:7.48.0.Final:jar
-org.drools:drools-core:7.48.0.Final:jar
-org.drools:drools-core-dynamic:7.48.0.Final:jar
-org.drools:drools-core-reflective:7.48.0.Final:jar
-org.drools:drools-decisiontables:7.48.0.Final:jar
-org.drools:drools-ecj:7.48.0.Final:jar
-org.drools:drools-model-compiler:7.48.0.Final:jar
-org.drools:drools-mvel:7.48.0.Final:jar
-org.drools:drools-mvel-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-parser:7.48.0.Final:jar
-org.drools:drools-templates:7.48.0.Final:jar
-org.glassfish.jaxb:jaxb-runtime:2.3.3:jar
-org.glassfish.jaxb:txw2:2.3.3:jar
-org.javassist:javassist:3.24.1-GA:jar
-org.jsoup:jsoup:1.10.3:jar
-org.kie:kie-api:7.48.0.Final:jar
-org.kie:kie-internal:7.48.0.Final:jar
-org.kie:kie-memory-compiler:7.48.0.Final:jar
-org.kie.kogito:drools-compiler:1.1.0.Final:jar
-org.kie.kogito:drools-core:1.1.0.Final:jar
-org.kie.kogito:drools-core-dynamic:1.1.0.Final:jar
-org.kie.kogito:drools-core-static:1.1.0.Final:jar
-org.kie.kogito:kogito-api:1.1.0.Final:jar
-org.kie.kogito:kogito-drools-model:1.1.0.Final:jar
-org.kie.kogito:kogito-internal:1.1.0.Final:jar
-org.kie.kogito:kogito-services:1.1.0.Final:jar
-org.kie.soup:kie-soup-commons:7.48.0.Final:jar
-org.kie.soup:kie-soup-maven-support:7.48.0.Final:jar
-org.kie.soup:kie-soup-project-datamodel-api:7.48.0.Final:jar
-org.kie.soup:kie-soup-project-datamodel-commons:7.48.0.Final:jar
-org.kie.soup:kie-soup-xstream:7.48.0.Final:jar
-org.mvel:mvel2:2.4.11.Final:jar
-org.optaplanner:optaplanner-core:8.1.0.Final:jar
-org.optaplanner:optaplanner-persistence-common:8.1.0.Final:jar
-org.optaplanner:optaplanner-persistence-jackson:8.1.0.Final:jar
-org.optaplanner:optaplanner-spring-boot-autoconfigure:8.1.0.Final:jar
-org.optaplanner:optaplanner-spring-boot-starter:8.1.0.Final:jar
-org.slf4j:slf4j-api:1.7.30:jar
-org.springframework:spring-aop:5.2.7.RELEASE:jar
-org.springframework:spring-beans:5.2.7.RELEASE:jar
-org.springframework:spring-context:5.2.7.RELEASE:jar
-org.springframework:spring-core:5.2.7.RELEASE:jar
-org.springframework:spring-expression:5.2.7.RELEASE:jar
-org.springframework:spring-jcl:5.2.7.RELEASE:jar
-org.springframework.boot:spring-boot:2.3.1.RELEASE:jar
-org.springframework.boot:spring-boot-autoconfigure:2.3.1.RELEASE:jar
-org.yaml:snakeyaml:1.26:jar
-xmlpull:xmlpull:1.1.3.1:jar
-xpp3:xpp3_min:1.1.4c:jar
diff --git a/module/acme-planner/pom.xml b/module/acme-planner/pom.xml
deleted file mode 100644
index ed8699d..0000000
--- a/module/acme-planner/pom.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>io.trygvis.rules-sandbox</groupId>
- <artifactId>rules-sandbox</artifactId>
- <version>1.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <artifactId>acme-planner</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.optaplanner</groupId>
- <artifactId>optaplanner-spring-boot-starter</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ri-engine</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.optaplanner</groupId>
- <artifactId>optaplanner-spring-boot-starter</artifactId>
- <version>8.1.0.Final</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
-</project>
diff --git a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudBalance.java b/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudBalance.java
deleted file mode 100644
index 7311918..0000000
--- a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudBalance.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package io.trygvis.acme.planning.machine;
-
-import org.optaplanner.core.api.domain.solution.PlanningEntityCollectionProperty;
-import org.optaplanner.core.api.domain.solution.PlanningScore;
-import org.optaplanner.core.api.domain.solution.PlanningSolution;
-import org.optaplanner.core.api.domain.solution.ProblemFactCollectionProperty;
-import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider;
-import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;
-
-import java.util.List;
-
-@PlanningSolution
-public class CloudBalance {
-
- private List<CloudComputer> computerList;
-
- private List<CloudProcess> processList;
-
- private HardSoftScore score;
-
- public CloudBalance(List<CloudComputer> computerList, List<CloudProcess> processList) {
- this.computerList = computerList;
- this.processList = processList;
- }
-
- public CloudBalance() {
- }
-
- @ValueRangeProvider(id = "computerRange")
- @ProblemFactCollectionProperty
- public List<CloudComputer> getComputerList() {
- return computerList;
- }
-
- @PlanningEntityCollectionProperty
- public List<CloudProcess> getProcessList() {
- return processList;
- }
-
- @PlanningScore
- public HardSoftScore getScore() {
- return score;
- }
-
- public void setScore(HardSoftScore score) {
- this.score = score;
- }
-}
diff --git a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudBalancingEasyScoreCalculator.java b/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudBalancingEasyScoreCalculator.java
deleted file mode 100644
index 6a14372..0000000
--- a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudBalancingEasyScoreCalculator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package io.trygvis.acme.planning.machine;
-
-import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;
-import org.optaplanner.core.api.score.calculator.EasyScoreCalculator;
-
-public class CloudBalancingEasyScoreCalculator implements EasyScoreCalculator<CloudBalance, HardSoftScore> {
-
- @Override
- public HardSoftScore calculateScore(CloudBalance cloudBalance) {
- int hardScore = 0;
- int softScore = 0;
- for (CloudComputer computer : cloudBalance.getComputerList()) {
- int cpu = 0;
- int memory = 0;
- boolean used = false;
-
- // Calculate usage
- for (CloudProcess process : cloudBalance.getProcessList()) {
- if (computer.equals(process.computer)) {
- cpu += process.requiredCpu;
- memory += process.requiredMemory;
- used = true;
- }
- }
-
- var instance = computer.instance;
-
- // Hard constraints
- int cpuPowerAvailable = instance.cpu - cpu;
- if (cpuPowerAvailable < 0) {
- hardScore += cpuPowerAvailable;
- }
- int memoryAvailable = instance.memory - memory;
- if (memoryAvailable < 0) {
- hardScore += memoryAvailable;
- }
-
- // Soft constraints
- if (used) {
- softScore -= instance.cost;
- }
- }
- return HardSoftScore.of(hardScore, softScore);
- }
-}
diff --git a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudComputer.java b/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudComputer.java
deleted file mode 100644
index aa2087d..0000000
--- a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudComputer.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.trygvis.acme.planning.machine;
-
-public class CloudComputer {
- public final String host;
- public final ScalewayInstance instance;
-
- public CloudComputer(String host, ScalewayInstance instance) {
- this.host = host;
- this.instance = instance;
- }
-
- @Override
- public String toString() {
- return host;
- }
-}
diff --git a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudPlaningMain.java b/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudPlaningMain.java
deleted file mode 100644
index 60b3fd3..0000000
--- a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudPlaningMain.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package io.trygvis.acme.planning.machine;
-
-import org.optaplanner.core.api.solver.SolverFactory;
-
-import java.util.ArrayList;
-
-public class CloudPlaningMain {
- public static final ScalewayInstance Stardust1_s = new ScalewayInstance("Stardust1-s", 0.0025, 1000, 1000);
- public static final ScalewayInstance DEV1_S = new ScalewayInstance("DEV1-S", 0.01, 2000, 2000);
- public static final ScalewayInstance DEV1_M = new ScalewayInstance("DEV1-M", 0.02, 3000, 4000);
- public static final ScalewayInstance DEV1_L = new ScalewayInstance("DEV1-L", 0.04, 4000, 8000);
- public static final ScalewayInstance DEV1_XL = new ScalewayInstance("DEV1-XL", 0.06, 4000, 12000);
-
- public static void main(String[] args) {
- var solverFactory = SolverFactory.<CloudBalance>createFromXmlResource("io/trygvis/acme/planning/machine/solver-config.xml");
- var solver = solverFactory.buildSolver();
-
- var computers = new ArrayList<CloudComputer>();
-
- computers.add(new CloudComputer("acme-1", DEV1_S));
- computers.add(new CloudComputer("acme-2", DEV1_M));
- computers.add(new CloudComputer("acme-3", DEV1_S));
-
- var processes = new ArrayList<CloudProcess>();
-
- processes.add(new CloudProcess("statera", 200, 1000));
- processes.add(new CloudProcess("statera-console", 100, 50));
- processes.add(new CloudProcess("4tune-web", 100, 50));
- processes.add(new CloudProcess("4tune-api", 200, 200));
- processes.add(new CloudProcess("pdb", 500, 500));
- processes.add(new CloudProcess("mdb", 500, 200));
-
- var unsolvedCloudBalance = new CloudBalance(computers, processes);
-
- var solvedCloudBalance = solver.solve(unsolvedCloudBalance);
-
- System.out.println("solvedCloudBalance.getScore() = " + solvedCloudBalance.getScore());
- for (CloudProcess process : solvedCloudBalance.getProcessList()) {
- System.out.println("process.id = " + process.id);
- if (process.computer == null) {
- System.out.println("COMPUTER IS NULL");
- } else {
- System.out.println("process.computer.host = " + process.computer.host);
- }
- }
-
- System.out.println("------------------------------------------------------------------------");
-
-// System.out.println("\nSolved cloudBalance with 400 computers and 1200 processes:\n"
-// + toDisplayString(solvedCloudBalance));
- }
-}
diff --git a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudPlanner.java b/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudPlanner.java
deleted file mode 100644
index c629656..0000000
--- a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudPlanner.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package io.trygvis.acme.planning.machine;
-
-import org.optaplanner.core.api.domain.entity.PlanningEntity;
-import org.optaplanner.core.api.domain.variable.PlanningVariable;
-
-@PlanningEntity()
-public class CloudPlanner {
- private int requiredCpuPower;
- private int requiredMemory;
- private int requiredNetworkBandwidth;
-
- private CloudComputer computer;
-
- @PlanningVariable(valueRangeProviderRefs = {"computerRange"})
- public CloudComputer getComputer() {
- return computer;
- }
-
- public void setComputer(CloudComputer computer) {
- this.computer = computer;
- }
-}
diff --git a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudProcess.java b/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudProcess.java
deleted file mode 100644
index 2002903..0000000
--- a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudProcess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package io.trygvis.acme.planning.machine;
-
-import org.apache.commons.lang3.builder.CompareToBuilder;
-import org.optaplanner.core.api.domain.entity.PlanningEntity;
-import org.optaplanner.core.api.domain.variable.PlanningVariable;
-
-import java.util.Comparator;
-
-@PlanningEntity(difficultyComparatorClass = CloudProcessDifficultyComparator.class)
-public class CloudProcess {
- public String id;
- public int requiredCpu;
- public int requiredMemory;
- public int requiredMultiplicand;
-
- @PlanningVariable(
- valueRangeProviderRefs = "computerRange",
- strengthComparatorClass = CloudComputerStrengthComparator.class)
- public CloudComputer computer;
-
- public CloudProcess(String id, int requiredCpu, int requiredMemory) {
- this.id = id;
- this.requiredCpu = requiredCpu;
- this.requiredMemory = requiredMemory;
-
- this.requiredMultiplicand = requiredCpu * requiredMemory;
- }
-
- @SuppressWarnings("unused")
- public CloudProcess() {
- }
-
- public String toString() {
- return id;
- }
-
- public static class CloudComputerStrengthComparator implements Comparator<CloudComputer> {
- public int compare(CloudComputer a, CloudComputer b) {
- var x = a.instance;
- var y = b.instance;
- return new CompareToBuilder()
- .append(x.multiplicand, y.multiplicand)
- .append(y.cost, x.cost) // Descending (but this is debatable)
- .append(x.kind, y.kind)
- .toComparison();
- }
- }
-}
diff --git a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudProcessDifficultyComparator.java b/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudProcessDifficultyComparator.java
deleted file mode 100644
index 658e826..0000000
--- a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/CloudProcessDifficultyComparator.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.trygvis.acme.planning.machine;
-
-import org.apache.commons.lang3.builder.CompareToBuilder;
-
-import java.util.Comparator;
-
-public class CloudProcessDifficultyComparator implements Comparator<CloudProcess> {
-
- public int compare(CloudProcess a, CloudProcess b) {
- return new CompareToBuilder()
- .append(a.requiredMultiplicand, b.requiredMultiplicand)
- .append(a.id, b.id)
- .toComparison();
- }
-}
diff --git a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/ScalewayInstance.java b/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/ScalewayInstance.java
deleted file mode 100644
index dfdc0e0..0000000
--- a/module/acme-planner/src/main/java/io/trygvis/acme/planning/machine/ScalewayInstance.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package io.trygvis.acme.planning.machine;
-
-public class ScalewayInstance {
- public final String kind;
- // Euros / hour
- public final double cost;
- public final int cpu;
- public final int memory;
-
- public int multiplicand;
-
- public ScalewayInstance(String kind, double cost, int cpu, int memory) {
- this.kind = kind;
- this.cost = cost;
- this.cpu = cpu;
- this.memory = memory;
-
- this.multiplicand = cpu * memory;
- }
-
- @Override
- public String toString() {
- return kind;
- }
-}
diff --git a/module/acme-planner/src/main/resources/io/trygvis/acme/planning/machine/solver-config.xml b/module/acme-planner/src/main/resources/io/trygvis/acme/planning/machine/solver-config.xml
deleted file mode 100644
index 81ae8ed..0000000
--- a/module/acme-planner/src/main/resources/io/trygvis/acme/planning/machine/solver-config.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<solver xmlns="https://www.optaplanner.org/xsd/solver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="https://www.optaplanner.org/xsd/solver https://www.optaplanner.org/xsd/solver/solver.xsd">
- <!-- Domain model configuration -->
- <solutionClass>io.trygvis.acme.planning.machine.CloudBalance</solutionClass>
- <entityClass>io.trygvis.acme.planning.machine.CloudProcess</entityClass>
-
- <!-- Score configuration -->
- <scoreDirectorFactory>
- <easyScoreCalculatorClass>io.trygvis.acme.planning.machine.CloudBalancingEasyScoreCalculator</easyScoreCalculatorClass>
- <!--<scoreDrl>org/optaplanner/examples/cloudbalancing/solver/cloudBalancingConstraints.drl</scoreDrl>-->
- </scoreDirectorFactory>
-
- <!-- Optimization algorithms configuration -->
- <termination>
- <secondsSpentLimit>3</secondsSpentLimit>
- </termination>
-</solver>
diff --git a/module/acme/classpath.txt b/module/acme/classpath.txt
deleted file mode 100644
index e544c09..0000000
--- a/module/acme/classpath.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-io.trygvis.rules-sandbox.module:acme:1.0-SNAPSHOT:jar
-com.fasterxml.jackson.core:jackson-annotations:2.12.0:jar
-com.fasterxml.jackson.core:jackson-core:2.12.0:jar
-com.fasterxml.jackson.core:jackson-databind:2.12.0:jar
-com.github.javaparser:javaparser-core:3.13.10:jar
-com.thoughtworks.xstream:xstream:1.4.14:jar
-commons-codec:commons-codec:1.14:jar
-commons-io:commons-io:2.8.0:jar
-io.trygvis.rules-sandbox.module:ri-base:1.0-SNAPSHOT:jar
-io.trygvis.rules-sandbox.module:ri-module-api:1.0-SNAPSHOT:jar
-io.trygvis.rules-sandbox.module:ri-wireguard:1.0-SNAPSHOT:jar
-org.antlr:antlr-runtime:3.5.2:jar
-org.drools:drools-canonical-model:7.48.0.Final:jar
-org.drools:drools-compiler:7.48.0.Final:jar
-org.drools:drools-core:7.48.0.Final:jar
-org.drools:drools-core-dynamic:7.48.0.Final:jar
-org.drools:drools-core-reflective:7.48.0.Final:jar
-org.drools:drools-ecj:7.48.0.Final:jar
-org.drools:drools-model-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-parser:7.48.0.Final:jar
-org.kie:kie-api:7.48.0.Final:jar
-org.kie:kie-internal:7.48.0.Final:jar
-org.kie:kie-memory-compiler:7.48.0.Final:jar
-org.kie.soup:kie-soup-maven-support:7.48.0.Final:jar
-org.kie.soup:kie-soup-xstream:7.48.0.Final:jar
-org.slf4j:slf4j-api:1.7.30:jar
-xmlpull:xmlpull:1.1.3.1:jar
-xpp3:xpp3_min:1.1.4c:jar
diff --git a/module/acme/pom.xml b/module/acme/pom.xml
deleted file mode 100644
index 3081602..0000000
--- a/module/acme/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>io.trygvis.rules-sandbox.module</groupId>
- <artifactId>ri-module-parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <relativePath>../ri-module-parent/pom.xml</relativePath>
- </parent>
-
- <artifactId>acme</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ri-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ri-wireguard</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/module/acme/src/main/java/io/trygvis/acme/AcmeAppsMain.java b/module/acme/src/main/java/io/trygvis/acme/AcmeAppsMain.java
deleted file mode 100644
index c65a3b2..0000000
--- a/module/acme/src/main/java/io/trygvis/acme/AcmeAppsMain.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package io.trygvis.acme;
-
-public class AcmeAppsMain {
-// public static void main(String[] args) throws IOException {
-// try (var engine = new Engine(
-// "acme-apps",
-// new File("acme.yaml"),
-// new File("acme-apps"),
-// new String[]{"init", "generate"},
-// new File[0])) {
-// engine.io.dump(new File("out", "acme/apps.yaml"), engine.session.getFactHandles());
-// }
-// }
-}
diff --git a/module/acme/src/main/java/io/trygvis/acme/VpnMain.java b/module/acme/src/main/java/io/trygvis/acme/VpnMain.java
deleted file mode 100644
index cbf962c..0000000
--- a/module/acme/src/main/java/io/trygvis/acme/VpnMain.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package io.trygvis.acme;
-
-public class VpnMain {
-// public static void main(String[] args) throws IOException {
-// try (var engine = new Engine(
-// "acme-wireguard",
-// new File("acme.yaml"),
-// new File("acme-wireguard"),
-// new String[]{"init", "generate"},
-// new File[0])) {
-// var outputFile = new File("out", "acme/wireguard.yaml");
-// engine.io.dump(outputFile, engine.session.getFactHandles(), (Object o) ->
-// o.getClass().getName().contains("Wg")
-// || o instanceof Machine
-// || o instanceof DnsEntry
-// || o instanceof Ipv4Cidr
-// || o instanceof Ipv4Address
-// );
-// }
-// }
-}
diff --git a/module/acme/src/main/java/io/trygvis/acme/apps/AcmeMyApp.java b/module/acme/src/main/java/io/trygvis/acme/apps/AcmeMyApp.java
deleted file mode 100644
index 9371af2..0000000
--- a/module/acme/src/main/java/io/trygvis/acme/apps/AcmeMyApp.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package io.trygvis.acme.apps;
-
-public class AcmeMyApp {
- public String environment;
- public String dockerTag;
-}
diff --git a/module/acme/src/main/java/io/trygvis/acme/apps/AcmeOps.java b/module/acme/src/main/java/io/trygvis/acme/apps/AcmeOps.java
deleted file mode 100644
index be9d82b..0000000
--- a/module/acme/src/main/java/io/trygvis/acme/apps/AcmeOps.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package io.trygvis.acme.apps;
-
-public class AcmeOps {
-}
diff --git a/module/acme/src/main/resources/META-INF/kmodule.xml b/module/acme/src/main/resources/META-INF/kmodule.xml
deleted file mode 100644
index da435d6..0000000
--- a/module/acme/src/main/resources/META-INF/kmodule.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://www.drools.org/xsd/kmodule"
- xsi:schemaLocation="http://www.drools.org/xsd/kmodule https://www.drools.org/xsd/kmodule_7_1.xsd">
-
- <kbase name="acme-apps" packages="io.trygvis.acme.apps" includes="dba,engine,machine,terraform, acme-shared">
- <ksession name="acme-apps" default="true"/>
- </kbase>
-
- <kbase name="acme-wireguard" packages="io.trygvis.acme.wireguard" includes="engine,wireguard, acme-shared">
- <ksession name="acme-wireguard" default="true"/>
- </kbase>
-
- <kbase name="acme-shared" packages="io.trygvis.acme">
- <ksession name="acme-shared" default="true"/>
- </kbase>
-</kmodule>
diff --git a/module/acme/src/main/resources/io/trygvis/acme/acme.drl b/module/acme/src/main/resources/io/trygvis/acme/acme.drl
deleted file mode 100644
index 6a2f33b..0000000
--- a/module/acme/src/main/resources/io/trygvis/acme/acme.drl
+++ /dev/null
@@ -1,81 +0,0 @@
-package io.trygvis.acme;
-
-import io.trygvis.rules.machine.Machine;
-import io.trygvis.rules.dba.Cluster;
-import io.trygvis.rules.dba.Container
-import io.trygvis.rules.terraform.TerraformResource;
-import io.trygvis.rules.terraform.TerraformMain
-import io.trygvis.rules.terraform.TerraformProvider;
-
-dialect "mvel"
-
-declare AcmeServer
- name : String
- machine : Machine
-end
-
-rule "Create Acme servers"
-when
- $m : Machine(name.startsWith("acme-"))
- not(AcmeServer(name == $m.name))
-then
- var s = new AcmeServer();
- s.name = $m.name;
- s.machine = $m;
- insert(s);
-end
-
-rule "Set public domain for ACME servers"
-when
- $m : Machine(fqdn == null)
- $s : AcmeServer(machine == $m)
-then
- var fqdn = "%s.machine.acme.com".formatted($m.name);
- modify ($m) {
- fqdn = fqdn
- }
-end
-
-rule "Make Terraform module for machines"
-when
- not TerraformMain(module == "terraform")
-then
- var module = new TerraformMain("terraform");
-
- var scaleway = new TerraformProvider("scaleway", "2.0.0-rc1");
- module.getProviders().put("scaleway", scaleway);
-
- insert(module)
-end
-
-rule "Make Scaleway Terraform resources for Machine"
-when
- $m : Machine()
- $s : AcmeServer(machine == $m)
-then
- var ip = new TerraformResource("terraform/" + $m.name + "-ip.tf", "scaleway_instance_ip", $m.name);
- var instance = new TerraformResource("terraform/" + $m.name + "-instance.tf", "scaleway_server_instance", $m.name)
- .set("name", "acme-1")
- .set("type", "DEV1-S")
- .set("image", "b3042271-d2b1-4f87-b407-aedd3bbd1663")
- .setExpression("ip_id", ip.name + ".ip")
- .set("enable_dynamic_ip", false)
- .set("enable_ipv6", true);
-
-
- var rev = new TerraformResource("terraform/" + $m.name + "-ip.tf", "scaleway_instance_reverse_dns", $m.name)
- .set("reverse", $m.fqdn + ".")
- .setExpression("ip_id", ip.name + ".id");
- var dns = new TerraformResource("terraform/" + $m.name + "-dns.tf", "google_dns_record_set", $m.name)
- .set("name", $m.fqdn)
- .setExpression("managed_zone", "var.dns_zone")
- .set("type", "A")
- .set("ttl", 300)
- .array("rrdatas")
- .addExpression(ip.name + ".id");
-
- insert(instance)
- insert(ip)
- insert(rev)
- insert(dns)
-end
diff --git a/module/acme/src/main/resources/io/trygvis/acme/apps/apps.drl b/module/acme/src/main/resources/io/trygvis/acme/apps/apps.drl
deleted file mode 100644
index 670079f..0000000
--- a/module/acme/src/main/resources/io/trygvis/acme/apps/apps.drl
+++ /dev/null
@@ -1,44 +0,0 @@
-package io.trygvis.acme.apps
-
-import io.trygvis.rules.machine.Machine;
-import io.trygvis.rules.dba.Cluster;
-import io.trygvis.rules.dba.Container
-import io.trygvis.rules.dns.DnsZone;
-import io.trygvis.rules.machine.Machine
-import io.trygvis.rules.machine.MachineSpecification
-import io.trygvis.rules.dba.Cluster
-import io.trygvis.rules.dba.Container
-
-dialect "mvel"
-
-rule "Ops"
-when
- $ops: AcmeOps()
-then
- var cluster = new Cluster("acme-ops");
- insert(cluster);
- insert(new Container(cluster, "pdb", "ops", "postgresql", "11", null));
- insert(new Container(cluster, "n8n", "ops", "n8n", "0.84.1", null));
-end
-
-rule "MyApp"
-when
- $app: AcmeMyApp()
-then
- var zone = new DnsZone($app.environment + ".acme.com");
- insert(zone)
-
- var cluster = new Cluster("acme-myapp-" + $app.environment);
- insert(cluster);
-
- var app = $app.environment + "-app";
- var db = $app.environment + "-db";
-
- var tag = $app.dockerTag;
- insert(new Container(cluster, "statera", app, "statera", tag, new MachineSpecification(200, 1000)));
- insert(new Container(cluster, "statera-console", app, "statera-console", tag, new MachineSpecification(100, 50)));
- insert(new Container(cluster, "4tune-web", app, "4tune-web", tag, new MachineSpecification(100, 50)));
- insert(new Container(cluster, "4tune-api", app, "4tune-api", tag, new MachineSpecification(200, 200)));
- insert(new Container(cluster, "pdb", db, "postgresql", "13", new MachineSpecification(500, 500)));
- insert(new Container(cluster, "mdb", db, "mongodb", "3.2", new MachineSpecification(500, 200)));
-end
diff --git a/module/ri-base/classpath.txt b/module/ri-base/classpath.txt
deleted file mode 100644
index d5370b2..0000000
--- a/module/ri-base/classpath.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-io.trygvis.rules-sandbox.module:ri-base:1.0-SNAPSHOT:kjar
-com.fasterxml.jackson.core:jackson-annotations:2.12.0:jar
-com.fasterxml.jackson.core:jackson-core:2.12.0:jar
-com.fasterxml.jackson.core:jackson-databind:2.12.0:jar
-com.github.javaparser:javaparser-core:3.13.10:jar
-com.thoughtworks.xstream:xstream:1.4.14:jar
-commons-codec:commons-codec:1.14:jar
-commons-io:commons-io:2.8.0:jar
-io.trygvis.rules-sandbox.module:ri-module-api:1.0-SNAPSHOT:jar
-org.antlr:antlr-runtime:3.5.2:jar
-org.drools:drools-canonical-model:7.48.0.Final:jar
-org.drools:drools-compiler:7.48.0.Final:jar
-org.drools:drools-core:7.48.0.Final:jar
-org.drools:drools-core-dynamic:7.48.0.Final:jar
-org.drools:drools-core-reflective:7.48.0.Final:jar
-org.drools:drools-ecj:7.48.0.Final:jar
-org.drools:drools-model-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-parser:7.48.0.Final:jar
-org.kie:kie-api:7.48.0.Final:jar
-org.kie:kie-internal:7.48.0.Final:jar
-org.kie:kie-memory-compiler:7.48.0.Final:jar
-org.kie.soup:kie-soup-maven-support:7.48.0.Final:jar
-org.kie.soup:kie-soup-xstream:7.48.0.Final:jar
-org.slf4j:slf4j-api:1.7.30:jar
-xmlpull:xmlpull:1.1.3.1:jar
-xpp3:xpp3_min:1.1.4c:jar
diff --git a/module/ri-base/pom.xml b/module/ri-base/pom.xml
deleted file mode 100644
index 119368c..0000000
--- a/module/ri-base/pom.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>io.trygvis.rules-sandbox.module</groupId>
- <artifactId>ri-module-parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <relativePath>../ri-module-parent/pom.xml</relativePath>
- </parent>
-
- <artifactId>ri-base</artifactId>
- <packaging>kjar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ri-module-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/core/Problem.java b/module/ri-base/src/main/java/io/trygvis/rules/core/Problem.java
deleted file mode 100644
index 04d1af3..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/core/Problem.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package io.trygvis.rules.core;
-
-public class Problem {
- public final String message;
- public final Object object;
-
- public Problem(String message, Object object) {
- this.message = message;
- this.object = object;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/dba/Cluster.java b/module/ri-base/src/main/java/io/trygvis/rules/dba/Cluster.java
deleted file mode 100644
index 6b23cdd..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/dba/Cluster.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.trygvis.rules.dba;
-
-import com.fasterxml.jackson.annotation.JsonIdentityInfo;
-import com.fasterxml.jackson.annotation.ObjectIdGenerators;
-
-@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name")
-public class Cluster {
- public String name;
-
- public Cluster(String name) {
- this.name = name;
- }
-
- protected Cluster() {}
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/dba/Container.java b/module/ri-base/src/main/java/io/trygvis/rules/dba/Container.java
deleted file mode 100644
index a420671..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/dba/Container.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package io.trygvis.rules.dba;
-
-import io.trygvis.rules.machine.Machine;
-import io.trygvis.rules.machine.MachineSpecification;
-
-//@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
-public class Container {
- public String id;
- public Cluster cluster;
- public String name;
- public String machineRole;
- public String image;
- public String tag;
-
- private Machine machine;
- public MachineSpecification machineSpecification;
-
- public Container(Cluster cluster, String name, String machineRole, String image, String tag,
- MachineSpecification machineSpecification) {
- this.id = cluster.name + "-" + name;
- this.cluster = cluster;
- this.name = name;
- this.machineRole = machineRole;
- this.image = image;
- this.tag = tag;
- this.machineSpecification = machineSpecification;
- }
-
- protected Container() {
- }
-
- public Cluster getCluster() {
- return cluster;
- }
-
- public String getName() {
- return name;
- }
-
- public String getMachineRole() {
- return machineRole;
- }
-
- public String getImage() {
- return image;
- }
-
- public String getTag() {
- return tag;
- }
-
- public Machine getMachine() {
- return machine;
- }
-
- public void setMachine(Machine machine) {
- this.machine = machine;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/dns/DnsEntry.java b/module/ri-base/src/main/java/io/trygvis/rules/dns/DnsEntry.java
deleted file mode 100644
index 105ef79..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/dns/DnsEntry.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package io.trygvis.rules.dns;
-
-public class DnsEntry {
- public String fqdn;
- public String type;
-
- public DnsEntry(String fqdn, String type) {
- this.fqdn = fqdn;
- this.type = type;
- }
-
- public static DnsEntry a(String fqdn) {
- return new DnsEntry(fqdn, "A");
- }
-
- public static DnsEntry aaaa(String fqdn) {
- return new DnsEntry(fqdn, "AAAA");
- }
-
- public String getFqdn() {
- return fqdn;
- }
-
- public String getType() {
- return type;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/dns/DnsEntryTerraformExpression.java b/module/ri-base/src/main/java/io/trygvis/rules/dns/DnsEntryTerraformExpression.java
deleted file mode 100644
index 79bf934..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/dns/DnsEntryTerraformExpression.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package io.trygvis.rules.dns;
-
-public class DnsEntryTerraformExpression {
- public DnsEntry entry;
- public String key;
- public String expression;
-
- public DnsEntryTerraformExpression(DnsEntry entry, String key, String expression) {
- this.entry = entry;
- this.key = key;
- this.expression = expression;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getExpression() {
- return expression;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/dns/DnsZone.java b/module/ri-base/src/main/java/io/trygvis/rules/dns/DnsZone.java
deleted file mode 100644
index 1af5c8f..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/dns/DnsZone.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package io.trygvis.rules.dns;
-
-public class DnsZone {
- public final String name;
-
- public DnsZone(String name) {
- this.name = name;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/engine/KeyValue.java b/module/ri-base/src/main/java/io/trygvis/rules/engine/KeyValue.java
deleted file mode 100644
index 5046169..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/engine/KeyValue.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package io.trygvis.rules.engine;
-
-public class KeyValue {
- public String key;
- public String value;
-
- public KeyValue() {
- }
-
- public KeyValue(String key, String value) {
- this.key = key;
- this.value = value;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/machine/Machine.java b/module/ri-base/src/main/java/io/trygvis/rules/machine/Machine.java
deleted file mode 100644
index 8f162c6..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/machine/Machine.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package io.trygvis.rules.machine;
-
-import com.fasterxml.jackson.annotation.JsonIdentityInfo;
-import com.fasterxml.jackson.annotation.ObjectIdGenerators;
-
-@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name")
-public class Machine {
- public String name;
- private String fqdn;
-
- public Machine() {
- }
-
- public Machine(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public String getFqdn() {
- return fqdn;
- }
-
- public void setFqdn(String fqdn) {
- this.fqdn = fqdn;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/machine/MachineSpecification.java b/module/ri-base/src/main/java/io/trygvis/rules/machine/MachineSpecification.java
deleted file mode 100644
index 9d38b2d..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/machine/MachineSpecification.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package io.trygvis.rules.machine;
-
-public class MachineSpecification {
- public int cpu;
- public int memory;
-
- protected MachineSpecification() {}
-
- public MachineSpecification(int cpu, int memory) {
- this.cpu = cpu;
- this.memory = memory;
- }
-
- public int getCpu() {
- return cpu;
- }
-
- public int getMemory() {
- return memory;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/network/IpCalc.java b/module/ri-base/src/main/java/io/trygvis/rules/network/IpCalc.java
deleted file mode 100644
index 7ec344c..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/network/IpCalc.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package io.trygvis.rules.network;
-
-import java.util.regex.Pattern;
-
-public class IpCalc {
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/network/Ipv4Address.java b/module/ri-base/src/main/java/io/trygvis/rules/network/Ipv4Address.java
deleted file mode 100644
index 9021198..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/network/Ipv4Address.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package io.trygvis.rules.network;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-import java.io.IOException;
-import java.util.Objects;
-
-@JsonSerialize(using = Ipv4Address.Serializer.class)
-public class Ipv4Address implements Comparable<Ipv4Address> {
- public final int address;
-
- public Ipv4Address(int address) {
- this.address = address;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
-
- if (o instanceof Ipv4Address) {
- Ipv4Address other = (Ipv4Address) o;
- return address == other.address;
- }
-
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(address);
- }
-
- @Override
- public int compareTo(Ipv4Address o) {
- return address - o.address;
- }
-
- @Override
- public String toString() {
- return "%d.%d.%d.%d".formatted(
- address >> 24 & 0xff,
- address >> 16 & 0xff,
- address >> 8 & 0xff,
- address & 0xff);
- }
-
- public static class Serializer extends JsonSerializer<Ipv4Address> {
- @Override
- public void serialize(Ipv4Address value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
- gen.writeStartObject();
- gen.writeObjectField("value", value.toString());
- gen.writeEndObject();
- }
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java b/module/ri-base/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java
deleted file mode 100644
index 851af95..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package io.trygvis.rules.network;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.regex.Pattern;
-
-@JsonSerialize(using = Ipv4Cidr.Serializer.class)
-public class Ipv4Cidr implements Comparable<Ipv4Cidr> {
- public final int network;
- public final int bits;
-
- public Ipv4Cidr(int network, int bits) {
- if (bits < 0 || bits > 32) {
- throw new IllegalArgumentException("bits must be [0, 32]");
- }
-
- int hostBits = 32 - bits;
- int netmask = (-1 >> hostBits) << hostBits;
-
- int x = network & ~netmask;
-
- if (x != 0) {
- throw new IllegalArgumentException("The host part of the address must be 0.");
- }
-
- this.network = network;
- this.bits = bits;
- }
-
- @Override
- public String toString() {
- return "%d.%d.%d.%d/%d".formatted(
- network >> 24 & 0xff,
- network >> 16 & 0xff,
- network >> 8 & 0xff,
- network & 0xff,
- bits);
- }
-
- private String formatIpv4(int address) {
- return "%d.%d.%d.%d".formatted(address >> 24 & 0xff, address >> 16 & 0xff, address >> 8 & 0xff, address & 0xff);
- }
-
- public List<Ipv4Cidr> partition(int bits) {
- if (bits <= 0 || bits <= this.bits || bits > 32) {
- throw new IllegalArgumentException("Invalid new network size");
- }
-
- var list = new ArrayList<Ipv4Cidr>();
-
- int count = 1 << (bits - this.bits);
- for (int i = 0; i < count; i++) {
- var network = this.network | (i << (32 - bits));
-
- list.add(new Ipv4Cidr(network, bits));
- }
-
- return list;
- }
-
- public List<Ipv4Address> addresses() {
- int size = 1 << 32 - bits;
- var end = network + size;
- var addresses = new ArrayList<Ipv4Address>(size);
- for (int address = network; address < end; address++) {
- addresses.add(new Ipv4Address(address));
- }
-
- return addresses;
- }
-
- @Override
- public int compareTo(Ipv4Cidr o) {
- if (this == o) {
- return 0;
- }
-
- var ret = network - o.network;
- if (ret != 0) {
- return ret;
- }
-
- return bits - o.bits;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Ipv4Cidr ipv4Cidr = (Ipv4Cidr) o;
- return network == ipv4Cidr.network && bits == ipv4Cidr.bits;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(network, bits);
- }
-
- private static final Pattern pattern = Pattern.compile("([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})/([0-9]{1,3})");
-
- public static Ipv4Cidr parseCidr(String cidr) {
- var matcher = pattern.matcher(cidr);
- if (!matcher.matches()) {
- throw new IllegalArgumentException("Not a CIDR: " + cidr);
- }
-
- var b1 = matcher.group(1);
- var b2 = matcher.group(2);
- var b3 = matcher.group(3);
- var b4 = matcher.group(4);
-
- int network = parse(b1) << 24 |
- parse(b2) << 16 |
- parse(b3) << 8 |
- parse(b4);
-
-// System.out.printf("network = %x%n", network);
-
- var l = matcher.group(5);
- var bits = Integer.parseInt(l);
-// System.out.printf("netmask = %08x%n", netmask);
-
- return new Ipv4Cidr(network, bits);
- }
-
- private static int parse(String s) {
- var i = Integer.parseInt(s);
- if (i > 255) {
- throw new IllegalArgumentException("Not a CIDR");
- }
-
- return i;
- }
-
- public static class Serializer extends JsonSerializer<Ipv4Cidr> {
- @Override
- public void serialize(Ipv4Cidr value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
- gen.writeStartObject();
- gen.writeObjectField("value", value.toString());
- gen.writeEndObject();
- }
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformInputVariable.java b/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformInputVariable.java
deleted file mode 100644
index 1415767..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformInputVariable.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package io.trygvis.rules.terraform;
-
-public class TerraformInputVariable {
- private String module;
-
- private String name;
- private String type;
- private String default_;
-
- public TerraformInputVariable(String module) {
- this.module = module;
- }
-
- public String getModule() {
- return module;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getDefault() {
- return default_;
- }
-
- public void setDefault(String default_) {
- this.default_ = default_;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformMain.java b/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformMain.java
deleted file mode 100644
index 82626d2..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformMain.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package io.trygvis.rules.terraform;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-public class TerraformMain {
- private String module;
- private Map<String, TerraformProvider> providers = new TreeMap<String, TerraformProvider>();
-
- public TerraformMain(String module) {
- this.module = module;
- }
-
- public String getModule() {
- return module;
- }
-
- public Map<String, TerraformProvider> getProviders() {
- return providers;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformProvider.java b/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformProvider.java
deleted file mode 100644
index 613d953..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformProvider.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package io.trygvis.rules.terraform;
-
-public class TerraformProvider {
- private String source;
- private String version;
-
- protected TerraformProvider() {
- }
-
- public TerraformProvider(String source, String version) {
- this.source = source;
- this.version = version;
- }
-
- public String getSource() {
- return source;
- }
-
- public String getVersion() {
- return version;
- }
-}
diff --git a/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformResource.java b/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformResource.java
deleted file mode 100644
index 351a3e1..0000000
--- a/module/ri-base/src/main/java/io/trygvis/rules/terraform/TerraformResource.java
+++ /dev/null
@@ -1,213 +0,0 @@
-package io.trygvis.rules.terraform;
-
-import com.fasterxml.jackson.annotation.JsonValue;
-
-import java.util.*;
-
-@SuppressWarnings("unused")
-public class TerraformResource {
- private static final String EOL = System.getProperty("line.separator");
- private final String output;
- private final String kind;
- private final String instance;
- private final Map<String, TerraformValue> values = new LinkedHashMap<>();
-
- public TerraformResource(String output, String kind, String instance) {
- this.output = output;
- this.kind = kind;
- this.instance = instance;
- }
-
- public String getOutput() {
- return output;
- }
-
- public String getName() {
- return kind + "." + instance;
- }
-
- public String getKind() {
- return kind;
- }
-
- public String getInstance() {
- return instance;
- }
-
- public Map<String, TerraformValue> getValues() {
- return values;
- }
-
- public TerraformResource set(String key, String value) {
- values.put(key, new StringTerraformValue(value));
- return this;
- }
-
- public TerraformResource set(String key, boolean value) {
- values.put(key, new BooleanTerraformValue(value));
- return this;
- }
-
- public TerraformResource set(String key, int value) {
- values.put(key, new IntegerTerraformValue(value));
- return this;
- }
-
- public TerraformResource setExpression(String key, String value) {
- values.put(key, new ExpressionTerraformValue(value));
- return this;
- }
-
- public ArrayTerraformValue array(String key) {
- var array = new ArrayTerraformValue();
- values.put(key, array);
- return array;
- }
-
- public String asString() {
- var buf = new StringBuilder();
-
- buf.append("resource ");
- buf.append(quote(kind));
- buf.append(" ");
- buf.append(quote(instance));
- buf.append(" {");
- buf.append(EOL);
-
- for (var entry : values.entrySet()) {
- buf.append(" ");
- buf.append(entry.getKey());
- buf.append(" = ");
- buf.append(entry.getValue().asString());
- buf.append(EOL);
- }
-
- buf.append("}");
-
- return buf.toString();
- }
-
- public interface TerraformValue {
- String asString();
- }
-
- public static class StringTerraformValue implements TerraformValue {
- private final String value;
-
- public StringTerraformValue(String value) {
- this.value = value;
- }
-
- @JsonValue
- public String getValue() {
- return value;
- }
-
- @Override
- public String asString() {
- return quote(value);
- }
- }
-
- public static class BooleanTerraformValue implements TerraformValue {
- private final boolean value;
-
- public BooleanTerraformValue(boolean value) {
- this.value = value;
- }
-
- @JsonValue
- public boolean getValue() {
- return value;
- }
-
- @Override
- public String asString() {
- return String.valueOf(value);
- }
- }
-
- public static class IntegerTerraformValue implements TerraformValue {
- private final int value;
-
- public IntegerTerraformValue(int value) {
- this.value = value;
- }
-
- @JsonValue
- public int getValue() {
- return value;
- }
-
- @Override
- public String asString() {
- return String.valueOf(value);
- }
- }
-
- public static class ExpressionTerraformValue implements TerraformValue {
- private final String value;
-
- public ExpressionTerraformValue(String value) {
- this.value = value;
- }
-
- @JsonValue
- public String getValue() {
- return value;
- }
-
- @Override
- public String asString() {
- return value;
- }
- }
-
- public static class ArrayTerraformValue implements TerraformValue {
- private final List<TerraformValue> values = new ArrayList<>();
-
- @JsonValue
- public List<TerraformValue> getValues() {
- return values;
- }
-
- public ArrayTerraformValue add(String value) {
- values.add(new StringTerraformValue(value));
- return this;
- }
-
- public ArrayTerraformValue add(int value) {
- values.add(new IntegerTerraformValue(value));
- return this;
- }
-
- public ArrayTerraformValue add(boolean value) {
- values.add(new BooleanTerraformValue(value));
- return this;
- }
-
- public ArrayTerraformValue addExpression(String value) {
- values.add(new ExpressionTerraformValue(value));
- return this;
- }
-
- @Override
- public String asString() {
- if (values.isEmpty()) {
- return "[]";
- }
-
- if (values.size() == 1) {
- return "[" + values.get(0).asString() + "]";
- }
-
- var j = new StringJoiner(",\n ", "[\n", "\n ]");
- values.forEach(value -> j.add(value.asString()));
- return j.toString();
- }
- }
-
- private static String quote(String value) {
- return "\"%s\"".formatted(value);
- }
-}
diff --git a/module/ri-base/src/main/resources/META-INF/kmodule.xml b/module/ri-base/src/main/resources/META-INF/kmodule.xml
deleted file mode 100644
index 4650977..0000000
--- a/module/ri-base/src/main/resources/META-INF/kmodule.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://www.drools.org/xsd/kmodule"
- xsi:schemaLocation="http://www.drools.org/xsd/kmodule https://www.drools.org/xsd/kmodule_7_1.xsd">
-
- <kbase name="all" packages="io.trygvis.rules.*"/>
- <kbase name="engine" packages="io.trygvis.rules.engine"/>
- <kbase name="dba" packages="io.trygvis.rules.dba"/>
- <kbase name="machine" packages="io.trygvis.rules.machine"/>
- <kbase name="terraform" packages="io.trygvis.rules.terraform"/>
- <kbase name="scaleway" packages="io.trygvis.rules.scaleway"/>
-</kmodule>
diff --git a/module/ri-base/src/main/resources/io/trygvis/rules/dba/dba.drl b/module/ri-base/src/main/resources/io/trygvis/rules/dba/dba.drl
deleted file mode 100644
index c31bc57..0000000
--- a/module/ri-base/src/main/resources/io/trygvis/rules/dba/dba.drl
+++ /dev/null
@@ -1,69 +0,0 @@
-package io.trygvis.rules.dba
-
-import io.trygvis.rules.core.Problem
-import io.trygvis.rules.machine.Machine
-import java.util.ArrayList
-import java.util.Map
-import java.util.HashMap
-import java.util.List
-import java.util.stream.Collectors
-import java.util.Collections
-
-global io.trygvis.rules.engine.TemplateEngine te;
-
-dialect "mvel"
-
-declare DbaMachineRole
- machine : String
- roles : String[]
-end
-
-rule "Assign containers to machine"
-when
- $machine : Machine()
- $machineRole : DbaMachineRole(machine == $machine.name)
- $container : Container(machine == null, $machineRole.roles contains machineRole)
-then
- System.out.println("Assigning container to machine: " + $machine.name);
- modify ($container) {
- machine = $machine
- }
-end
-
-rule "Containers without hosts"
- agenda-group "generate"
-when
- $container : Container(machine == null)
-then
- insert(new Problem("No machine for container", $container))
-end
-
-rule "Generate docker-compose.yaml"
- agenda-group "generate"
-when
- $cluster : Cluster()
- $containers : ArrayList(size > 0) from collect(Container(cluster == $cluster))
-then
- System.out.println("Docker compose for cluster: " + $cluster.name + " with " + $containers.size() + " containers");
-
- Map containersByMachine = new HashMap();
- for (Object o : $containers) {
- Container c = (Container) o;
-
- List list = (List) containersByMachine.get(c.getMachine());
- if (list == null) {
- list = new ArrayList();
- containersByMachine.put(c.getMachine(), list);
- }
- list.add(c);
- }
-
- System.out.println("containersByMachine = " + containersByMachine);
-
- String path = "ansible/dba/" + $cluster.name + ".yml";
- te.template("dba/cluster", path, Map.of(
- "cluster", $cluster,
- "containers", $containers,
- "containersByMachine", containersByMachine
- ));
-end
diff --git a/module/ri-base/src/main/resources/io/trygvis/rules/engine/init.drl b/module/ri-base/src/main/resources/io/trygvis/rules/engine/init.drl
deleted file mode 100644
index 267cc4a..0000000
--- a/module/ri-base/src/main/resources/io/trygvis/rules/engine/init.drl
+++ /dev/null
@@ -1,17 +0,0 @@
-package io.trygvis.rules.engine;
-
-import java.util.Map
-import org.apache.commons.io.FileSystem
-import org.apache.commons.io.FileUtils
-import java.io.File
-
-global io.trygvis.rules.engine.TemplateEngine te;
-
-rule "Clean directories"
- agenda-group "init"
-when
- not(KeyValue(key == "rm-gen"));
-then
- te.clean();
- insert(new KeyValue("rm-gen", null));
-end
diff --git a/module/ri-base/src/main/resources/io/trygvis/rules/machine/machine.drl b/module/ri-base/src/main/resources/io/trygvis/rules/machine/machine.drl
deleted file mode 100644
index 0250cc6..0000000
--- a/module/ri-base/src/main/resources/io/trygvis/rules/machine/machine.drl
+++ /dev/null
@@ -1 +0,0 @@
-package io.trygvis.rules.machine;
diff --git a/module/ri-base/src/main/resources/io/trygvis/rules/scaleway/terraform.drl b/module/ri-base/src/main/resources/io/trygvis/rules/scaleway/terraform.drl
deleted file mode 100644
index 7e0ff03..0000000
--- a/module/ri-base/src/main/resources/io/trygvis/rules/scaleway/terraform.drl
+++ /dev/null
@@ -1,81 +0,0 @@
-package io.trygvis.rules.scaleway
-
-import io.trygvis.rules.dba.Cluster
-import io.trygvis.rules.dba.Container
-import io.trygvis.rules.machine.Machine
-import io.trygvis.rules.dns.DnsEntry
-import io.trygvis.rules.dns.DnsEntryTerraformExpression
-import java.util.ArrayList;
-import java.util.Map;
-
-global io.trygvis.rules.engine.TemplateEngine te;
-
-dialect "mvel"
-
-declare ScalewayMachine
- machine : Machine
- key : String
-end
-
-declare GoogleManagedZoneTerraformExpression
- name : String
-end
-
-rule "Terraform for Machine"
-when
- $machine: Machine()
-then
- ScalewayMachine scw = new ScalewayMachine();
- scw.setKey($machine.name);
- scw.setMachine($machine);
-
- insert(scw);
-end
-
-rule "Create DNS entry for Terraform Machine"
-when
- $machine : Machine(fqdn != null)
- not(DnsEntry(fqdn == $machine.fqdn))
-then
- DnsEntry a = DnsEntry.a($machine.fqdn);
- insert(a);
-
- String ipv4 = "scaleway_instance_ip.%s.address".formatted($machine.name);
- insert(new DnsEntryTerraformExpression(a, $machine.name, ipv4));
-end
-
-rule "main-scaleway-machine.tf"
- agenda-group "generate"
-when
- $managedZones : ArrayList() from collect(GoogleManagedZoneTerraformExpression())
-then
- String path = "terraform/main-scaleway-machine.tf";
- te.template("terraform/main-scaleway-machine", path, Map.of(
- "managedZones", $managedZones
- ));
-end
-
-rule "TF for TerraformMachine"
- agenda-group "generate"
-when
- $m: Machine()
- $scw: ScalewayMachine(machine == $m)
-then
- String path = "terraform/scaleway-machine-%s.tf".formatted($scw.getKey());
- te.template("terraform/machine", path, Map.of("m", $m, "scw", $scw));
-end
-
-rule "Terraform for DNS"
- agenda-group "generate"
-when
- $entry: DnsEntry()
- $tf : DnsEntryTerraformExpression(entry == $entry)
- $managedZone : GoogleManagedZoneTerraformExpression()
-then
- String path = "terraform/dns-%s.tf".formatted($tf.key);
- te.template("terraform/record-set", path, Map.of(
- "entry", $entry,
- "managedZone", $managedZone,
- "tf", $tf)
- );
-end
diff --git a/module/ri-base/src/main/resources/io/trygvis/rules/terraform/terraform-resources.drl b/module/ri-base/src/main/resources/io/trygvis/rules/terraform/terraform-resources.drl
deleted file mode 100644
index 40a81f0..0000000
--- a/module/ri-base/src/main/resources/io/trygvis/rules/terraform/terraform-resources.drl
+++ /dev/null
@@ -1,28 +0,0 @@
-package io.trygvis.rules.terraform;
-
-import java.util.ArrayList
-import java.util.HashSet
-import java.util.Map
-import java.util.Set
-
-global io.trygvis.rules.engine.TemplateEngine te;
-
-dialect "mvel"
-
-rule "terraform-resources"
- agenda-group "generate"
-when
- $r : TerraformResource()
-then
- te.template("terraform/resource", $r.output, Map.of("resource", $r));
-end
-
-rule "main.tf"
- agenda-group "generate"
-when
- $main : TerraformMain()
- $variables : ArrayList() from collect(TerraformInputVariable(module == $main.module))
-then
- te.template("terraform/main", $main.module + "/main.tf", Map.of("main", $main));
- te.template("terraform/variables", $main.module + "/vars.tf", Map.of("variables", $variables));
-end
diff --git a/module/ri-base/src/main/resources/templates/dba/cluster.j2 b/module/ri-base/src/main/resources/templates/dba/cluster.j2
deleted file mode 100644
index 045fbcd..0000000
--- a/module/ri-base/src/main/resources/templates/dba/cluster.j2
+++ /dev/null
@@ -1,19 +0,0 @@
-# Generated
-
-# cluster: {{ cluster.name }}
-{%- for m, containers in containersByMachine.entrySet() %}
----
-- host:
- - {{ m.name }}
- tasks:
- import_role:
- name: docker-service
- vars:
- template: |
- version: "3"
- services:
-{%- for c in containers %}
- {{ c.name }}:
- image: {{ c.image }}:{{ c.tag }}
-{%- endfor %}
-{% endfor %}
diff --git a/module/ri-base/src/main/resources/templates/platform-ansible.j2 b/module/ri-base/src/main/resources/templates/platform-ansible.j2
deleted file mode 100644
index 72e3247..0000000
--- a/module/ri-base/src/main/resources/templates/platform-ansible.j2
+++ /dev/null
@@ -1,6 +0,0 @@
-# Ansible
-- hosts:
- - {{ m.key }}
- tasks:
- - import_role:
- name: acme-platform
diff --git a/module/ri-base/src/main/resources/templates/terraform/machine-outputs.j2 b/module/ri-base/src/main/resources/templates/terraform/machine-outputs.j2
deleted file mode 100644
index 438fac6..0000000
--- a/module/ri-base/src/main/resources/templates/terraform/machine-outputs.j2
+++ /dev/null
@@ -1,7 +0,0 @@
-output "addresses" {
- value = {
-{%- for m in machines %}
- {{ m.key }}: scaleway_instance_ip.{{ m.key }}.address,
-{%- endfor %}
- }
-}
diff --git a/module/ri-base/src/main/resources/templates/terraform/machine.j2 b/module/ri-base/src/main/resources/templates/terraform/machine.j2
deleted file mode 100644
index 0ac8b90..0000000
--- a/module/ri-base/src/main/resources/templates/terraform/machine.j2
+++ /dev/null
@@ -1,19 +0,0 @@
-resource "scaleway_instance_server" "{{ scw.key }}" {
- name = "acme-1"
- type = "DEV1-S"
- image = "b3042271-d2b1-4f87-b407-aedd3bbd1663"
- ip_id = scaleway_instance_ip.{{ scw.key }}.id
- enable_dynamic_ip = false
- enable_ipv6 = true
-}
-
-resource "scaleway_instance_ip" "{{ scw.key }}" {}
-
-resource "scaleway_instance_ip_reverse_dns" "{{ scw.key }}" {
- ip_id = scaleway_instance_ip.{{ scw.key }}.id
- reverse = "{{ m.fqdn }}."
-}
-
-output "{{scw.key}}_public_ip" {
- value = scaleway_instance_server.{{ scw.key }}.public_ip
-}
diff --git a/module/ri-base/src/main/resources/templates/terraform/main-scaleway-machine.j2 b/module/ri-base/src/main/resources/templates/terraform/main-scaleway-machine.j2
deleted file mode 100644
index eab9fac..0000000
--- a/module/ri-base/src/main/resources/templates/terraform/main-scaleway-machine.j2
+++ /dev/null
@@ -1,19 +0,0 @@
-# Generated
-
-terraform {
- required_providers {
- scaleway = {
- source = "scaleway/scaleway"
- version = "1.17.2"
- }
- }
-}
-
-provider "scaleway" {
-}
-
-{% -for z in managedZones %}
-variable "{{z.name}}" {
- type = string
-}
-{% endfor -%}
diff --git a/module/ri-base/src/main/resources/templates/terraform/main.j2 b/module/ri-base/src/main/resources/templates/terraform/main.j2
deleted file mode 100644
index 009f4ed..0000000
--- a/module/ri-base/src/main/resources/templates/terraform/main.j2
+++ /dev/null
@@ -1,10 +0,0 @@
-terraform {
- required_providers {
-{% for alias, provider in main.providers.entrySet() %}
- {{ alias }} = {
- version = "{{ provider.version }}"
- source = "{{ provider.source }}"
- }
-{%- endfor %}
- }
-}
diff --git a/module/ri-base/src/main/resources/templates/terraform/record-set.j2 b/module/ri-base/src/main/resources/templates/terraform/record-set.j2
deleted file mode 100644
index b89ee00..0000000
--- a/module/ri-base/src/main/resources/templates/terraform/record-set.j2
+++ /dev/null
@@ -1,8 +0,0 @@
-resource "google_dns_record_set" "{{ tf.key }}" {
- name = "{{ entry.fqdn }}"
- managed_zone = var.{{ managedZone.name }}
- type = "{{ entry.type }}"
- ttl = 300
-
- rrdatas = [{{ tf.expression }}]
-}
diff --git a/module/ri-base/src/main/resources/templates/terraform/resource.j2 b/module/ri-base/src/main/resources/templates/terraform/resource.j2
deleted file mode 100644
index 91af481..0000000
--- a/module/ri-base/src/main/resources/templates/terraform/resource.j2
+++ /dev/null
@@ -1 +0,0 @@
-{{ resource.asString() -}}
diff --git a/module/ri-base/src/main/resources/templates/terraform/variables.j2 b/module/ri-base/src/main/resources/templates/terraform/variables.j2
deleted file mode 100644
index 6c37d99..0000000
--- a/module/ri-base/src/main/resources/templates/terraform/variables.j2
+++ /dev/null
@@ -1,10 +0,0 @@
-{%- for var in variables %}
-variable "{{ var.name }}" {
-{%- if var.type %}
- type = {{ var.type }}
-{% endif %}
-{%- if var.default %}
- default = {{ var.default }}
-{% endif %}
-}
-{% endfor %}
diff --git a/module/ri-base/src/test/java/io/trygvis/rules/network/Ipv4CidrTest.txt b/module/ri-base/src/test/java/io/trygvis/rules/network/Ipv4CidrTest.txt
deleted file mode 100644
index 826f586..0000000
--- a/module/ri-base/src/test/java/io/trygvis/rules/network/Ipv4CidrTest.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-package io.trygvis.rules.network;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-import static io.trygvis.rules.network.Ipv4Cidr.parseCidr;
-import static org.junit.jupiter.api.Assertions.*;
-
-class Ipv4CidrTest {
-
- @Test
- public void basic() {
- Assertions.assertThrows(IllegalArgumentException.class, () -> parseCidr("192.168.1.1/24").addresses());
- assertEquals(256, parseCidr("192.168.1.0/24").addresses().size());
- assertEquals(128, parseCidr("192.168.1.128/25").addresses().size());
- }
-
- @ParameterizedTest
- @ValueSource(strings = {
- "192.168.1.0/24",
- "192.168.1.128/25",
- })
- public void testParsing(String s) {
- assertEquals(s, parseCidr(s).toString());
- }
-
- @Test
- public void partition() {
- var children = parseCidr("192.168.1.0/24").partition(26);
- assertEquals(1 << 2, children.size());
- for (var cidr : children) {
- assertEquals(26, cidr.bits);
- }
- }
-}
diff --git a/module/ri-engine/classpath.txt b/module/ri-engine/classpath.txt
deleted file mode 100644
index f01f5f8..0000000
--- a/module/ri-engine/classpath.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-io.trygvis.rules-sandbox:ri-engine:1.0-SNAPSHOT:jar
-ch.obermuhlner:big-math:2.0.0:jar
-ch.qos.logback:logback-classic:1.2.3:jar
-ch.qos.logback:logback-core:1.2.3:jar
-com.fasterxml.jackson.core:jackson-annotations:2.12.0:jar
-com.fasterxml.jackson.core:jackson-core:2.12.0:jar
-com.fasterxml.jackson.core:jackson-databind:2.12.0:jar
-com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.0:jar
-com.github.javaparser:javaparser-core:3.13.10:jar
-com.github.virtuald:curvesapi:1.06:jar
-com.google.code.findbugs:annotations:3.0.1:jar
-com.google.errorprone:error_prone_annotations:2.1.3:jar
-com.google.guava:guava:25.0-jre:jar
-com.google.j2objc:j2objc-annotations:1.1:jar
-com.google.re2j:re2j:1.2:jar
-com.googlecode.java-ipv6:java-ipv6:0.17:jar
-com.hubspot.jinjava:jinjava:2.5.6:jar
-com.thoughtworks.xstream:xstream:1.4.14:jar
-com.zaxxer:SparseBitSet:1.2:jar
-commons-codec:commons-codec:1.14:jar
-commons-io:commons-io:2.8.0:jar
-commons-net:commons-net:3.3:jar
-info.picocli:picocli:4.6.1:jar
-io.trygvis.rules-sandbox.module:ri-module-api:1.0-SNAPSHOT:jar
-org.antlr:antlr-runtime:3.5.2:jar
-org.apache.commons:commons-collections4:4.4:jar
-org.apache.commons:commons-compress:1.19:jar
-org.apache.commons:commons-lang3:3.10:jar
-org.apache.commons:commons-math3:3.6.1:jar
-org.apache.poi:poi:4.1.2:jar
-org.apache.poi:poi-ooxml:4.1.2:jar
-org.apache.poi:poi-ooxml-schemas:4.1.2:jar
-org.apache.xmlbeans:xmlbeans:3.1.0:jar
-org.checkerframework:checker-compat-qual:2.0.0:jar
-org.codehaus.mojo:animal-sniffer-annotations:1.14:jar
-org.drools:drools-canonical-model:7.48.0.Final:jar
-org.drools:drools-compiler:7.48.0.Final:jar
-org.drools:drools-core:7.48.0.Final:jar
-org.drools:drools-core-dynamic:7.48.0.Final:jar
-org.drools:drools-core-reflective:7.48.0.Final:jar
-org.drools:drools-decisiontables:7.48.0.Final:jar
-org.drools:drools-ecj:7.48.0.Final:jar
-org.drools:drools-model-compiler:7.48.0.Final:jar
-org.drools:drools-mvel:7.48.0.Final:jar
-org.drools:drools-mvel-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-parser:7.48.0.Final:jar
-org.drools:drools-templates:7.48.0.Final:jar
-org.javassist:javassist:3.24.1-GA:jar
-org.jsoup:jsoup:1.10.3:jar
-org.kie:kie-api:7.48.0.Final:jar
-org.kie:kie-internal:7.48.0.Final:jar
-org.kie:kie-memory-compiler:7.48.0.Final:jar
-org.kie.soup:kie-soup-commons:7.48.0.Final:jar
-org.kie.soup:kie-soup-maven-support:7.48.0.Final:jar
-org.kie.soup:kie-soup-project-datamodel-api:7.48.0.Final:jar
-org.kie.soup:kie-soup-project-datamodel-commons:7.48.0.Final:jar
-org.kie.soup:kie-soup-xstream:7.48.0.Final:jar
-org.mvel:mvel2:2.4.11.Final:jar
-org.slf4j:slf4j-api:1.7.30:jar
-org.yaml:snakeyaml:1.26:jar
-xmlpull:xmlpull:1.1.3.1:jar
-xpp3:xpp3_min:1.1.4c:jar
diff --git a/module/ri-engine/pom.xml b/module/ri-engine/pom.xml
deleted file mode 100644
index a2307f0..0000000
--- a/module/ri-engine/pom.xml
+++ /dev/null
@@ -1,191 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <properties>
- <main-class>io.trygvis.rules.engine.Main</main-class>
- </properties>
-
- <parent>
- <groupId>io.trygvis.rules-sandbox</groupId>
- <artifactId>rules-sandbox</artifactId>
- <version>1.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <artifactId>ri-engine</artifactId>
-
- <dependencies>
-
- <dependency>
- <groupId>${project.groupId}.module</groupId>
- <artifactId>ri-module-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>io.trygvis.rules-sandbox.module</groupId>
- <artifactId>ri-base</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.trygvis.rules-sandbox.module</groupId>
- <artifactId>ri-wireguard</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.trygvis.rules-sandbox.module</groupId>
- <artifactId>acme</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-compiler</artifactId>
- </dependency>
- <dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-decisiontables</artifactId>
- </dependency>
- <dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-templates</artifactId>
- </dependency>
-
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.jackson.dataformat</groupId>
- <artifactId>jackson-dataformat-yaml</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.hubspot.jinjava</groupId>
- <artifactId>jinjava</artifactId>
- <version>2.5.6</version>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>info.picocli</groupId>
- <artifactId>picocli</artifactId>
- <version>${version.picocli}</version>
- </dependency>
-
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <version>5.7.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-params</artifactId>
- <version>5.7.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <annotationProcessorPaths>
- <path>
- <groupId>info.picocli</groupId>
- <artifactId>picocli-codegen</artifactId>
- <version>${version.picocli}</version>
- </path>
- </annotationProcessorPaths>
- <compilerArgs combine.children="append">
- <arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
- </compilerArgs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>3.2.4</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
- <resource>META-INF/kie.conf</resource>
- </transformer>
- </transformers>
- <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>3.2.0</version>
- <configuration>
- <archive>
- <manifest>
- <mainClass>${main-class}</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
-
- <!-- TODO: attach generated script to build -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.6.0</version>
- <executions>
- <execution>
- <id>generate-autocompletion-script</id>
- <phase>package</phase>
- <goals>
- <!-- The java goal doesn't work here as maven itself would have to run with enable-preview -->
- <goal>exec</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <executable>java</executable>
- <arguments>
- <argument>-Dpicocli.autocomplete.systemExitOnError</argument>
- <argument>${java.preview}</argument>
- <argument>-cp</argument>
- <classpath/>
- <argument>picocli.AutoComplete</argument>
- <argument>--force</argument>
- <argument>--completionScript</argument>
- <argument>${project.build.directory}/engine_completion.sh</argument>
- <argument>${main-class}</argument>
- </arguments>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbIo.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbIo.java
deleted file mode 100644
index 7dc24ad..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbIo.java
+++ /dev/null
@@ -1,365 +0,0 @@
-package io.trygvis.rules.engine;
-
-import ch.qos.logback.core.util.FileUtil;
-import com.fasterxml.jackson.annotation.ObjectIdGenerators;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.PropertyName;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.introspect.Annotated;
-import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
-import com.fasterxml.jackson.databind.introspect.ObjectIdInfo;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-import org.drools.core.common.DefaultFactHandle;
-import org.drools.core.factmodel.GeneratedFact;
-import org.kie.api.KieBase;
-import org.kie.api.runtime.KieContainer;
-import org.kie.api.runtime.rule.FactHandle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-import java.util.function.Function;
-
-@SuppressWarnings("unchecked")
-public class DbIo {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
- private final ObjectMapper mapper;
-
- private static final List<String> prioritizedKeys = List.of("key", "name", "fqdn");
-
- public DbIo(KieContainer container, KieBase kieBase) {
- var factory = new YAMLFactory();
- factory.enable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID);
- factory.enable(YAMLGenerator.Feature.USE_NATIVE_OBJECT_ID);
- mapper = new ObjectMapper(factory);
- mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
- var typeFactory = TypeFactory.defaultInstance()
- .withClassLoader(new DbClassLoader(container, kieBase));
- mapper.setTypeFactory(typeFactory);
- mapper.findAndRegisterModules();
-
- mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector() {
- @Override
- public ObjectIdInfo findObjectIdInfo(Annotated a) {
- final Class<?> klass = a.getRawType();
- if (GeneratedFact.class.isAssignableFrom(klass)) {
- System.out.println("klass = " + klass);
-
- for (String name : prioritizedKeys) {
- try {
- final String getter = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
- klass.getMethod(getter);
- return new ObjectIdInfo(PropertyName.construct(name), null, ObjectIdGenerators.PropertyGenerator.class, null);
- } catch (NoSuchMethodException ignore) {
- }
- }
- System.out.println("a.getRawType() = " + klass);
- return new ObjectIdInfo(null, null, ObjectIdGenerators.IntSequenceGenerator.class, null);
- }
-
- return super.findObjectIdInfo(a);
- }
- });
- }
-
- public List<Object> load(File file) throws IOException {
- var parser = mapper.getFactory().createParser(file);
-
- var objects = parser.<List<DbObject>>readValueAs(new TypeReference<List<DbObject>>() {});
-
- var items = new ArrayList<>();
- for (DbObject object : objects) {
- try {
- var type = mapper.getTypeFactory().findClass(object.type);
- var x = mapper.treeToValue(object.data, type);
- if (x == null) {
- x = type.getDeclaredConstructor().newInstance();
- }
- items.add(x);
- } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
- System.out.println("e.getClass() = " + e.getClass().getName());
- System.out.println("e.getMessage() = " + e.getMessage());
- // ignore
- }
- }
-
- return items;
- }
-
- public void dump(File file, Collection<FactHandle> factHandles) throws IOException {
- dump(file, factHandles, (o) -> true);
- }
-
- // This should just sort by all getters instead.
- static class FactCollection<T> {
- public final Class<T> type;
- public final List<T> values;
-
- public FactCollection(Class<T> type) {
- this.type = type;
- this.values = new ArrayList<>();
- }
-
- public void sort() {
- var comparator = comparable(type);
-
- this.values.sort(comparator);
- }
- }
-
- private static final Map<Class<?>, Comparator> comparators = new HashMap<>();
-
- private static <A, T extends Comparable<T>> Comparator comparable(Class<A> klass) {
- var comparator = comparators.get(klass);
- if (comparator != null) {
- return comparator;
- }
-
- // TODO: check if klass is a Comparable directly.
-
- var discoveredFieldsP1 = new LinkedHashMap<String, Function<Object, Object>>();
- var discoveredFieldsP2 = new LinkedHashMap<String, Function<Object, Object>>();
-
- var prioritizedTypes = List.of(String.class, int.class, Number.class);
-
- for (var f : klass.getDeclaredFields()) {
- if (f.getDeclaringClass() == Object.class) {
- continue;
- }
-
- if (!f.trySetAccessible()) {
- continue;
- }
-
- var collection = discoveredFieldsP2;
-
- if (prioritizedTypes.contains(f.getType())) {
- collection = discoveredFieldsP1;
- }
-
- collection.put(f.getName(), (Object o) -> {
- try {
- return f.get(o);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- });
- }
-
-// for (var m : klass.getFields()) {
-// if (m.getParameterCount() != 0) {
-// continue;
-// }
-//
-// var name = m.getName();
-//
-// if (name.startsWith("get") && name.length() > 3 && Character.isUpperCase(name.charAt(4))) {
-// name = name.substring(3, 3).toLowerCase() + name.substring(4);
-// } else {
-// continue;
-// }
-//
-// if (!m.isAccessible()) {
-// if (!m.trySetAccessible())
-// return null;
-// }
-//
-// discoveredFields.put(name, m);
-// }
-
-// System.out.printf("Sorting %s by:%n", klass.getName());
-
- var discoveredFields = new LinkedHashMap<>(discoveredFieldsP1);
- discoveredFields.putAll(discoveredFieldsP2);
-
- List<Function<Object, Object>> accessors = new ArrayList<>();
- for (String prioritizedKey : prioritizedKeys) {
- var m = discoveredFields.remove(prioritizedKey);
- if (m == null) {
- continue;
- }
-
- accessors.add(m);
-// System.out.println(" + " + prioritizedKey);
- }
- accessors.addAll(discoveredFields.values());
-// discoveredFields.keySet().forEach((s)-> System.out.println(" - " + s));
-
- comparator = (a, b) -> {
-// if (klass.getName().contains("AcmeServer")) {
-// System.out.println("AcmeIo.comparable");
-// }
-
- for (var method : accessors) {
- var x = method.apply(a);
- var y = method.apply(b);
-
- if (x == null && y == null) {
- continue;
- }
-
- if (x == null) {
- return -1;
- } else if (y == null) {
- return 1;
- } else {
- var res = x.toString().compareTo(y.toString());
- if (res != 0) {
- return res;
- }
- }
- }
-
- return 0;
- };
-
- comparators.put(klass, comparator);
-
- return comparator;
- }
-
- static record DbObject2(String type, Object data) {
- }
-
- public void dump(File file, Collection<FactHandle> factHandles, Function<Object, Boolean> filter) throws IOException {
- FileUtil.createMissingParentDirectories(file);
-
- var facts = new TreeMap<Class<?>, FactCollection<Object>>(Comparator.comparing(Class::getName));
- for (var handle : factHandles) {
- if (handle instanceof DefaultFactHandle h) {
- var obj = h.getObject();
- if (!filter.apply(obj)) {
- continue;
- }
-
- Class<?> type = obj.getClass();
- var collection = facts.get(type);
-
- if (collection == null) {
- collection = new FactCollection(type);
- facts.put(type, collection);
- }
-
- collection.values.add(obj);
- }
- }
-
- var objects = new ArrayList<DbObject2>(facts.size());
- for (var e : facts.entrySet()) {
- var name = e.getKey().getName();
-
- var collection = e.getValue();
- collection.sort();
- for (var fact : collection.values) {
- objects.add(new DbObject2(name, fact));
- }
- }
-
- objects.sort(new DbObjectComparator());
-
- var factory = mapper.getFactory();
- try (var writer = new FileWriter(file);
- var g = factory.createGenerator(writer)) {
- g.writeObject(objects);
- }
- }
-
- private class DbClassLoader extends ClassLoader {
- private final KieContainer container;
- private final KieBase kieBase;
-
- public DbClassLoader(KieContainer container, KieBase kieBase) {
- this.container = container;
- this.kieBase = kieBase;
- }
-
- @Override
- public Class<?> loadClass(String name) throws ClassNotFoundException {
- logger.info("Loading class {}", name);
- try {
- var klass = super.loadClass(name);
- logger.info("Found class in super classloader");
- return klass;
- } catch (ClassNotFoundException e) {
- var i = name.lastIndexOf('.');
- String pkg, simpleName;
- if (i == -1) {
- pkg = null;
- simpleName = name;
- } else {
- pkg = name.substring(0, i);
- simpleName = name.substring(i + 1);
- }
-
- try {
- var klass = container.getClassLoader().loadClass(name);
- logger.info("Found class in container's classloader");
- return klass;
- } catch (ClassNotFoundException ignore) {
- }
-
- try {
- logger.info("pkg = {}", pkg);
- logger.info("simpleName = {}", simpleName);
- var clazz = kieBase.getFactType(pkg, simpleName);
- if (clazz != null) {
- logger.info("Found class as a FactType");
- return clazz.getFactClass();
- }
- } catch (UnsupportedOperationException ignore) {
- }
-
- logger.warn("Class not found: {}", name);
-
- throw e;
- }
- }
- }
-
- private static class DbObjectComparator implements Comparator<DbObject2> {
- private final List<String> prioritizedPackages = List.of(
- "io.trygvis.rules.machine",
- "io.trygvis.rules.network",
- "io.trygvis.rules.dns",
- "io.trygvis.rules.dba",
- "io.trygvis.rules",
- "io.trygvis.rules.core");
-
- @Override
- public int compare(DbObject2 a, DbObject2 b) {
- var indexA = a.type.lastIndexOf(".");
- String packageA = indexA == -1 ? null : a.type.substring(0, indexA);
- String classA = indexA == -1 ? a.type : a.type.substring(indexA + 1);
-
- var indexB = b.type.lastIndexOf(".");
- String packageB = indexB == -1 ? null : b.type.substring(0, indexB);
- String classB = indexB == -1 ? b.type : b.type.substring(indexB + 1);
-
- var priIdxA = prioritizedPackages.indexOf(packageA);
- var priIdxB = prioritizedPackages.indexOf(packageB);
-
- if (priIdxA == -1 && priIdxB == -1) {
- return classB.compareTo(classA);
- } else if (priIdxA == -1) {
- return 1;
- } else if (priIdxB == -1) {
- return -1;
- }
- return priIdxA - priIdxB;
-// var diff = priIdxB - priIdxA;
-// if (diff != 0) {
-// return diff;
-// }
-//
-// return classB.compareTo(classA);
- }
- }
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbObject.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbObject.java
deleted file mode 100644
index 6b9817e..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/DbObject.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.trygvis.rules.engine;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public final class DbObject {
- public String type;
- public ObjectNode data;
-
- public DbObject() {
- }
-
- public DbObject(String type, ObjectNode data) {
- this.type = type;
- this.data = data;
- }
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java
deleted file mode 100644
index f2247d3..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/Engine.java
+++ /dev/null
@@ -1,172 +0,0 @@
-package io.trygvis.rules.engine;
-
-import org.drools.core.audit.WorkingMemoryConsoleLogger;
-import org.drools.core.base.MapGlobalResolver;
-import org.drools.reflective.classloader.ProjectClassLoader;
-import org.kie.api.KieServices;
-import org.kie.api.event.rule.AgendaEventListener;
-import org.kie.api.event.rule.RuleRuntimeEventListener;
-import org.kie.api.io.Resource;
-import org.kie.api.runtime.KieContainer;
-import org.kie.api.runtime.KieSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nullable;
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Engine implements Closeable {
- @SuppressWarnings("FieldCanBeLocal")
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
- public final String name;
- @Nullable
- public final File output;
- public final DbIo io;
- public final KieSession session;
-
- public Engine(String name, File[] databases, @Nullable File output, String[] agendaGroups, File[] modules)
- throws IOException {
- this.name = name;
- this.output = output;
-
- logger.info("Getting KieServices");
-
- var services = KieServices.Factory.get();
-
- var kieRepository = services.getRepository();
-
- KieContainer container;
- TemplateLoader templateLoader;
- if (modules != null && modules.length > 0) {
- List<Resource> resources = new ArrayList<>();
- List<URL> files = new ArrayList<>();
- for (File path : modules) {
- if (!path.exists()) {
- logger.warn("Module path does not exist: {}", path.getAbsolutePath());
- continue;
- }
-
- logger.info("New KieBuilder: {}, file={}, directory={}", path, path.isFile(), path.isDirectory());
-
- if (path.isFile()) {
- files.add(path.toURI().toURL());
- }
-
- var resource = services.getResources().newFileSystemResource(path);
- logger.info("resource.getResourceType() = {}", resource.getResourceType());
- resources.add(resource);
- }
-
- var module = kieRepository.addKieModule(resources.get(0), resources.subList(1, resources.size()).toArray(new Resource[0]));
- logger.info("module.getReleaseId() = {}", module.getReleaseId());
- var rId = module.getReleaseId();
-
- logger.info("Creating classpath container, releaseId=" + rId);
- container = services.newKieContainer(rId);
-
- templateLoader = new ClasspathTemplateLoader(new URLClassLoader(files.toArray(new URL[0])));
- } else {
- var classLoader = ProjectClassLoader.findParentClassLoader();
- container = services.getKieClasspathContainer(classLoader);
- templateLoader = new ClasspathTemplateLoader(classLoader);
- }
-
- logger.info("Creating KieBase \"{}\"", name);
- logger.info("Available kie base names: {}", container.getKieBaseNames());
- var kieBase = container.getKieBase(name);
-
- session = container.newKieSession(name);
-
- var l = new WorkingMemoryConsoleLogger(session);
- session.addEventListener((AgendaEventListener) l);
- session.addEventListener((RuleRuntimeEventListener) l);
-
- session.getGlobals().setDelegate(new EngineGlobalResolver(templateLoader));
-
- logger.info("Loading data");
- io = new DbIo(container, kieBase);
-
- List<Object> allObjects = new ArrayList<>();
- for (File database : databases) {
- var objects = io.load(database);
-
- if (objects.isEmpty()) {
- logger.warn("Did not load any objects, something is wrong");
- return;
- }
-
- logger.info("Loaded {} objects from {}", objects.size(), database);
- allObjects.addAll(objects);
- }
- logger.info("Loaded {} objects", allObjects.size());
-
- for (var object : allObjects) {
- logger.info("object = " + object);
- session.insert(object);
- }
-
- for (var agendaGroup : agendaGroups) {
- logger.info("Setting agenda: " + agendaGroup);
- session.getAgenda().getAgendaGroup(agendaGroup).setFocus();
- session.fireAllRules();
- }
- }
-
- @Override
- public void close() {
- session.dispose();
- }
-
- private static class ClasspathTemplateLoader implements TemplateLoader {
- private final ClassLoader classLoader;
-
- private ClasspathTemplateLoader(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- @Override
- public String load(String name) throws IOException {
- var resource = "templates/" + name + ".j2";
-
- try (var inputStream = classLoader.getResourceAsStream(resource)) {
- if (inputStream == null) {
- throw new FileNotFoundException("Classpath resource: " + resource);
- }
-
- return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
- }
- }
- }
-
- private class EngineGlobalResolver extends MapGlobalResolver {
- private final TemplateLoader templateLoader;
-
- public EngineGlobalResolver() {
- templateLoader = null;
- }
-
- public EngineGlobalResolver(TemplateLoader templateLoader) {
- this.templateLoader = templateLoader;
- }
-
- @Override
- public Object resolveGlobal(String identifier) {
- if ("te".equals(identifier)) {
- if (output == null) {
- throw new IllegalArgumentException("An instance of the TemplateEngine is required, but this job is not configured with a output directory.");
- }
- return new JinjavaTemplateEngine(templateLoader, output);
- }
- return super.resolveGlobal(identifier);
- }
- }
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/JinjavaTemplateEngine.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/JinjavaTemplateEngine.java
deleted file mode 100644
index ba23089..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/JinjavaTemplateEngine.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package io.trygvis.rules.engine;
-
-import ch.qos.logback.core.util.FileUtil;
-import com.hubspot.jinjava.Jinjava;
-import org.apache.commons.io.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * TODO: cache templates.
- */
-public class JinjavaTemplateEngine implements TemplateEngine {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
- private final Jinjava jinjava = new Jinjava();
-
- private final TemplateLoader loader;
- private final File basedir;
-
- public JinjavaTemplateEngine(TemplateLoader templateLoader, File basedir) {
- Objects.requireNonNull(templateLoader);
- Objects.requireNonNull(basedir);
- this.loader = templateLoader;
- this.basedir = basedir;
- }
-
- @Override
- public void clean() {
- try {
- logger.info("Removing output directory: {}", basedir);
- FileUtils.deleteDirectory(basedir);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void template(String name, String output, Map<String, Object> params) throws IOException {
- var template = loader.load(name);
- String renderedTemplate = jinjava.render(template, params);
- var f = new File(basedir, output);
- FileUtil.createMissingParentDirectories(f);
- Files.writeString(f.toPath(), renderedTemplate);
- }
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/Main.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/Main.java
deleted file mode 100644
index dc9ed02..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/Main.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package io.trygvis.rules.engine;
-
-import io.trygvis.rules.engine.cli.DatabaseCommand;
-import io.trygvis.rules.engine.cli.NinjaCommand;
-import io.trygvis.rules.engine.cli.RunCommand;
-import picocli.CommandLine;
-import picocli.CommandLine.Command;
-
-@Command(
- name = "engine",
- subcommands = {RunCommand.class, DatabaseCommand.class, NinjaCommand.class},
- mixinStandardHelpOptions = true,
- version = "UNSPECIFIED")
-class Main {
-
- public static void main(String... args) {
- //noinspection InstantiationOfUtilityClass
- int exitCode = new CommandLine(new Main()).execute(args);
- System.exit(exitCode);
- }
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/TemplateLoader.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/TemplateLoader.java
deleted file mode 100644
index 9441264..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/TemplateLoader.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package io.trygvis.rules.engine;
-
-import java.io.IOException;
-
-interface TemplateLoader {
- String load(String name) throws IOException;
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/DatabaseCommand.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/DatabaseCommand.java
deleted file mode 100644
index 03650b5..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/DatabaseCommand.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package io.trygvis.rules.engine.cli;
-
-import picocli.CommandLine.Command;
-
-import java.util.concurrent.Callable;
-
-import static picocli.CommandLine.Option;
-
-@Command(name = "database")
-public class DatabaseCommand implements Callable<Integer> {
-
- @Option(names = {"-v", "--verbose"})
- private boolean verbose;
-
- @Override
- public Integer call() {
- System.out.println("DatabaseCommand.call");
- return 0;
- }
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/EngineFile.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/EngineFile.java
deleted file mode 100644
index 8da0e39..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/EngineFile.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package io.trygvis.rules.engine.cli;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class EngineFile {
- public String dbDir;
- public List<Job> jobs;
-
- public static class Job {
- public String name;
- public List<String> inputs = new ArrayList<>();
- public List<String> outputIncludes = new ArrayList<>();
- public String generatedOutput;
- public List<String> agendaGroups = new ArrayList<>();
- public List<String> modules = new ArrayList<>();
- }
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/NinjaCommand.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/NinjaCommand.java
deleted file mode 100644
index ef5ed1d..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/NinjaCommand.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package io.trygvis.rules.engine.cli;
-
-import com.fasterxml.jackson.databind.MapperFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-import org.apache.commons.lang3.StringUtils;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.Callable;
-import java.util.stream.Collectors;
-
-import static picocli.CommandLine.Command;
-
-@Command(name = "ninja")
-public class NinjaCommand implements Callable<Integer> {
-
- public File basedir = null;
-
- public Path basepath;
-
- @Override
- public Integer call() throws Exception {
- basepath = Objects.requireNonNullElseGet(basedir, () -> new File("").getAbsoluteFile()).toPath();
-
- var factory = new YAMLFactory();
- factory.enable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID);
- factory.enable(YAMLGenerator.Feature.USE_NATIVE_OBJECT_ID);
- var mapper = new ObjectMapper(factory);
- mapper.enable(MapperFeature.AUTO_DETECT_FIELDS);
-
- var f = mapper.readValue(new File(basedir, "engine.yaml"), EngineFile.class);
-
- Path dbDir;
- if (StringUtils.trimToNull(f.dbDir) == null) {
- System.err.println("Missing required field: dbDir");
- return 1;
- } else {
- dbDir = Path.of(f.dbDir);
- }
-
- var buf = new StringWriter();
- var out = new PrintWriter(buf);
-
- out.println("# Generated");
- out.println("#");
- out.println("### engine.ninja");
- out.println("");
- out.println("rule engine-yaml-to-ninja");
- out.println(" command = engine ninja");
- out.println("");
- out.println("build engine.ninja: engine-yaml-to-ninja engine.yaml");
- out.println("");
- out.println("### engine.png");
- out.println("");
- out.println("rule ninja-to-dot");
- out.println(" command = ninja -t graph > $out");
- out.println("");
- out.println("rule dot-to-png");
- out.println(" command = dot -Tpng < $in > $out");
- out.println("");
- out.println("build engine.dot: ninja-to-dot build.ninja engine.ninja");
- out.println("");
- out.println("build engine.png: dot-to-png engine.dot");
- out.println("");
- out.println("# Jobs");
-
- for (var job : f.jobs) {
- out.println("");
-
- out.println("rule %s".formatted(job.name));
- out.println(" command=engine run $name $inputs $output_state $output_includes $generated_output $agenda_groups $modules");
- out.println();
- var dependencies = job.inputs.stream()
- .map(s -> dbDir.resolve(s + ".yaml").toString())
- .collect(Collectors.joining(" "));
-
- var outputState = dbDir.resolve(job.name + ".yaml");
-
- var generated = List.of(outputState).stream()
- .map(Path::toString)
- .collect(Collectors.joining(" "));
-
- out.println("build %s: %s %s".formatted(generated, job.name, dependencies));
- out.println(" name=--name %s".formatted(job.name));
-
- if (!job.inputs.isEmpty()) {
- var is = job.inputs.stream()
- .map(s -> "--input=" + dbDir.resolve(s + ".yaml"))
- .collect(Collectors.joining(" $\n ", "\n ", ""));
-
- out.println(" inputs=$%s".formatted(is));
- }
-
- out.println(" output_state=--output-state %s".formatted(outputState));
- if (!job.outputIncludes.isEmpty()) {
- var str = job.outputIncludes.stream()
- .map(s -> "--output-include=" + s)
- .collect(Collectors.joining(" $\n ", "\n ", ""));
-
- out.println(" output_includes=$%s".formatted(str));
- }
-
- if (job.generatedOutput != null) {
- out.println(" generated_output=--generated-output %s".formatted(fixPath(job.generatedOutput)));
- }
-
- if (!job.agendaGroups.isEmpty()) {
- var ag = job.agendaGroups.stream()
- .map(s -> "--agenda-group=" + s)
- .collect(Collectors.joining(" $\n ", "\n ", ""));
- out.println(" agenda_groups=%s".formatted(ag));
- }
-
- if (!job.modules.isEmpty()) {
- var ms = job.modules.stream()
- .map(this::fixPath)
- .map(s -> "--module=" + s)
- .collect(Collectors.joining(" $\n ", "\n ", ""));
-
- out.println(" modules=$%s".formatted(ms));
- }
- }
-
- var ninjaFile = new File(basedir, "engine.ninja");
- try (var writer = new FileWriter(ninjaFile)) {
- writer.write(buf.toString());
- }
-
- return 0;
- }
-
- private String fixPath(String s) {
- if (s.startsWith("$MODULE_HOME/")) {
- s = "$" + s;
- }
-
- var p = Path.of(s);
-
- if (p.isAbsolute()) {
- s = basepath.relativize(Path.of(s)).toString();
- }
-
- if (s.contains("*")) {
- s = "$$(echo " + s + ")";
- }
-
- return s;
- }
-}
diff --git a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java b/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java
deleted file mode 100644
index 35f30cd..0000000
--- a/module/ri-engine/src/main/java/io/trygvis/rules/engine/cli/RunCommand.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package io.trygvis.rules.engine.cli;
-
-import io.trygvis.rules.engine.Engine;
-
-import java.io.File;
-import java.util.concurrent.Callable;
-
-import static picocli.CommandLine.Command;
-import static picocli.CommandLine.Option;
-
-@Command(name = "run")
-public class RunCommand implements Callable<Integer> {
-
- @Option(names = {"-n", "--name"})
- public String name;
-
- @Option(names = {"-i", "--input"})
- public File[] input;
-
- @Option(names = {"--output-state"})
- public File outputState;
-
- @Option(names = {"--output-include"}, split = ",", arity = "1..*")
- public String[] outputIncludes;
-
- @Option(names = {"--generated-output"})
- public File generatedOutput;
-
- @Option(names = {"--agenda-group"})
- public String[] agendaGroups;
-
- @Option(names = {"--module"}, split = ",", arity = "1..*")
- public File[] module;
-
- @Override
- public Integer call() throws Exception {
-
- if (agendaGroups == null || agendaGroups.length == 0) {
- agendaGroups = new String[]{"init", "generate"};
- }
-
- try (var engine = new Engine(name, input, generatedOutput, agendaGroups, module)) {
- engine.io.dump(outputState, engine.session.getFactHandles(), (Object o) ->
- {
- if (outputIncludes == null || outputIncludes.length == 0) {
- return true;
- }
-
- var name = o.getClass().getName();
- var simpleName = o.getClass().getSimpleName();
-
- for (var i : outputIncludes) {
- var ok = false;
- if (i.startsWith("*")) {
- i = i.substring(1);
-
- if (i.endsWith("*")) {
- i = i.substring(1, i.length() - 2);
- ok = name.contains(i);
- } else {
- ok = name.startsWith(i) || simpleName.startsWith(i);
- }
- } else if (i.endsWith("*")) {
- i = i.substring(0, i.length() - 2);
- ok = name.startsWith(i) || simpleName.startsWith(i);
- } else {
- ok = name.equals(i) || simpleName.equals(i);
- }
-
- if (ok) {
- return true;
- }
- }
-
- return false;
- }
- );
- }
-
- return 0;
- }
-}
diff --git a/module/ri-engine/src/test/java/io/trygvis/rules/engine/AcmeAppsTestMain.java b/module/ri-engine/src/test/java/io/trygvis/rules/engine/AcmeAppsTestMain.java
deleted file mode 100644
index 37e8787..0000000
--- a/module/ri-engine/src/test/java/io/trygvis/rules/engine/AcmeAppsTestMain.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package io.trygvis.rules.engine;
-
-import io.trygvis.rules.engine.cli.RunCommand;
-
-import java.io.File;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-class AcmeAppsTestMain {
- public static void main(String[] args) throws Exception {
- var c = new RunCommand();
- c.name = "acme-apps";
- c.input = new File[]{new File("acme.yaml")};
- c.outputState = new File("out/acme/apps.yaml");
- c.agendaGroups = new String[]{"init", "generate"};
- c.generatedOutput = new File("acme-apps");
- assertEquals(0, c.call());
- }
-}
diff --git a/module/ri-engine/src/test/java/io/trygvis/rules/engine/AcmeWireguardTestMain.java b/module/ri-engine/src/test/java/io/trygvis/rules/engine/AcmeWireguardTestMain.java
deleted file mode 100644
index cf6b1c8..0000000
--- a/module/ri-engine/src/test/java/io/trygvis/rules/engine/AcmeWireguardTestMain.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package io.trygvis.rules.engine;
-
-import io.trygvis.rules.engine.cli.RunCommand;
-
-import java.io.File;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-class AcmeWireguardTestMain {
- public static void main(String[] args) throws Exception {
- var c = new RunCommand();
- c.name = "acme-wireguard";
- c.input = new File[]{new File("acme.yaml")};
- c.outputState = new File("out/acme/wireguard.yaml");
- c.agendaGroups = new String[]{"init", "generate"};
- c.generatedOutput = new File("acme-wireguard");
- c.outputIncludes = new String[]{
- "Wg*",
- "Machine",
- "DnsEntry",
- "Ipv4Cidr",
- "Ipv4Address",
- };
-
- assertEquals(0, c.call());
- }
-}
diff --git a/module/ri-engine/src/test/java/io/trygvis/rules/engine/NinjaTestMain.java b/module/ri-engine/src/test/java/io/trygvis/rules/engine/NinjaTestMain.java
deleted file mode 100644
index d62eec1..0000000
--- a/module/ri-engine/src/test/java/io/trygvis/rules/engine/NinjaTestMain.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.trygvis.rules.engine;
-
-import io.trygvis.rules.engine.cli.NinjaCommand;
-
-import java.io.File;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-class NinjaTestMain {
- public static void main(String[] args) throws Exception {
- var c = new NinjaCommand();
- c.basedir = new File("example");
-
- assertEquals(0, c.call());
- }
-}
diff --git a/module/ri-module-api/classpath.txt b/module/ri-module-api/classpath.txt
deleted file mode 100644
index 1f0f0a6..0000000
--- a/module/ri-module-api/classpath.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-io.trygvis.rules-sandbox.module:ri-module-api:1.0-SNAPSHOT:jar
-com.github.javaparser:javaparser-core:3.13.10:jar
-com.thoughtworks.xstream:xstream:1.4.14:jar
-commons-codec:commons-codec:1.14:jar
-commons-io:commons-io:2.8.0:jar
-org.antlr:antlr-runtime:3.5.2:jar
-org.drools:drools-canonical-model:7.48.0.Final:jar
-org.drools:drools-compiler:7.48.0.Final:jar
-org.drools:drools-core:7.48.0.Final:jar
-org.drools:drools-core-dynamic:7.48.0.Final:jar
-org.drools:drools-core-reflective:7.48.0.Final:jar
-org.drools:drools-ecj:7.48.0.Final:jar
-org.drools:drools-model-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-parser:7.48.0.Final:jar
-org.kie:kie-api:7.48.0.Final:jar
-org.kie:kie-internal:7.48.0.Final:jar
-org.kie:kie-memory-compiler:7.48.0.Final:jar
-org.kie.soup:kie-soup-maven-support:7.48.0.Final:jar
-org.kie.soup:kie-soup-xstream:7.48.0.Final:jar
-org.slf4j:slf4j-api:1.7.30:jar
-xmlpull:xmlpull:1.1.3.1:jar
-xpp3:xpp3_min:1.1.4c:jar
diff --git a/module/ri-module-api/pom.xml b/module/ri-module-api/pom.xml
deleted file mode 100644
index 118b5ba..0000000
--- a/module/ri-module-api/pom.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>io.trygvis.rules-sandbox.module</groupId>
- <artifactId>ri-module-parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <relativePath>../ri-module-parent/pom.xml</relativePath>
- </parent>
-
- <artifactId>ri-module-api</artifactId>
-
-</project>
diff --git a/module/ri-module-api/src/main/java/io/trygvis/rules/engine/TemplateEngine.java b/module/ri-module-api/src/main/java/io/trygvis/rules/engine/TemplateEngine.java
deleted file mode 100644
index eafa6e4..0000000
--- a/module/ri-module-api/src/main/java/io/trygvis/rules/engine/TemplateEngine.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package io.trygvis.rules.engine;
-
-import java.io.IOException;
-import java.util.Map;
-
-public interface TemplateEngine {
- void clean();
-
- void template(String name, String output, Map<String, Object> params) throws IOException;
-}
diff --git a/module/ri-module-parent/classpath.txt b/module/ri-module-parent/classpath.txt
deleted file mode 100644
index 8624088..0000000
--- a/module/ri-module-parent/classpath.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-io.trygvis.rules-sandbox.module:ri-module-parent:1.0-SNAPSHOT:pom
-com.github.javaparser:javaparser-core:3.13.10:jar
-com.thoughtworks.xstream:xstream:1.4.14:jar
-commons-codec:commons-codec:1.14:jar
-commons-io:commons-io:2.8.0:jar
-org.antlr:antlr-runtime:3.5.2:jar
-org.drools:drools-canonical-model:7.48.0.Final:jar
-org.drools:drools-compiler:7.48.0.Final:jar
-org.drools:drools-core:7.48.0.Final:jar
-org.drools:drools-core-dynamic:7.48.0.Final:jar
-org.drools:drools-core-reflective:7.48.0.Final:jar
-org.drools:drools-ecj:7.48.0.Final:jar
-org.drools:drools-model-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-parser:7.48.0.Final:jar
-org.kie:kie-api:7.48.0.Final:jar
-org.kie:kie-internal:7.48.0.Final:jar
-org.kie:kie-memory-compiler:7.48.0.Final:jar
-org.kie.soup:kie-soup-maven-support:7.48.0.Final:jar
-org.kie.soup:kie-soup-xstream:7.48.0.Final:jar
-org.slf4j:slf4j-api:1.7.30:jar
-xmlpull:xmlpull:1.1.3.1:jar
-xpp3:xpp3_min:1.1.4c:jar
diff --git a/module/ri-module-parent/pom.xml b/module/ri-module-parent/pom.xml
deleted file mode 100644
index d593ca8..0000000
--- a/module/ri-module-parent/pom.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>ri-module-parent</artifactId>
- <groupId>io.trygvis.rules-sandbox.module</groupId>
- <version>1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <properties>
- <version.drools>7.48.0.Final</version.drools>
- <java.version>13</java.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-model-compiler</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- </dependencies>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>io.trygvis.rules-sandbox</groupId>
- <artifactId>ri-engine</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <build>
- <finalName>${project.artifactId}</finalName>
- <plugins>
- <plugin>
- <groupId>org.kie</groupId>
- <artifactId>kie-maven-plugin</artifactId>
- <extensions>true</extensions>
- </plugin>
- <plugin>
- <groupId>eu.nets.oss.maven</groupId>
- <artifactId>classpath-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>default</id>
- <goals>
- <goal>export-classpath</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.kie</groupId>
- <artifactId>kie-maven-plugin</artifactId>
- <versionRange>[7.48.0.Final,)</versionRange>
- <goals>
- <goal>generatePMMLModel</goal>
- <goal>generateDMNModel</goal>
- <goal>build</goal>
- <goal>generateANC</goal>
- <goal>generateModel</goal>
- <goal>validateDMN</goal>
- <goal>injectreactive</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore></ignore>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.kie</groupId>
- <artifactId>kie-maven-plugin</artifactId>
- <version>${version.drools}</version>
- <extensions>true</extensions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.8.1</version>
- <configuration>
- <encoding>UTF-8</encoding>
- <release>${java.version}</release>
- <source>${java.version}</source>
- <target>${java.version}</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>3.2.0</version>
- <configuration>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
- <plugin>
- <groupId>eu.nets.oss.maven</groupId>
- <artifactId>classpath-maven-plugin</artifactId>
- <version>1.0</version>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
-</project>
diff --git a/module/ri-wireguard/classpath.txt b/module/ri-wireguard/classpath.txt
deleted file mode 100644
index ef1b057..0000000
--- a/module/ri-wireguard/classpath.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-io.trygvis.rules-sandbox.module:ri-wireguard:1.0-SNAPSHOT:kjar
-com.fasterxml.jackson.core:jackson-annotations:2.12.0:jar
-com.fasterxml.jackson.core:jackson-core:2.12.0:jar
-com.fasterxml.jackson.core:jackson-databind:2.12.0:jar
-com.github.javaparser:javaparser-core:3.13.10:jar
-com.thoughtworks.xstream:xstream:1.4.14:jar
-commons-codec:commons-codec:1.14:jar
-commons-io:commons-io:2.8.0:jar
-io.trygvis.rules-sandbox.module:ri-base:1.0-SNAPSHOT:jar
-io.trygvis.rules-sandbox.module:ri-module-api:1.0-SNAPSHOT:jar
-org.antlr:antlr-runtime:3.5.2:jar
-org.drools:drools-canonical-model:7.48.0.Final:jar
-org.drools:drools-compiler:7.48.0.Final:jar
-org.drools:drools-core:7.48.0.Final:jar
-org.drools:drools-core-dynamic:7.48.0.Final:jar
-org.drools:drools-core-reflective:7.48.0.Final:jar
-org.drools:drools-ecj:7.48.0.Final:jar
-org.drools:drools-model-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-compiler:7.48.0.Final:jar
-org.drools:drools-mvel-parser:7.48.0.Final:jar
-org.kie:kie-api:7.48.0.Final:jar
-org.kie:kie-internal:7.48.0.Final:jar
-org.kie:kie-memory-compiler:7.48.0.Final:jar
-org.kie.soup:kie-soup-maven-support:7.48.0.Final:jar
-org.kie.soup:kie-soup-xstream:7.48.0.Final:jar
-org.slf4j:slf4j-api:1.7.30:jar
-xmlpull:xmlpull:1.1.3.1:jar
-xpp3:xpp3_min:1.1.4c:jar
diff --git a/module/ri-wireguard/pom.xml b/module/ri-wireguard/pom.xml
deleted file mode 100644
index cc569d7..0000000
--- a/module/ri-wireguard/pom.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>io.trygvis.rules-sandbox.module</groupId>
- <artifactId>ri-module-parent</artifactId>
- <version>1.0-SNAPSHOT</version>
- <relativePath>../ri-module-parent/pom.xml</relativePath>
- </parent>
-
- <artifactId>ri-wireguard</artifactId>
- <packaging>kjar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ri-base</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/module/ri-wireguard/src/main/resources/META-INF/kmodule.xml b/module/ri-wireguard/src/main/resources/META-INF/kmodule.xml
deleted file mode 100644
index de617f7..0000000
--- a/module/ri-wireguard/src/main/resources/META-INF/kmodule.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://www.drools.org/xsd/kmodule"
- xsi:schemaLocation="http://www.drools.org/xsd/kmodule https://www.drools.org/xsd/kmodule_7_1.xsd">
-
- <kbase name="wireguard" packages="io.trygvis.rules.wireguard">
-<!-- <ksession name="wireguard"/>-->
- </kbase>
-</kmodule>
diff --git a/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl b/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl
deleted file mode 100644
index 5630ab6..0000000
--- a/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl
+++ /dev/null
@@ -1,185 +0,0 @@
-package io.trygvis.rules.wireguard;
-
-import io.trygvis.rules.dns.DnsEntry;
-import io.trygvis.rules.machine.Machine;
-import io.trygvis.rules.network.IpCalc
-import io.trygvis.rules.network.Ipv4Address
-import io.trygvis.rules.network.Ipv4Cidr
-import java.util.ArrayList
-import java.util.List
-import java.util.Map
-
-global io.trygvis.rules.engine.TemplateEngine te;
-
-dialect "mvel"
-
-declare WgNet
- name : String
- domain : String
- port : int
- linkCidr : String
- networkCidr : String
- networkBits : int
-end
-
-declare WgIpPool
- net : WgNet
- role : String
- cidr : Ipv4Cidr
-end
-
-declare WgHost
- machine : Machine
- net : WgNet
- publicName : String
- publicPort : int
- ip : String // This host's IP
- networkCidr : String
-end
-
-declare WgConnection
- name : String
- host : WgHost
- to : WgHost
-end
-
-declare WgIpAllocation
- host : WgHost
- role : String
- ip : Ipv4Address
-end
-
-rule "Create IP pools" when
- $net : WgNet()
-// not(Ipv4Cidr(network == Ipv4Cidr.parseCidr($net.linkCidr).network))
-then
- System.out.println("Creating main IP pools");
- insert(new WgIpPool($net, "link", Ipv4Cidr.parseCidr($net.getLinkCidr())))
- insert(new WgIpPool($net, "networks", Ipv4Cidr.parseCidr($net.getNetworkCidr())))
-end
-
-rule "WgHost VPN machines"
-when
- $machine : Machine()
- $wgNet : WgNet(name == "vpn0")
- not(WgHost(machine == $machine))
-then
- WgHost wgHost = new WgHost();
- wgHost.machine = $machine;
- wgHost.net = $wgNet;
- wgHost.publicName = $machine.fqdn;
- wgHost.publicPort = $wgNet.port;
- insert(wgHost)
-end
-
-rule "Set public name of WgHost"
-when
- $host : WgHost(publicName == null)
- $m : Machine(this == $host.machine, fqdn != null)
-then
- modify($host) {
- publicName = $m.fqdn
- }
-end
-
-rule "Make DNS entries for all VPN hosts"
-when
- $h : WgHost()
- not(DnsEntry(fqdn == "%s.%s".formatted($h.machine.name, $h.net.domain), type == "A"))
-then
- String fqdn = "%s.%s".formatted($h.machine.name, $h.net.domain);
- insert(DnsEntry.a(fqdn))
-end
-
-rule "Connect VPN nodes"
- salience -1
-when
- $h : WgHost()
- $other : WgHost(publicName != null, this != $h)
-then
- System.out.printf("VPN connection from %s to %s%n", $h.machine.name, $other.machine.name);
- WgConnection c = new WgConnection();
- c.host = $h;
- c.to = $other;
- insert(c)
-end
-
-rule "Name connections"
-when
- $c : WgConnection(name == null, host != null, to != null)
-then
- String n = $c.host.machine.name + "_x_" + $c.to.machine.name;
- modify($c) {
- name = n
- }
-end
-
-// This and the next rule needs to use .toString(), the specific objects might be generated multiple times,
-// but Drools use identityHashCode() to find equal objects, not equals().
-rule "Assign IP"
-when
- $pool : WgIpPool(role == "link")
- $ip : Ipv4Address() from $pool.cidr.addresses()
- not(WgHost(net == $pool.net, ip == $ip.toString()))
- $host : WgHost(net == $pool.net, ip == null)
-then
- System.out.printf("IP: net=%s, pool.role=%s, host=%s, ip=%s%n", $pool.net.name, $pool.role, $host.machine.name, $ip);
- modify($host) {
- ip = $ip.toString()
- }
-end
-
-rule "Assign network CIDR"
-when
- $net : WgNet()
- $network : Ipv4Cidr() from Ipv4Cidr.parseCidr($net.networkCidr).partition($net.networkBits)
- $host : WgHost(net == $net, networkCidr == null)
- not(WgHost(net == $net, networkCidr == $network.toString()))
-then
- System.out.printf("Network CIDR: net=%s, host=%s, network=%s%n", $net.name, $host.machine.name, $network);
- modify($host) {
- networkCidr = $network.toString()
- }
-end
-
-rule "Generate per-net files"
- agenda-group "generate"
- salience 10
-when
- $net : WgNet()
- $hosts : ArrayList() from collect(WgHost(net == $net))
-then
- te.template("wireguard/ansible", "wireguard-" + $net.name + ".yml", Map.of(
- "net", $net
- ));
-
- List machines = new ArrayList();
- for (Object o : $hosts) {
- WgHost m = (WgHost) o;
- machines.add(m.getMachine());
- }
-
- te.template("wireguard/inventory", "inventory.yml", Map.of(
- "net", $net,
- "hosts", machines
- ));
-end
-
-rule "Generate per-net, per-host files"
- agenda-group "generate"
- salience 10
-when
- $net : WgNet()
- $host : WgHost(net == $net)
- $peers : ArrayList() from accumulate(WgConnection(host == $host, $to: to), collectList($to))
-then
- System.out.printf("Generating per-host files: net=%s, host=%s%n", $net.name, $host.machine.name);
-
- String output = "host_vars/%s/wireguard.yml".formatted($host.machine.name);
-
- te.template("wireguard/ansible-host", output, Map.of(
- "net", $net,
- "host", $host,
- "peers", $peers
- ));
-end
diff --git a/module/ri-wireguard/src/main/resources/logback.xml b/module/ri-wireguard/src/main/resources/logback.xml
deleted file mode 100644
index 66ae905..0000000
--- a/module/ri-wireguard/src/main/resources/logback.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <logger name="org.apache.http" level="WARN"/>
- <root level="DEBUG">
- <appender-ref ref="STDOUT" />
- </root>
-
-</configuration>
diff --git a/module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j2 b/module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j2
deleted file mode 100644
index 6cb3a05..0000000
--- a/module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j2
+++ /dev/null
@@ -1,12 +0,0 @@
-# Generated
-wireguard_port: {{ host.publicPort }}
-link_address: {{ host.ip }}
-network_cidr: {{ host.networkCidr }}
-wireguard_peers:
-{%- for peer in peers %}
- {{ peer.machine.name }}:
- public_address: {{ peer.publicName }}
- public_port: {{ peer.publicPort }}
- gateway: {{ peer.ip }}
- network: {{ peer.networkCidr }}
-{%- endfor %}
diff --git a/module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j2 b/module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j2
deleted file mode 100644
index ad4d034..0000000
--- a/module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j2
+++ /dev/null
@@ -1,7 +0,0 @@
-- hosts: wireguard_{{ net.name }}
- vars:
- wireguard_if: {{ net.name }}
- tasks:
- - name: wireguard
- import_role:
- name: wireguard
diff --git a/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2 b/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2
deleted file mode 100644
index 64f3b5b..0000000
--- a/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2
+++ /dev/null
@@ -1,13 +0,0 @@
-# Generated
-all:
- hosts:
- {%- for host in hosts %}
- {{ host.getName() }}:
- ansible_host: {{ host.getFqdn() }}
- {%- endfor %}
- children:
- wireguard_{{ net.name }}:
- hosts:
-{%- for host in hosts %}
- {{ host.getName() }}:
-{%- endfor %}