From bd98dd1da0fb1fed0066bb9477c78a2569bd547b Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Tue, 4 May 2021 15:42:44 +0000 Subject: #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. --- src/ogRest.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/ogRest.py') 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()) -- cgit v1.2.3-18-g5258