mirror of
https://gitlab.sectorq.eu/jaydee/portainer.git
synced 2026-01-29 04:49:44 +01:00
Compare commits
6 Commits
174aab4faa
...
63e158899e
| Author | SHA1 | Date | |
|---|---|---|---|
| 63e158899e | |||
| 9336b56f96 | |||
| 66fba7b994 | |||
| 7804dbb117 | |||
| fb1763e14d | |||
| 829891d1ba |
8
port.py
8
port.py
@@ -873,7 +873,7 @@ class Portainer:
|
|||||||
def update_containers(self):
|
def update_containers(self):
|
||||||
all_containers = self.all_data["containers"][self.args.endpoint_id]
|
all_containers = self.all_data["containers"][self.args.endpoint_id]
|
||||||
#input(all_containers)
|
#input(all_containers)
|
||||||
service_tuples = [(s[1], s[0]) for s in all_containers if "." not in s[0]]
|
service_tuples = [(s[1], s[0]) for s in all_containers if "." not in s[0] and not s[0].startswith("runner-")]
|
||||||
service_tuples = sorted(service_tuples, key=lambda x: x[1])
|
service_tuples = sorted(service_tuples, key=lambda x: x[1])
|
||||||
service_dict = dict(service_tuples)
|
service_dict = dict(service_tuples)
|
||||||
# input(service_tuples)
|
# input(service_tuples)
|
||||||
@@ -930,7 +930,7 @@ class Portainer:
|
|||||||
print("?")
|
print("?")
|
||||||
elif resp['Status'] == "outdated":
|
elif resp['Status'] == "outdated":
|
||||||
if pull:
|
if pull:
|
||||||
print("Recreate")
|
#print("Recreate")
|
||||||
self.recreate_container(service_id, pull)
|
self.recreate_container(service_id, pull)
|
||||||
#print(f"Service {service_dict[service_id]:<{longest}} : updated")
|
#print(f"Service {service_dict[service_id]:<{longest}} : updated")
|
||||||
self.gotify_message(f"Service {service_dict[service_id]} updated")
|
self.gotify_message(f"Service {service_dict[service_id]} updated")
|
||||||
@@ -1016,7 +1016,7 @@ class Portainer:
|
|||||||
self.restart_srv(service_id, pull)
|
self.restart_srv(service_id, pull)
|
||||||
#print(f"Service {service_dict[service_id]:<{longest}} : updated")
|
#print(f"Service {service_dict[service_id]:<{longest}} : updated")
|
||||||
self.gotify_message(f"Service {service_dict[service_id]} updated")
|
self.gotify_message(f"Service {service_dict[service_id]} updated")
|
||||||
print(ok)
|
print(f"{ok} updated")
|
||||||
else:
|
else:
|
||||||
print(f"\r\033[4m{service_dict[service_id]:<{longest}}\033[0m ", end="", flush=True)
|
print(f"\r\033[4m{service_dict[service_id]:<{longest}}\033[0m ", end="", flush=True)
|
||||||
#print(f"\033[4m{service_dict[service_id]:<{longest}} {err}\033[0m")
|
#print(f"\033[4m{service_dict[service_id]:<{longest}} {err}\033[0m")
|
||||||
@@ -1094,7 +1094,7 @@ class Portainer:
|
|||||||
def recreate_container(self,service_id, pull=False):
|
def recreate_container(self,service_id, pull=False):
|
||||||
"""Restart a service on an endpoint."""
|
"""Restart a service on an endpoint."""
|
||||||
path = f"/docker/{self.endpoint_id}/containers/{service_id}/recreate"
|
path = f"/docker/{self.endpoint_id}/containers/{service_id}/recreate"
|
||||||
print(path)
|
# print(path)
|
||||||
params={"pullImage": pull}
|
params={"pullImage": pull}
|
||||||
try:
|
try:
|
||||||
resp = self._api_post(path, json=params, timeout=20)
|
resp = self._api_post(path, json=params, timeout=20)
|
||||||
|
|||||||
13
portainer.py
13
portainer.py
@@ -39,7 +39,7 @@ else:
|
|||||||
raise Exception("Failed to authenticate with Vault")
|
raise Exception("Failed to authenticate with Vault")
|
||||||
# Specify the mount point of your KV engine
|
# Specify the mount point of your KV engine
|
||||||
|
|
||||||
VERSION = "0.1.16"
|
VERSION = "0.1.17"
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
"endpoint_id": "vm01",
|
"endpoint_id": "vm01",
|
||||||
@@ -372,7 +372,7 @@ def prompt_missing_args(args_in, defaults_in, fields, action=None,stacks=None):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Example usage: set PORTAINER_USER and PORTAINER_PASS in env, or pass literals below.
|
# Example usage: set PORTAINER_USER and PORTAINER_PASS in env, or pass literals below.
|
||||||
# token = get_portainer_token(base,"admin","l4c1j4yd33Du5lo") # or get_portainer_token(base, "admin", "secret")
|
|
||||||
def signal_handler(sig, frame):
|
def signal_handler(sig, frame):
|
||||||
logger.warning("Killed manually %s, %s", sig, frame)
|
logger.warning("Killed manually %s, %s", sig, frame)
|
||||||
print("\nTerminated by user")
|
print("\nTerminated by user")
|
||||||
@@ -621,6 +621,15 @@ if __name__ == "__main__":
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if args.action == "stop_containers":
|
if args.action == "stop_containers":
|
||||||
|
# TODO: does not work
|
||||||
|
args = prompt_missing_args(
|
||||||
|
args,
|
||||||
|
cur_config,
|
||||||
|
[
|
||||||
|
("site", "Site"),
|
||||||
|
("endpoint_id", "Endpoint ID"),
|
||||||
|
],
|
||||||
|
)
|
||||||
if por.all_data["endpoints_status"][args.endpoint_id] != 1:
|
if por.all_data["endpoints_status"][args.endpoint_id] != 1:
|
||||||
print(f"Endpoint {por.get_endpoint_name(args.endpoint_id)} is offline")
|
print(f"Endpoint {por.get_endpoint_name(args.endpoint_id)} is offline")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|||||||
Reference in New Issue
Block a user