From f6ac34dfd0d51f4144bbd8769beed4a01677518b Mon Sep 17 00:00:00 2001 From: mwiegand Date: Fri, 29 Oct 2021 10:43:14 +0200 Subject: [PATCH] openhab wip --- bundles/java/metadata.py | 28 ++++++++++++++++++---------- bundles/openhab/items.py | 18 ++++++++++++++++++ bundles/openhab/metadata.py | 6 +++++- nodes/home.openhab3.py | 3 +++ 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/bundles/java/metadata.py b/bundles/java/metadata.py index f561c9a..0fe4d09 100644 --- a/bundles/java/metadata.py +++ b/bundles/java/metadata.py @@ -1,16 +1,24 @@ assert node.os == 'debian' -if node.os_version == (10,): - version = 11 -elif node.os_version == (11,): - version = 17 -else: - raise Exception('java bundle doesnt support this os and version') defaults = { - 'apt': { - 'packages': { - f'openjdk-{version}-jre': {}, + 'java': { + 'version': { + 10: 11, + 11: 17, + }[node.os_version[0]], + }, +} + + +@metadata_reactor.provides( + 'apt/packages', +) +def apt(metadata): + return { + 'apt': { + 'packages': { + f'openjdk-{metadata.get("java/version")}-jre': {}, + } } } -} diff --git a/bundles/openhab/items.py b/bundles/openhab/items.py index 49009a7..0712ac1 100644 --- a/bundles/openhab/items.py +++ b/bundles/openhab/items.py @@ -1,5 +1,23 @@ directories = { '/var/lib/openhab': { 'owner': 'openhab', + 'group': 'openhab', + 'needs': [ + 'zfs_dataset:tank/openhab', + 'pkg_apt:openhab', + ], + 'triggers': [ + 'svc_systemd:openhab:restart', + ], + } +} + + +svc_systemd = { + 'openhab': { + 'needs': [ + 'pkg_apt:openhab', + 'directory:/var/lib/openhab', + ], } } diff --git a/bundles/openhab/metadata.py b/bundles/openhab/metadata.py index b2ffc03..60b1795 100644 --- a/bundles/openhab/metadata.py +++ b/bundles/openhab/metadata.py @@ -1,7 +1,11 @@ defaults = { 'apt': { 'packages': { - 'openhab': {}, + 'openhab': { + 'needs': [ + 'zfs_dataset:tank/openhab', + ], + }, }, 'sources': { 'deb https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable main', diff --git a/nodes/home.openhab3.py b/nodes/home.openhab3.py index e8eb917..1b83fc8 100644 --- a/nodes/home.openhab3.py +++ b/nodes/home.openhab3.py @@ -19,6 +19,9 @@ 'gateway4': '10.0.0.1', }, }, + 'java': { + 'version': 11, + }, 'zfs': { 'pools': { 'tank': {