mirror of
https://gitlab.sectorq.eu/jaydee/portainer.git
synced 2025-12-14 02:34:53 +01:00
build
This commit is contained in:
98
port.py
98
port.py
@@ -2,15 +2,15 @@ import os
|
||||
import requests
|
||||
import json
|
||||
import uuid
|
||||
import argparse
|
||||
import shutil
|
||||
import time
|
||||
import logging
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
from tabulate import tabulate
|
||||
from git import Repo # pip install gitpython
|
||||
import base64
|
||||
|
||||
|
||||
class Portainer:
|
||||
"""
|
||||
Simple wrapper around the module-level Portainer helper functions.
|
||||
@@ -28,22 +28,83 @@ class Portainer:
|
||||
self.stack_ids = []
|
||||
self.endpoint_name = None
|
||||
self.endpoint_id = None
|
||||
#self.git_url = "https://gitlab.sectorq.eu/home/docker-compose.git"
|
||||
# self.git_url = "https://gitlab.sectorq.eu/home/docker-compose.git"
|
||||
self.git_url = "git@gitlab.sectorq.eu:home/docker-compose.git"
|
||||
self.repo_dir = "/tmp/docker-compose"
|
||||
self.basic_stacks = ["pihole","nginx", "mosquitto", "webhub", "authentik","bitwarden","mailu3","home-assistant","homepage"]
|
||||
self.nas_stacks = self.basic_stacks + ["gitlab", "bookstack","dockermon","gitea","grafana","immich","jupyter","kestra","mealie"]
|
||||
self.m_server_stacks = self.basic_stacks + ['immich', 'zabbix-server', 'gitea', 'unifibrowser', 'mediacenter', 'watchtower', 'wazuh', 'octoprint', 'motioneye', 'kestra', 'bookstack', 'wud', 'uptime-kuma', 'registry', 'regsync', 'dockermon', 'grafana', 'nextcloud', 'semaphore', 'node-red', 'test', 'jupyter', 'paperless', 'mealie', 'n8n', 'ollama', 'rancher']
|
||||
self.rpi5_stacks = self.basic_stacks + ["gitlab","bookstack","gitea"]
|
||||
self.rack_stacks = self.basic_stacks + ["gitlab", "bookstack","dockermon","gitea","grafana","immich","jupyter","kestra","mealie"]
|
||||
self.basic_stacks = [
|
||||
"pihole",
|
||||
"nginx",
|
||||
"mosquitto",
|
||||
"webhub",
|
||||
"authentik",
|
||||
"bitwarden",
|
||||
"mailu3",
|
||||
"home-assistant",
|
||||
"homepage"
|
||||
]
|
||||
self.nas_stacks = self.basic_stacks + [
|
||||
"gitlab",
|
||||
"bookstack",
|
||||
"dockermon",
|
||||
"gitea",
|
||||
"grafana",
|
||||
"immich",
|
||||
"jupyter",
|
||||
"kestra",
|
||||
"mealie"
|
||||
]
|
||||
self.m_server_stacks = self.basic_stacks + [
|
||||
'immich',
|
||||
'zabbix-server',
|
||||
'gitea',
|
||||
'unifibrowser',
|
||||
'mediacenter',
|
||||
'watchtower',
|
||||
'wazuh',
|
||||
'octoprint',
|
||||
'motioneye',
|
||||
'kestra',
|
||||
'bookstack',
|
||||
'wud',
|
||||
'uptime-kuma',
|
||||
'registry',
|
||||
'regsync',
|
||||
'dockermon',
|
||||
'grafana',
|
||||
'nextcloud',
|
||||
'semaphore',
|
||||
'node-red',
|
||||
'test',
|
||||
'jupyter',
|
||||
'paperless',
|
||||
'mealie',
|
||||
'n8n',
|
||||
'ollama',
|
||||
'rancher'
|
||||
]
|
||||
self.rpi5_stacks = self.basic_stacks + [
|
||||
"gitlab",
|
||||
"bookstack",
|
||||
"gitea"
|
||||
]
|
||||
self.rack_stacks = self.basic_stacks + [
|
||||
"gitlab",
|
||||
"bookstack",
|
||||
"dockermon",
|
||||
"gitea",
|
||||
"grafana",
|
||||
"immich",
|
||||
"jupyter",
|
||||
"kestra",
|
||||
"mealie"
|
||||
]
|
||||
self.log_mode = False
|
||||
self.hw_mode = False
|
||||
self.all_data = {"containers":{},"stacks":{},"endpoints":{}}
|
||||
self.all_data = {"containers": {}, "stacks": {}, "endpoints": {}}
|
||||
self.get_endpoints()
|
||||
self.get_stacks()
|
||||
self.get_containers()
|
||||
|
||||
|
||||
|
||||
def is_number(self, s):
|
||||
"""Check if the input string is a number."""
|
||||
try:
|
||||
@@ -62,11 +123,11 @@ class Portainer:
|
||||
def api_post(self, path, json="", timeout=120):
|
||||
url = f"{self.base_url.rstrip('/')}{path}"
|
||||
headers = {"X-API-Key": f"{self.token}"}
|
||||
#print(url)
|
||||
#print(json)
|
||||
# print(url)
|
||||
# print(json)
|
||||
resp = requests.post(url, headers=headers, json=json, timeout=timeout)
|
||||
return resp.text
|
||||
|
||||
|
||||
def api_post_file(self, path, endpoint_id, name, envs, file, timeout=120):
|
||||
#input("API POST2 called. Press Enter to continue.")
|
||||
"""Example authenticated GET request to Portainer API."""
|
||||
@@ -361,18 +422,15 @@ class Portainer:
|
||||
self.endpoint_id = self.get_endpoint_id(endpoint)
|
||||
if os.path.exists(self.repo_dir):
|
||||
shutil.rmtree(self.repo_dir)
|
||||
print(f"Folder '{self.repo_dir}' has been removed.")
|
||||
else:
|
||||
print(f"Folder '{self.repo_dir}' does not exist.")
|
||||
Repo.clone_from(self.git_url, self.repo_dir)
|
||||
if mode == "git":
|
||||
print("Creating new stack from git repo...")
|
||||
path = f"/stacks/create/{p}/repository"
|
||||
|
||||
if self.endpoint_id is not None:
|
||||
path += f"?endpointId={self.endpoint_id}"
|
||||
|
||||
print(path)
|
||||
|
||||
|
||||
if stack == "all":
|
||||
if self.endpoint_name == "rack":
|
||||
|
||||
Reference in New Issue
Block a user