Compare commits

...

18 Commits

Author SHA1 Message Date
8ba22f79b9 build 2026-01-24 21:07:26 +01:00
ddeb67750f build 2026-01-24 21:05:09 +01:00
12ff88f8e8 build 2026-01-24 21:03:32 +01:00
9d27e804a5 build 2026-01-24 21:02:34 +01:00
1f0a19b7b1 build 2026-01-24 21:00:19 +01:00
5adfbbcf3d build 2026-01-24 20:59:37 +01:00
0dda82be87 build 2026-01-24 20:57:21 +01:00
1a54c1e341 Merge branch 'main' of gitlab.sectorq.eu:jaydee/portainer 2026-01-24 20:55:55 +01:00
8d4bd382ee build 2026-01-24 20:55:51 +01:00
ladislav.dusa
96068d4fb3 Merge branch 'main' of https://gitlab.sectorq.eu/jaydee/portainer 2026-01-13 13:22:24 +01:00
ladislav.dusa
de37276ab6 build 2026-01-13 13:22:20 +01:00
2dc800f7f9 build 2026-01-12 23:30:30 +01:00
ae387a794c build 2026-01-09 17:34:31 +01:00
a3518ec0bb build 2026-01-09 14:07:31 +01:00
ladislav.dusa
3e86a75502 build 2026-01-08 09:06:23 +01:00
ladislav.dusa
11cd76215a build 2026-01-08 08:52:35 +01:00
4bbe283211 build 2026-01-06 22:44:38 +01:00
fc3fe7b837 build 2026-01-06 22:02:06 +01:00
3 changed files with 36 additions and 25 deletions

24
main.py
View File

@@ -26,7 +26,8 @@ from prompt_toolkit.shortcuts import checkboxlist_dialog
from prompt_toolkit.shortcuts import radiolist_dialog
VAULT_ADDR = os.environ.get("VAULT_ADDR", "http://192.168.77.101:8200")
# VAULT_ADDR = os.environ.get("VAULT_ADDR", "http://192.168.77.101:8200")
VAULT_ADDR = os.environ.get("VAULT_ADDR", "https://vault.sectorq.eu")
try:
VAULT_TOKEN = os.environ.get("VAULT_TOKEN")
if VAULT_TOKEN is None:
@@ -43,7 +44,7 @@ else:
raise Exception("Failed to authenticate with Vault")
# Specify the mount point of your KV engine
VERSION = "0.1.53"
VERSION = "0.1.55"
defaults = {
"endpoint_id": "vm01",
@@ -248,11 +249,11 @@ def prompt_missing_args(args_in, defaults_in, fields, action=None,stacks=None):
if args.action == "create_stack":
# input(json.dumps(stacks, indent=2))
commands = [
'authentik', 'bitwarden', 'bookstack', 'dockermon', 'fail2ban', 'gitea', 'gitlab', 'grafana', 'grocy',
'hashicorp', 'home-assistant', 'homebox','homepage', 'immich', 'influxdb', 'jupyter', 'kestra', 'mailu3',
'authentik', 'bitwarden', 'bookstack', 'dockermon', 'duplicati', 'fail2ban', 'gitea', 'gitlab', 'grafana', 'grocy',
'hashicorp', 'home-assistant', 'homebox','homepage', 'immich', 'influxdb', 'jupyter', 'kestra', 'kopia', 'mailu3',
'mealie', 'mediacenter', 'mosquitto', 'motioneye', 'n8n', 'nebula', 'nextcloud', 'nginx',
'node-red', 'octoprint', 'ollama', 'onlyoffice', 'paperless-ngx', 'pihole', 'portainer-ce', 'rancher', 'registry',
'regsync', 'semaphore', 'unifibrowser', 'uptime-kuma', 'watchtower', 'wazuh', 'webhub', 'wordpress',
'regsync', 'searxng','semaphore', 'unifibrowser', 'uptime-kuma', 'watchtower', 'wazuh', 'webhub', 'wordpress',
'wud', 'zabbix-server']
try:
print(por.all_data['stacks'][defaults_in[f"PORTAINER_ENDPOINT_ID".upper()]]['by_name'].keys())
@@ -409,18 +410,13 @@ if __name__ == "__main__":
]
selected_action = radiolist_dialog(
title="Select one service",
title=f"Select one service - version: {VERSION}",
text="Choose a service:",
values=actions
).run()
print("Selected:", selected_action)
# print("Possible actions: \n")
# i = 1
# for a in actions:
@@ -682,8 +678,4 @@ if __name__ == "__main__":
sys.exit()
if args.action == "refresh_status":
if args.stack == "all":
print("Stopping all stacks...")
stcks = por.get_stacks(endpoint_id=args.endpoint_id)
else:
por.refresh_status(args.stack_id)
por.refresh_status(args)

View File

@@ -141,6 +141,13 @@ class PortainerApi:
self.get_endpoints()
self.get_stacks()
def refresh_status(self, args):
for s in self.all_data['stacks']['m-s']['by_id']:
path = f'/stacks/{s}/images_status?refresh=true'
print(path)
res = self._api_get(path, timeout=args.timeout)
def _is_number(self, s):
"""Check if the input string is a number."""
try:
@@ -361,12 +368,15 @@ class PortainerApi:
print(f"failed to get containers from {path}: {e}")
continue
contr = []
print(f"Containers: {containers}")
# print(f"Containers: {containers}")
try:
for c in containers:
print(c)
cont.append([c["Names"][0].replace("/", ""),c["Id"], c['Image']])
contr.append([c["Names"][0].replace("/", ""), c["Id"], c['Image']])
# print(c)
try:
cont.append([c["Names"][0].replace("/", ""),c["Id"], c['Image']])
contr.append([c["Names"][0].replace("/", ""), c["Id"], c['Image']])
except:
print("Unable to parse container info")
if self.all_data["endpoints"]["by_id"][endpoint] in data:
data[self.all_data["endpoints"]["by_id"][endpoint]] = contr
data[endpoint] = contr
@@ -489,7 +499,7 @@ class PortainerApi:
stacks_tuples.append((s['Webhook'],s['Name']))
# print(s['Name'], " : ", s['Webhook'])
stacks_dict = dict(stacks_tuples)
print(stacks_dict)
# print(stacks_dict)
#input(stacks_tuples)
# stacks_tuples = [(s['AutoUpdate']['Webhook'], s['Name']) for s in stacks if "Webhook" in s['AutoUpdate'] ]
@@ -524,7 +534,7 @@ class PortainerApi:
if s in stack_ids:
stcs.append([s, stack_dict[s]])
print(stcs)
# print(stcs)
with ThreadPoolExecutor(max_workers=10) as exe:
list(exe.map(update, stcs))
@@ -962,7 +972,14 @@ class PortainerApi:
def update_service(self):
all_services = self.get_services(self.get_endpoint_id())
#input(all_services)
if self.args.debug:
print(all_services)
if all_services == 503:
print("No services found on this endpoint.")
return False
if len(all_services) == 0:
print("No services found on this endpoint.")
return False
service_tuples = [(s['ID'], s['Spec']['Name']) for s in all_services]
service_tuples = sorted(service_tuples, key=lambda x: x[1])
service_dict = dict(service_tuples)

View File

@@ -6,3 +6,5 @@ flake8
pylint
black
docker
hvac
prompt_toolkit