mirror of
https://gitlab.sectorq.eu/jaydee/portainer.git
synced 2026-01-29 04:49:44 +01:00
Compare commits
22 Commits
fdbf41a819
...
0cbbb443f2
| Author | SHA1 | Date | |
|---|---|---|---|
| 0cbbb443f2 | |||
| 91702d8f4a | |||
| 4884ba41c4 | |||
| ec47d331d7 | |||
| cc6dc31409 | |||
| 609da77e77 | |||
| 17daad941e | |||
| cd32ad1d3e | |||
| 45a0b0030c | |||
| 5d0b488b87 | |||
| 5df457bdcb | |||
| 8f207f2fad | |||
| c0682d478d | |||
| db1710e065 | |||
| 7bac5e84c8 | |||
| 3a0117c2a5 | |||
| 8b916572cb | |||
| 498b88c7ee | |||
| 497a1f7947 | |||
| 928e4daae6 | |||
| 926248fda7 | |||
| ab9e93effe |
44
port.py
44
port.py
@@ -161,6 +161,7 @@ class Portainer:
|
|||||||
data=payload,
|
data=payload,
|
||||||
headers={"X-Gotify-Key": "ASn_fIAd5OVjm8c"}
|
headers={"X-Gotify-Key": "ASn_fIAd5OVjm8c"}
|
||||||
)
|
)
|
||||||
|
logger.debug(response.text)
|
||||||
# print("Status:", response.status_code)
|
# print("Status:", response.status_code)
|
||||||
# print("Response:", response.text)
|
# print("Response:", response.text)
|
||||||
pass
|
pass
|
||||||
@@ -886,15 +887,21 @@ class Portainer:
|
|||||||
values=service_tuples
|
values=service_tuples
|
||||||
).run()
|
).run()
|
||||||
elif self.args.service_id == "all":
|
elif self.args.service_id == "all":
|
||||||
service_ids = [s[0] for s in service_tuples if s[0] != "__ALL__" and s[0] != "__ONLY_CHECK__"]
|
service_ids = [s[0] for s in service_tuples if s[0] != "__ALL__" ]
|
||||||
else:
|
else:
|
||||||
service_ids = [self.args.service_id]
|
service_ids = [self.args.service_id]
|
||||||
if "__ONLY_CHECK__" in service_ids or self.args.update is False:
|
|
||||||
|
if self.args.update is False:
|
||||||
|
if "__ONLY_CHECK__" in service_ids:
|
||||||
|
service_ids.remove("__ONLY_CHECK__")
|
||||||
pull = False
|
pull = False
|
||||||
print("Checking for updates only...")
|
print("Checking for updates only...")
|
||||||
else:
|
else:
|
||||||
print("Checking for updates and pulling updates...")
|
|
||||||
pull = True
|
pull = True
|
||||||
|
print("Checking for updates and pulling updates...")
|
||||||
|
else:
|
||||||
|
pull = True
|
||||||
|
print("Checking for updates and pulling updates...")
|
||||||
if "__ALL__" in service_ids:
|
if "__ALL__" in service_ids:
|
||||||
service_ids = [s[0] for s in service_tuples if s[0] != "__ALL__" and s[0] != "__ONLY_CHECK__"]
|
service_ids = [s[0] for s in service_tuples if s[0] != "__ALL__" and s[0] != "__ONLY_CHECK__"]
|
||||||
|
|
||||||
@@ -923,7 +930,7 @@ class Portainer:
|
|||||||
print("?")
|
print("?")
|
||||||
elif resp['Status'] == "outdated":
|
elif resp['Status'] == "outdated":
|
||||||
if pull:
|
if pull:
|
||||||
|
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")
|
||||||
@@ -963,25 +970,30 @@ class Portainer:
|
|||||||
text="Choose a service:",
|
text="Choose a service:",
|
||||||
values=service_tuples
|
values=service_tuples
|
||||||
).run()
|
).run()
|
||||||
|
if "__ONLY_CHECK__" in service_ids:
|
||||||
|
self.args.update = False
|
||||||
|
else:
|
||||||
|
self.args.update = True
|
||||||
|
if "__ALL__" in service_ids:
|
||||||
|
service_ids = [s[0] for s in service_tuples if s[0] != "__ALL__" and s[0] != "__ONLY_CHECK__"]
|
||||||
|
|
||||||
elif self.args.service_id == "all":
|
elif self.args.service_id == "all":
|
||||||
service_ids = [s[0] for s in service_tuples if s[0] != "__ALL__" and s[0] != "__ONLY_CHECK__"]
|
service_ids = [s[0] for s in service_tuples if s[0] != "__ALL__" and s[0] != "__ONLY_CHECK__"]
|
||||||
else:
|
else:
|
||||||
service_ids = [self.args.service_id]
|
service_ids = [self.args.service_id]
|
||||||
if self.args.update is False:
|
|
||||||
if "__ONLY_CHECK__" in service_ids:
|
if self.args.update:
|
||||||
|
pull = True
|
||||||
|
print("Checking for updates and pulling updates...")
|
||||||
|
else:
|
||||||
pull = False
|
pull = False
|
||||||
print("Checking for updates only...")
|
print("Checking for updates only...")
|
||||||
else:
|
|
||||||
pull = True
|
|
||||||
print("Checking for updates and pulling updates...")
|
|
||||||
else:
|
|
||||||
pull = True
|
|
||||||
print("Checking for updates and pulling updates...")
|
|
||||||
if "__ALL__" in service_ids:
|
|
||||||
service_ids = [s[0] for s in service_tuples if s[0] != "__ALL__" and s[0] != "__ONLY_CHECK__"]
|
|
||||||
|
|
||||||
longest = 0
|
longest = 0
|
||||||
for a in service_dict.items():
|
for a in service_dict.items():
|
||||||
|
if a[0] == "__ONLY_CHECK__":
|
||||||
|
continue
|
||||||
# print(a[1])
|
# print(a[1])
|
||||||
if len(a[1]) > longest:
|
if len(a[1]) > longest:
|
||||||
longest = len(a[1])
|
longest = len(a[1])
|
||||||
@@ -1082,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)
|
||||||
@@ -1097,7 +1109,7 @@ class Portainer:
|
|||||||
params={"serviceID": service_id, "pullImage": pool}
|
params={"serviceID": service_id, "pullImage": pool}
|
||||||
try:
|
try:
|
||||||
resp = self._api_put(path, json=params, timeout=20)
|
resp = self._api_put(path, json=params, timeout=20)
|
||||||
print(resp)
|
# print(resp)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
print(f"Error restarting service: {e}")
|
print(f"Error restarting service: {e}")
|
||||||
return []
|
return []
|
||||||
|
|||||||
@@ -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.14"
|
VERSION = "0.1.15"
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
"endpoint_id": "vm01",
|
"endpoint_id": "vm01",
|
||||||
@@ -163,7 +163,7 @@ update_configs(cur_config)
|
|||||||
if args.debug:
|
if args.debug:
|
||||||
input(cur_config)
|
input(cur_config)
|
||||||
|
|
||||||
_LOG_LEVEL = "INFO"
|
_LOG_LEVEL = "DEBUG"
|
||||||
LOG_FILE = "/tmp/portainer.log"
|
LOG_FILE = "/tmp/portainer.log"
|
||||||
if _LOG_LEVEL == "DEBUG":
|
if _LOG_LEVEL == "DEBUG":
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
|
|||||||
Reference in New Issue
Block a user