diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-05-23 11:17:35 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-05-30 17:22:23 +0200 |
commit | 8de2b785a9be79f9cc0caa0011293f95a42d4d31 (patch) | |
tree | 660b9c7088f56e3d9a768c05fe1a0f65b296bc69 /src/ogRest.py | |
parent | e2d48ba3a0909f34afcf286ece339aa6a426678c (diff) |
src: add POST cache/delete method
Add API REST method to delete cache contents.
Resquest payload structure:
{
'images': ['windows.img', 'linux.img']
}
The client will try to delete as many images in cache as available
with names matching the list of filenames in the 'images' field.
Resquest response structure:
{
'cache': [
{'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'},
{'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'}
]
}
Diffstat (limited to 'src/ogRest.py')
-rw-r--r-- | src/ogRest.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/ogRest.py b/src/ogRest.py index 5d6c746..ad57c8c 100644 --- a/src/ogRest.py +++ b/src/ogRest.py @@ -215,6 +215,19 @@ class ogThread(): client.send(response.get()) ogRest.state = ThreadState.IDLE + def cache_delete(client, request, ogRest): + try: + out = ogRest.operations.cache_delete(request, ogRest) + except Exception as e: + ogRest.send_internal_server_error(client, exc=e) + return + + json_body = jsonBody(out) + + response = restResponse(ogResponses.OK, json_body, seq=client.seq) + client.send(response.get()) + ogRest.state = ThreadState.IDLE + def refresh(client, ogRest): try: out = ogRest.operations.refresh(ogRest) @@ -328,6 +341,8 @@ class ogRest(): self.process_stop(client) elif ("image/create" in URI): self.process_imagecreate(client, request) + elif ("cache/delete" in URI): + self.process_cache_delete(client, request) else: logging.warn('Unsupported request: %s', URI[:ogRest.LOG_LENGTH]) @@ -430,5 +445,8 @@ class ogRest(): def process_imagecreate(self, client, request): threading.Thread(target=ogThread.image_create, args=(client, request, self,)).start() + def process_cache_delete(self, client, request): + threading.Thread(target=ogThread.cache_delete, args=(client, request, self,)).start() + def process_refresh(self, client): threading.Thread(target=ogThread.refresh, args=(client, self,)).start() |