mirror of
https://gitlab.sectorq.eu/jaydee/portainer.git
synced 2026-05-04 13:59:51 +02:00
build
This commit is contained in:
@@ -302,6 +302,7 @@ def prompt_missing_args(args_in, defaults_in, fields, action=None,stacks=None):
|
||||
commands.sort()
|
||||
commands_tuples = [(cmd, cmd) for cmd in commands]
|
||||
commands_tuples.insert(0, ("__ALL__", "[Select ALL]"))
|
||||
commands_tuples.insert(0, ("mandatory", "[Mandatory]"))
|
||||
value_in = checkboxlist_dialog(
|
||||
title="Select Services",
|
||||
text="Choose one or more services:",
|
||||
@@ -314,12 +315,14 @@ def prompt_missing_args(args_in, defaults_in, fields, action=None,stacks=None):
|
||||
elif "__ALL__" in value_in:
|
||||
# User selected "Select ALL"
|
||||
value_in = commands # all real commands
|
||||
|
||||
elif "mandatory" in value_in:
|
||||
# User selected "Select ALL"
|
||||
value_in = ['pihole', 'nginx', 'authentik', 'hashicorp', 'mosquitto','homepage', 'mailu3', 'home-assistant', 'mediacenter' ] # all real commands
|
||||
|
||||
value_in.sort()
|
||||
|
||||
if "pihole" in value_in:
|
||||
if action == "delete_stack":
|
||||
if args.action == "delete_stack":
|
||||
value_in.remove("pihole")
|
||||
value_in.append("pihole")
|
||||
else:
|
||||
|
||||
+38
-11
@@ -657,6 +657,11 @@ class PortainerApi:
|
||||
stack_mode="swarm",
|
||||
):
|
||||
for stack in stacks:
|
||||
if self.endpoint_name == "nas":
|
||||
server = "_nas"
|
||||
else:
|
||||
server = ""
|
||||
|
||||
if stack_mode == "swarm":
|
||||
swarm_id = self.get_swarm_id(endpoint)
|
||||
p = "swarm"
|
||||
@@ -748,8 +753,8 @@ class PortainerApi:
|
||||
},
|
||||
"repositoryURL": "https://gitlab.sectorq.eu/home/docker-compose.git",
|
||||
"ReferenceName": "refs/heads/main",
|
||||
"composeFile": f"{stack}/docker-compose.yml",
|
||||
"ConfigFilePath": f"{stack}/docker-compose.yml",
|
||||
"composeFile": f"{stack}/docker-compose{server}.yml",
|
||||
"ConfigFilePath": f"{stack}/docker-compose{server}.yml",
|
||||
"repositoryAuthentication": True,
|
||||
"repositoryUsername": "jaydee",
|
||||
"repositoryPassword": "glpat-uj-n-eEfTY398PE4vKSS",
|
||||
@@ -1208,25 +1213,36 @@ class PortainerApi:
|
||||
|
||||
def start_stack(self, stack=None, endpoint_id=None):
|
||||
"""Start one stack or all stacks on an endpoint."""
|
||||
ok = "\033[92m✔\033[0m"
|
||||
ok2 = "\033[93m✔\033[0m"
|
||||
err = "\033[91m✖\033[0m"
|
||||
if endpoint_id is not None:
|
||||
print("Getting endpoint")
|
||||
self.get_endpoint(endpoint_id)
|
||||
size = 0
|
||||
if stack is not None:
|
||||
for s in stack:
|
||||
if len(s) > size:
|
||||
size = len(s)
|
||||
self.stack_ids.append(self._resolve_stack_id(s, endpoint_id))
|
||||
size = size + 5
|
||||
for stck in self.stack_ids:
|
||||
print(
|
||||
f"Starting stack {self.stacks_all[self.endpoint_id]['by_id'][stck][:size].ljust(size)}",
|
||||
end="", flush=True
|
||||
)
|
||||
path = f"/stacks/{stck}/start"
|
||||
if self.endpoint_id is not None:
|
||||
path += f"?endpointId={self.endpoint_id}"
|
||||
try:
|
||||
resp = self._api_post_no_body(path, timeout=20)
|
||||
resp = self._api_post_no_body(path, timeout=120)
|
||||
except ValueError as e:
|
||||
print(f"Error stoping stack: {e}")
|
||||
print(f"Error starting stack: {e}")
|
||||
return []
|
||||
if "Id" in json.loads(resp):
|
||||
print(
|
||||
f"Stack {self.stacks_all[self.endpoint_id]['by_id'][stck]} : started"
|
||||
)
|
||||
print(ok)
|
||||
elif "already running" in json.loads(resp)['message']:
|
||||
print(ok2)
|
||||
else:
|
||||
print(
|
||||
f"Stack {self.stacks_all[self.endpoint_id]['by_id'][stck]} : {json.loads(resp)['message']}"
|
||||
@@ -1238,14 +1254,25 @@ class PortainerApi:
|
||||
|
||||
"""Stop one stack or all stacks on an endpoint."""
|
||||
# print(f"Stopping stack {stack}")
|
||||
|
||||
ok = "\033[92m✔\033[0m"
|
||||
ok2 = "\033[93m✔\033[0m"
|
||||
err = "\033[91m✖\033[0m"
|
||||
if endpoint_id is not None:
|
||||
self.get_endpoint(endpoint_id)
|
||||
size = 0
|
||||
if stack is not None:
|
||||
for s in stack:
|
||||
if size < len(s):
|
||||
size = len(s)
|
||||
self.stack_ids.append(self._resolve_stack_id(s, endpoint_id))
|
||||
size = size + 5
|
||||
self.stack_ids = list(dict.fromkeys(self.stack_ids))
|
||||
for stck in self.stack_ids:
|
||||
print(
|
||||
f"Stopping stack {self.stacks_all[self.endpoint_id]['by_id'][stck][:size].ljust(size)}",
|
||||
end="",
|
||||
flush=True
|
||||
)
|
||||
path = f"/stacks/{stck}/stop"
|
||||
# print(path)
|
||||
if self.endpoint_id is not None:
|
||||
@@ -1256,9 +1283,9 @@ class PortainerApi:
|
||||
print(f"Error stopping stack: {e}")
|
||||
return []
|
||||
if "Id" in json.loads(resp):
|
||||
print(
|
||||
f"Stack {self.stacks_all[self.endpoint_id]['by_id'][stck]} : stopped"
|
||||
)
|
||||
print(ok)
|
||||
elif "already inactive" in json.loads(resp)['message']:
|
||||
print(ok2)
|
||||
else:
|
||||
print(
|
||||
f"Stack {self.stacks_all[self.endpoint_id]['by_id'][stck]} : {json.loads(resp)['message']}"
|
||||
|
||||
Reference in New Issue
Block a user