Experimental spice proxy provider.

This commit is contained in:
Michael Lipp 2024-04-10 11:14:32 +02:00
parent 383d1c5cca
commit 98f5c1e402
11 changed files with 154 additions and 0 deletions

View file

@ -16,3 +16,4 @@ include 'org.jdrupes.vmoperator.vmconlet'
include 'org.jdrupes.vmoperator.runner.qemu'
include 'org.jdrupes.vmoperator.common'
include 'org.jdrupes.vmoperator.util'
include 'spice-squid'

10
spice-squid/.checkstyle Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false">
<local-check-config name="Project Checks" location="/VM-Operator/checkstyle.xml" type="project" description="">
<additional-data name="protect-config-file" value="false"/>
</local-check-config>
<fileset name="all" enabled="true" check-config-name="Project Checks" local="true">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>

7
spice-squid/.eclipse-pmd Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<eclipse-pmd xmlns="http://acanda.ch/eclipse-pmd/0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://acanda.ch/eclipse-pmd/0.8 http://acanda.ch/eclipse-pmd/eclipse-pmd-0.8.xsd">
<analysis enabled="true" />
<rulesets>
<ruleset name="Custom Rules" ref="moodle-tools-console/ruleset.xml" refcontext="workspace" />
</rulesets>
</eclipse-pmd>

View file

@ -0,0 +1,8 @@
add_header=true
eclipse.preferences.version=1
header_text=/*\n * VM-Operator\n * Copyright (C) 2024 Michael N. Lipp\n * \n * This program is free software\: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <https\://www.gnu.org/licenses/>.\n */
project_specific_settings=true
replacements=<?xml version\="1.0" standalone\="yes"?>\n\n<replacements>\n<replacement key\="get" scope\="1" mode\="0">Returns the</replacement>\n<replacement key\="set" scope\="1" mode\="0">Sets the</replacement>\n<replacement key\="add" scope\="1" mode\="0">Adds the</replacement>\n<replacement key\="edit" scope\="1" mode\="0">Edits the</replacement>\n<replacement key\="remove" scope\="1" mode\="0">Removes the</replacement>\n<replacement key\="init" scope\="1" mode\="0">Inits the</replacement>\n<replacement key\="parse" scope\="1" mode\="0">Parses the</replacement>\n<replacement key\="create" scope\="1" mode\="0">Creates the</replacement>\n<replacement key\="build" scope\="1" mode\="0">Builds the</replacement>\n<replacement key\="is" scope\="1" mode\="0">Checks if is</replacement>\n<replacement key\="print" scope\="1" mode\="0">Prints the</replacement>\n<replacement key\="has" scope\="1" mode\="0">Checks for</replacement>\n</replacements>\n\n
visibility_package=false
visibility_private=false
visibility_protected=false

View file

@ -0,0 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=..
eclipse.preferences.version=1
gradle.user.home=
java.home=
jvm.arguments=
offline.mode=false
override.workspace.settings=false
show.console.view=false
show.executions.view=false

View file

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View file

@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n

11
spice-squid/Containerfile Normal file
View file

@ -0,0 +1,11 @@
FROM alpine:3.19
RUN apk update &&\
apk add --no-cache inotify-tools &&\
apk add --no-cache squid
COPY run.sh /usr/local/bin/run-squid.sh
CMD ["/usr/local/bin/run-squid.sh"]
EXPOSE 3128

77
spice-squid/build.gradle Normal file
View file

@ -0,0 +1,77 @@
plugins {
id 'org.jdrupes.vmoperator.java-application-conventions'
}
dependencies {
}
task buildImage(type: Exec) {
inputs.files 'Containerfile'
commandLine 'podman', 'build', '--pull',
'-t', "${project.name}:${project.version}",\
'-f', 'Containerfile', '.'
}
task tagLatestImage(type: Exec) {
dependsOn buildImage
enabled = !project.version.contains("SNAPSHOT")
&& !project.version.contains("alpha") \
&& !project.version.contains("beta") \
|| project.rootProject.properties['docker.testRegistry'] \
&& project.rootProject.properties['docker.registry'] \
== project.rootProject.properties['docker.testRegistry']
commandLine 'podman', 'tag', "${project.name}:${project.version}",\
"${project.name}:latest"
}
task buildLatestImage {
dependsOn buildImage
dependsOn tagLatestImage
}
task pushImage(type: Exec) {
dependsOn buildImage
commandLine 'podman', 'push', '--tls-verify=false', \
"localhost/${project.name}:${project.version}", \
"${project.rootProject.properties['docker.registry']}" \
+ "/${project.name}:${project.version}"
}
task pushLatestImage(type: Exec) {
dependsOn buildLatestImage
enabled = !project.version.contains("SNAPSHOT")
&& !project.version.contains("alpha") \
&& !project.version.contains("beta") \
|| project.rootProject.properties['docker.testRegistry'] \
&& project.rootProject.properties['docker.registry'] \
== project.rootProject.properties['docker.testRegistry']
commandLine 'podman', 'push', '--tls-verify=false', \
"localhost/${project.name}:${project.version}", \
"${project.rootProject.properties['docker.registry']}" \
+ "/${project.name}:latest"
}
task pushImages {
// Don't push without testing first
dependsOn pushImage
dependsOn pushLatestImage
}
test {
enabled = project.hasProperty("k8s.testCluster")
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
systemProperty "k8s.testCluster", project.hasProperty("k8s.testCluster")
? project.getProperty("k8s.testCluster") : null
}

19
spice-squid/run.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/sh
CONF_OPT="-f /run/etc/squid/squid.conf"
/usr/sbin/squid $CONF_OPT
inotifywait -m -e create -r /run/etc/squid |
while read file_path file_event file_name; do
if [ "$file_event" != "CREATE" ]; then
continue
fi
if [ -r /run/squid/squid.pid ]; then
echo "Reconfiguring squid"
/usr/sbin/squid $CONF_OPT -k reconfigure
else
echo "Restarting squid"
/usr/sbin/squid $CONF_OPT
fi
echo "Processed event"
done

4
spice-squid/squid.conf Normal file
View file

@ -0,0 +1,4 @@
http_access deny all
# Squid normally listens to port 3128
http_port 3128