This commit is contained in:
2025-12-19 17:23:20 +01:00
parent 9c6445ee03
commit 174aab4faa
2 changed files with 42 additions and 34 deletions

10
port.py
View File

@@ -315,6 +315,7 @@ class Portainer:
def get_endpoint_id(self): def get_endpoint_id(self):
'''Get endpoint ID from either ID or name input.''' '''Get endpoint ID from either ID or name input.'''
# input(self.args.endpoint_id)
if self._is_number(self.args.endpoint_id): if self._is_number(self.args.endpoint_id):
self.endpoint_id = self.args.endpoint_id self.endpoint_id = self.args.endpoint_id
self.endpoint_name = self.endpoints["by_id"][self.args.endpoint_id] self.endpoint_name = self.endpoints["by_id"][self.args.endpoint_id]
@@ -394,14 +395,13 @@ class Portainer:
else: else:
eps = [self.get_endpoint_id()] eps = [self.get_endpoint_id()]
#input(eps)
for endpoint in eps:
# print(s) for endpoint in eps:
#print(self.args.stack) #print(self.args.stack)
if self.args.stack in ["all", None]: if self.args.stack in ["all", None]:
# input([id for id in self.all_data["stacks"][endpoint]['by_id'].keys()]) # input([id for id in self.all_data["stacks"][endpoint]['by_id'].keys()])
for s in [id for id in self.all_data["stacks"][endpoint]['by_id'].keys()]: for e in [id for id in self.all_data["stacks"][endpoint]['by_name'].keys()]:
#input(e)
# if s not in self.all_data["stacks"]: # if s not in self.all_data["stacks"]:
# continue # continue
#input(self.all_data) #input(self.all_data)
@@ -409,7 +409,7 @@ class Portainer:
# print(f"Endpoint {self.all_data["endpoints"]["by_id"][s]} is offline") # print(f"Endpoint {self.all_data["endpoints"]["by_id"][s]} is offline")
continue continue
# input(self.all_data["stacks"][endpoint]["by_name"]) # input(self.all_data["stacks"][endpoint]["by_name"])
for e in self.all_data["stacks"][endpoint]["by_name"]:
#input(e) #input(e)
path = ( path = (
f"/endpoints/{endpoint}/docker/containers/json" f"/endpoints/{endpoint}/docker/containers/json"

View File

@@ -579,7 +579,15 @@ if __name__ == "__main__":
if args.action == "list_containers": if args.action == "list_containers":
print("Getting containers") print("Getting containers")
print(por.get_containers()) args = prompt_missing_args(
args,
cur_config,
[
("site", "Site"),
("endpoint_id", "Endpoint ID"),
],
)
print("\n".join(por.get_containers()))
sys.exit() sys.exit()
if args.action == "update_stack": if args.action == "update_stack":