summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-04-23 12:40:57 +0300
committerLars Wirzenius <liw@liw.fi>2018-04-23 12:53:09 +0300
commite826bfcbc6ca6c16da0941125f7675d49f5a413e (patch)
treedee5d472908c27a2ab272511a75345273ecf6663
parent85dd5c6551845ebc34c490f7fbc27a02d307f206 (diff)
downloadick2-e826bfcbc6ca6c16da0941125f7675d49f5a413e.tar.gz
Add: don't have a PUT for workers, log created worker
-rw-r--r--ick2/workerapi.py36
-rwxr-xr-x[-rw-r--r--]start_ick12
2 files changed, 46 insertions, 2 deletions
diff --git a/ick2/workerapi.py b/ick2/workerapi.py
index 5a7e835..bed14b4 100644
--- a/ick2/workerapi.py
+++ b/ick2/workerapi.py
@@ -21,5 +21,41 @@ class WorkerAPI(ick2.ResourceApiBase): # pragma: no cover
def __init__(self, state):
super().__init__('workers', state)
+ def get_routes(self, path):
+ return [
+ {
+ 'method': 'POST',
+ 'path': path,
+ 'callback': self.POST(self.create),
+ },
+ {
+ 'method': 'GET',
+ 'path': path,
+ 'callback': self.GET(self.list),
+ },
+ {
+ 'method': 'GET',
+ 'path': '{}/<name>'.format(path),
+ 'callback': self.GET(self.show),
+ },
+ {
+ 'method': 'DELETE',
+ 'path': '{}/<name>'.format(path),
+ 'callback': self.DELETE(self.delete),
+ },
+ ]
+
def get_resource_name(self, resource):
return resource['worker']
+
+ def create(self, body, **kwargs):
+ ick2.log.log(
+ 'trace', msg_text='create worker', body=body, kwargs=kwargs)
+ resource = self.mangle_new_resource(body)
+ name = self.get_resource_name(resource)
+ try:
+ self._state.get_resource(self._type_name, name)
+ except ick2.NotFound:
+ return self._state.add_resource(self._type_name, name, resource)
+ else:
+ raise ick2.ExistsAlready(name)
diff --git a/start_ick b/start_ick
index 96f745c..8c9d50f 100644..100755
--- a/start_ick
+++ b/start_ick
@@ -16,9 +16,17 @@
set -eux
-export ICK_CONTROLLER_CONFIG=/etc/ick/controller.yaml
+if [ "$#" = 1 ]
+then
+ export ICK_CONTROLLER_CONFIG="$1"
+ export GUNICORN_LOG=gunicorn3.log
+else
+ export ICK_CONTROLLER_CONFIG=/etc/ick/controller.yaml
+ export GUNICORN_LOG=/var/log/ick/gunicorn3.log
+fi
+
gunicorn3 \
--bind 127.0.0.1:12765 \
- --log-file /var/log/ick/gunicorn3.log \
+ --log-file "$GUNICORN_LOG" \
--log-level debug \
ick_controller:app