Add Docker runtime helper and explicitly labelled service inventory
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""Narrow client: the web app never receives Docker's daemon socket."""
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
|
||||
MANAGED_LABEL='io.athena-deck.managed=true'
|
||||
ROLE_LABEL='io.athena-deck.role=application'
|
||||
|
||||
class DockerSupport:
|
||||
def call(self,action):
|
||||
path=os.environ.get('DECK_DOCKER_HELPER_SOCKET','/run/athena-deck-docker/control.sock')
|
||||
with socket.socket(socket.AF_UNIX) as sock:
|
||||
sock.settimeout(20);sock.connect(path);sock.sendall(json.dumps({'action':action}).encode()+b'\n')
|
||||
with sock.makefile('rb') as stream:raw=stream.readline(1048577)
|
||||
if len(raw)>1048576:raise ValueError('Docker-Helferantwort zu groß.')
|
||||
value=json.loads(raw)
|
||||
if 'error' in value:raise ValueError(value['error'])
|
||||
return value
|
||||
def status(self):
|
||||
try:return dict(self.call('status'),helper_available=True)
|
||||
except (OSError,ValueError):return dict(helper_available=False,installed=None,reachable=False,services=[],install_supported=False,job=None,message='Docker-Systemhelfer nicht verbunden. Der Deck-Installer muss ihn auf dem Debian-Host einrichten.',labels=[MANAGED_LABEL,ROLE_LABEL])
|
||||
def install(self):return self.call('install')
|
||||
Reference in New Issue
Block a user