This commit is contained in:
2025-12-04 23:13:54 +01:00
parent f328118f65
commit 493f16281c
2 changed files with 88 additions and 76 deletions

View File

@@ -110,6 +110,10 @@ class Portainer:
self.get_stacks()
self.get_containers()
def set_defaults(self, config):
'''Set default configuration from provided config dictionary.'''
self.cur_config = config
def get_site(self, site):
if site == "portainer":
self.base_url = os.getenv(
@@ -698,6 +702,7 @@ class Portainer:
stacks = self.get_stacks()
count = 0
data = []
stack_names = []
for stack in stacks:
if endpoint is not None:
if not stack["EndpointId"] in self.endpoints["by_id"]:
@@ -706,6 +711,7 @@ class Portainer:
if self.endpoints["by_name"][endpoint] != stack["EndpointId"]:
continue
try:
stack_names.append(stack["Name"])
data.append(
[
stack["Id"],
@@ -723,6 +729,7 @@ class Portainer:
headers = ["StackID", "Name", "Endpoint"]
print(tabulate.tabulate(data, headers=headers, tablefmt="github"))
print(f"Total stacks: {count}")
# print(sorted(stack_names))
def start_stack(self, stack=None, endpoint_id=None):
"""Start one stack or all stacks on an endpoint."""