2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-12-25 12:41:39 +00:00

Relay target unreachable condition to client

If connectivity is lost in the midst of an interrogation,
relay the unreachable status to the client rather than
'Internal Error' that was occuring before.
This commit is contained in:
Jarrod Johnon 2015-01-22 13:56:16 -05:00
parent bd108d62ce
commit 98a3f6fcdc
2 changed files with 33 additions and 22 deletions

View File

@ -58,6 +58,7 @@ class RobustCookie(Cookie.SimpleCookie):
# empty value if SimpleCookie rejects
dict.__setitem__(self, K, Cookie.Morsel())
def group_creation_resources():
yield confluent.messages.Attributes(
kv={'name': None}, desc="Name of the group").html() + '<br>'

View File

@ -312,26 +312,29 @@ class IpmiHandler(object):
def read_sensors(self, sensorname):
if sensorname == 'all':
sensors = self.ipmicmd.get_sensor_descriptions()
readings = []
for sensor in filter(self.match_sensor, sensors):
try:
reading = self.ipmicmd.get_sensor_reading(sensor['name'])
except pygexc.IpmiException as ie:
if ie.ipmicode == 203:
continue
raise
readings.append(self._dict_sensor(reading))
yield msg.SensorReadings(readings, name=self.node)
else:
self.make_sensor_map()
if sensorname not in self.sensormap:
raise exc.NotFoundException('No such sensor')
reading = self.ipmicmd.get_sensor_reading(
self.sensormap[sensorname])
yield msg.SensorReadings([self._dict_sensor(reading)],
name=self.node)
try:
if sensorname == 'all':
sensors = self.ipmicmd.get_sensor_descriptions()
readings = []
for sensor in filter(self.match_sensor, sensors):
try:
reading = self.ipmicmd.get_sensor_reading(sensor['name'])
except pygexc.IpmiException as ie:
if ie.ipmicode == 203:
continue
raise
readings.append(self._dict_sensor(reading))
yield msg.SensorReadings(readings, name=self.node)
else:
self.make_sensor_map()
if sensorname not in self.sensormap:
raise exc.NotFoundException('No such sensor')
reading = self.ipmicmd.get_sensor_reading(
self.sensormap[sensorname])
yield msg.SensorReadings([self._dict_sensor(reading)],
name=self.node)
except pygexc.IpmiException:
yield msg.ConfluentTargetTimeout(self.node)
def handle_sensors(self):
if self.element[-1] == '':
@ -352,7 +355,10 @@ class IpmiHandler(object):
return False
def list_sensors(self):
sensors = self.ipmicmd.get_sensor_descriptions()
try:
sensors = self.ipmicmd.get_sensor_descriptions()
except pygexc.IpmiException:
yield msg.ConfluentTargetTimeout(self.node)
yield msg.ChildCollection('all')
for sensor in filter(self.match_sensor, sensors):
yield msg.ChildCollection(simplify_name(sensor['name']))
@ -378,7 +384,11 @@ class IpmiHandler(object):
def health(self):
if 'read' == self.op:
response = self.ipmicmd.get_health()
try:
response = self.ipmicmd.get_health()
except pygexc.IpmiException:
yield msg.ConfluentTargetTimeout(self.node)
return
health = response['health']
health = self._str_health(health)
yield msg.HealthSummary(health, self.node)