mirror of
https://github.com/xcat2/confluent.git
synced 2025-02-16 18:49:04 +00:00
Fix some error handling situations
The socket API was not wrapping enough output. Also fix 'databynode' reporting for noderange based commands and have the 'sensor not found' event fall in that realm.
This commit is contained in:
parent
77284af60d
commit
4beef5bb25
@ -54,7 +54,7 @@ class ConfluentMessage(object):
|
||||
|
||||
def json(self):
|
||||
# This will create the canonical json representation of this message
|
||||
if self.stripped:
|
||||
if hasattr(self, 'stripped') and self.stripped:
|
||||
datasource = self.kvpairs
|
||||
else:
|
||||
datasource = {'databynode': self.kvpairs}
|
||||
@ -65,7 +65,7 @@ class ConfluentMessage(object):
|
||||
"""Return pythonic representation of the response.
|
||||
|
||||
Used by httpapi while assembling data prior to json serialization"""
|
||||
if self.stripped:
|
||||
if hasattr(self, 'stripped') and self.stripped:
|
||||
return self.kvpairs
|
||||
return {'databynode': self.kvpairs}
|
||||
|
||||
@ -155,7 +155,7 @@ class ConfluentNodeError(object):
|
||||
self.error = errorstr
|
||||
|
||||
def raw(self):
|
||||
return {self.node: {'error': self.error}}
|
||||
return {'databynode': {self.node: {'error': self.error}}}
|
||||
|
||||
def html(self):
|
||||
return self.node + ":" + self.error
|
||||
@ -175,6 +175,14 @@ class ConfluentTargetTimeout(ConfluentNodeError):
|
||||
raise exc.TargetEndpointUnreachable
|
||||
|
||||
|
||||
class ConfluentTargetNotFound(ConfluentNodeError):
|
||||
def __init__(self, node, errorstr='not found'):
|
||||
self.node = node
|
||||
self.error = errorstr
|
||||
|
||||
def strip_node(self, node):
|
||||
raise exc.NotFoundException(self.error)
|
||||
|
||||
class ConfluentTargetInvalidCredentials(ConfluentNodeError):
|
||||
def __init__(self, node):
|
||||
self.node = node
|
||||
|
@ -329,7 +329,10 @@ class IpmiHandler(object):
|
||||
else:
|
||||
self.make_sensor_map()
|
||||
if sensorname not in self.sensormap:
|
||||
raise exc.NotFoundException('No such sensor')
|
||||
self.output.put(
|
||||
msg.ConfluentTargetNotFound(self.node,
|
||||
'Sensor not found'))
|
||||
return
|
||||
reading = self.ipmicmd.get_sensor_reading(
|
||||
self.sensormap[sensorname])
|
||||
self.output.put(
|
||||
|
@ -123,6 +123,14 @@ def sessionhdl(connection, authname, skipauth=False):
|
||||
tlvdata.send(connection, {'errorcode': 501,
|
||||
'error': 'Not Implemented'})
|
||||
tlvdata.send(connection, {'_requestdone': 1})
|
||||
except exc.NotFoundException as nfe:
|
||||
tlvdata.send(connection, {'errorcode': 404,
|
||||
'error': str(nfe)})
|
||||
tlvdata.send(connection, {'_requestdone': 1})
|
||||
except exc.InvalidArgumentException as iae:
|
||||
tlvdata.send(connection, {'errorcode': 400,
|
||||
'error': 'Bad Request - ' + str(iae)})
|
||||
tlvdata.send(connection, {'_requestdone': 1})
|
||||
except SystemExit:
|
||||
sys.exit(0)
|
||||
except:
|
||||
|
Loading…
x
Reference in New Issue
Block a user