mirror of https://git.48k.eu/ogclient
src: add cache info to the image/restore response
Add a 'cache' field into the json payload the client sends to the server after a restore operation so the server can update the new cache contents. Resquest response structure: { ... 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] ... }master
parent
72d8943576
commit
60803fe0ed
|
@ -452,6 +452,14 @@ class OgLiveOperations:
|
||||||
|
|
||||||
logging.info('Image restore command OK')
|
logging.info('Image restore command OK')
|
||||||
|
|
||||||
|
json_dict = {
|
||||||
|
'disk': request.getDisk(),
|
||||||
|
'partition': request.getPartition(),
|
||||||
|
'image_id': request.getId(),
|
||||||
|
'cache': self._get_cache_contents(),
|
||||||
|
}
|
||||||
|
return json_dict
|
||||||
|
|
||||||
def image_create(self, request, ogRest):
|
def image_create(self, request, ogRest):
|
||||||
disk = int(request.getDisk())
|
disk = int(request.getDisk())
|
||||||
partition = int(request.getPartition())
|
partition = int(request.getPartition())
|
||||||
|
|
|
@ -170,15 +170,12 @@ class ogThread():
|
||||||
|
|
||||||
def image_restore(client, request, ogRest):
|
def image_restore(client, request, ogRest):
|
||||||
try:
|
try:
|
||||||
ogRest.operations.image_restore(request, ogRest)
|
payload = ogRest.operations.image_restore(request, ogRest)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ogRest.send_internal_server_error(client, exc=e)
|
ogRest.send_internal_server_error(client, exc=e)
|
||||||
return
|
return
|
||||||
|
|
||||||
json_body = jsonBody()
|
json_body = jsonBody(payload)
|
||||||
json_body.add_element('disk', request.getDisk())
|
|
||||||
json_body.add_element('partition', request.getPartition())
|
|
||||||
json_body.add_element('image_id', request.getId())
|
|
||||||
|
|
||||||
response = restResponse(ogResponses.OK, json_body, seq=client.seq)
|
response = restResponse(ogResponses.OK, json_body, seq=client.seq)
|
||||||
client.send(response.get())
|
client.send(response.get())
|
||||||
|
|
|
@ -457,7 +457,14 @@ class OgVirtualOperations:
|
||||||
subprocess.run([f'umount {self.OG_IMAGES_PATH}'], shell=True)
|
subprocess.run([f'umount {self.OG_IMAGES_PATH}'], shell=True)
|
||||||
self.refresh(ogRest)
|
self.refresh(ogRest)
|
||||||
|
|
||||||
return True
|
json_dict = {
|
||||||
|
'disk': request.getDisk(),
|
||||||
|
'partition': request.getPartition(),
|
||||||
|
'image_id': request.getId(),
|
||||||
|
'cache': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_dict
|
||||||
|
|
||||||
def cache_delete(self, request, ogRest):
|
def cache_delete(self, request, ogRest):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
Loading…
Reference in New Issue