Skip to content

Commit

Permalink
inventory: add get-facts
Browse files Browse the repository at this point in the history
  • Loading branch information
gsanchietti committed Apr 12, 2024
1 parent d72ae6f commit 8d2bc11
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions imageroot/actions/get-facts/10get_facts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3

#
# Copyright (C) 2024 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#

import json
import subprocess
import os
import sys
import agent

units = -1
try:
p = subprocess.run(["/usr/bin/podman", "exec", "-ti", "vpn", "find", "/etc/openvpn/ccd", "-type", "f"], capture_output=True, text=True)
units = len(p.stdout.split("\n")) - 1
except Exception as ex:
print(agent.SD_ERR, ex, file=sys.stderr)
units = 0

json.dump({
"units": units
}, fp=sys.stdout)

0 comments on commit 8d2bc11

Please sign in to comment.