Compare commits
No commits in common. "f60c3be98703088f8436b7e3e4dd63fa952bb4c1" and "6a4d6e38133b0442dd57998060d3320cc4e89403" have entirely different histories.
f60c3be987
...
6a4d6e3813
16
.drone.yml
16
.drone.yml
@ -15,18 +15,4 @@ steps:
|
|||||||
- latest
|
- latest
|
||||||
when:
|
when:
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
- name: docker-test
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
registry: git.jbranan.com
|
|
||||||
dry_run: false
|
|
||||||
username: jblu
|
|
||||||
password:
|
|
||||||
from_secret: gittea_drone
|
|
||||||
repo: git.jbranan.com/jblu/crane
|
|
||||||
tags:
|
|
||||||
- dev
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- dev*
|
|
@ -1,7 +1,7 @@
|
|||||||
FROM python:alpine3.18
|
FROM python:alpine3.18
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
COPY . opt
|
COPY . opt
|
||||||
RUN apk add --no-cache supercronic
|
|
||||||
RUN pip install requests
|
RUN pip install requests
|
||||||
|
RUN crontab /opt/crontab
|
||||||
RUN chmod +x /opt/entrypoint.sh
|
RUN chmod +x /opt/entrypoint.sh
|
||||||
CMD ["/opt/entrypoint.sh"]
|
CMD ["/opt/entrypoint.sh"]
|
@ -5,6 +5,7 @@ def c_get_containers(req_obj, host, port, access_token, endpoint):
|
|||||||
|
|
||||||
def c_get_filtered_containers(req_obj, j_obj, host, port, access_token, endpoint, containers, statuses):
|
def c_get_filtered_containers(req_obj, j_obj, host, port, access_token, endpoint, containers, statuses):
|
||||||
filter_string = j_obj.dumps({"name":containers,"status":statuses})
|
filter_string = j_obj.dumps({"name":containers,"status":statuses})
|
||||||
|
# url = 'https://192.168.4.11:9443/api/endpoints/1/docker/containers/json?filters={"name": ["restic","qbittorrent"],"status": ["paused","dead","created","exited","removing","restarting","created"]}'
|
||||||
url = f'https://{host}:{port}/api/endpoints/{endpoint}/docker/containers/json?filters={filter_string}'
|
url = f'https://{host}:{port}/api/endpoints/{endpoint}/docker/containers/json?filters={filter_string}'
|
||||||
c_get_containers_response = req_obj.get(url, headers={"X-API-Key": access_token}, verify=False)
|
c_get_containers_response = req_obj.get(url, headers={"X-API-Key": access_token}, verify=False)
|
||||||
return c_get_containers_response.json()
|
return c_get_containers_response.json()
|
||||||
|
1
crontab
Normal file
1
crontab
Normal file
@ -0,0 +1 @@
|
|||||||
|
*/5 * * * * . /etc/environment; python /opt/crane.py >> /logfile
|
@ -1,7 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
CRON_CONFIG_FILE="/opt/crontab"
|
printenv | grep -v "no_proxy" >> /etc/environment
|
||||||
|
|
||||||
echo "${CRON} python /opt/crane.py" > $CRON_CONFIG_FILE
|
crond -f
|
||||||
|
|
||||||
exec supercronic -passthrough-logs -quiet $CRON_CONFIG_FILE
|
|
@ -2,7 +2,7 @@ import unittest
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from tomllib import load
|
from tomllib import load
|
||||||
from cclient import c_get_filtered_containers, c_start_container, c_stop_container
|
from cclient import c_get_filtered_containers, c_start_container, c_stop_container, c_get_filtered_containers
|
||||||
from cprocess import process_cont_list
|
from cprocess import process_cont_list
|
||||||
# unittest.TestLoader.sortTestMethodsUsing = None
|
# unittest.TestLoader.sortTestMethodsUsing = None
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ class TestCrane(unittest.TestCase):
|
|||||||
self.cid = 'ef8fee86e02b2b82acbddf6f0da1ff023f60bfe52c0b4087cac29c1686ccbac4'
|
self.cid = 'ef8fee86e02b2b82acbddf6f0da1ff023f60bfe52c0b4087cac29c1686ccbac4'
|
||||||
self.req_obj = requests
|
self.req_obj = requests
|
||||||
self.j_obj = json
|
self.j_obj = json
|
||||||
self.hypercare_containers = ['hello-world']
|
self.hypercare_containers = ['restic','qbittorrent']
|
||||||
self.status_filters = ["paused","dead","created","exited","removing","restarting","created"]
|
self.status_filters = ["paused","dead","created","exited","removing","restarting","created"]
|
||||||
self.cont_obj = c_get_filtered_containers(self.req_obj,self.j_obj, self.host, self.port, self.access_token, self.endpoint,self.hypercare_containers,self.status_filters)
|
self.cont_obj = c_get_filtered_containers(self.req_obj,self.j_obj, self.host, self.port, self.access_token, self.endpoint,self.hypercare_containers,self.status_filters)
|
||||||
|
|
||||||
|
12
test_pushover.py
Normal file
12
test_pushover.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import pushover
|
||||||
|
from tomllib import load
|
||||||
|
|
||||||
|
with open('./config.toml', mode="rb") as c:
|
||||||
|
config = load(c)
|
||||||
|
|
||||||
|
po_key = config["pushover"]["po_key"]
|
||||||
|
po_token = config["pushover"]["po_token"]
|
||||||
|
|
||||||
|
message = "hello"
|
||||||
|
|
||||||
|
# pushover.Pushover(po_token).message(po_key, message, title="--- crane summary ---")
|
6
test_toml.py
Normal file
6
test_toml.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from tomllib import load
|
||||||
|
|
||||||
|
with open('./config.toml', mode="rb") as c:
|
||||||
|
config = load(c)
|
||||||
|
|
||||||
|
print(config["containers"].values())
|
Loading…
x
Reference in New Issue
Block a user