summaryrefslogtreecommitdiffstats
path: root/src/ogRest.py
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2021-05-04 15:42:44 +0000
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-05-04 18:30:40 +0200
commitbd98dd1da0fb1fed0066bb9477c78a2569bd547b (patch)
tree9c5b254910421f6a6b6b18754f37854b10be3eec /src/ogRest.py
parent8b959c8be9639ac481be528ba8bc5a98f1cf51b2 (diff)
#995 Add link speed in probe responses
Separates probe method into separate ogclient modes (virtual, vdi) so future supported OS can easily have a tailored probe responses. Link speed is retrieved using a minimal ethtool command sent using fcntl module from python.
Diffstat (limited to 'src/ogRest.py')
-rw-r--r--src/ogRest.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/ogRest.py b/src/ogRest.py
index bd9b65c..32519fc 100644
--- a/src/ogRest.py
+++ b/src/ogRest.py
@@ -373,16 +373,20 @@ class ogRest():
threading.Thread(target=ogThread.poweroff, args=(self,)).start()
def process_probe(self, client):
+ try:
+ status = self.operations.probe(self)
+ except:
+ response = restResponse(ogResponses.INTERNAL_ERR)
+ client.send(response.get())
+ return
+
json_body = jsonBody()
+ for k, v in status.items():
+ json_body.add_element(k, v)
if self.state != ThreadState.BUSY:
- if self.mode == 'live':
- json_body.add_element('status', 'OPG')
- elif self.mode == 'virtual':
- json_body.add_element('status', 'VDI')
response = restResponse(ogResponses.OK, json_body)
else:
- json_body.add_element('status', 'BSY')
response = restResponse(ogResponses.IN_PROGRESS, json_body)
client.send(response.get())