2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-15 04:07:51 +00:00

Restructure ipmi plugin logon errors

Make it so that logon errors are raised in the context
of the request(s) that actually care.
This commit is contained in:
Jarrod Johnson 2014-02-01 19:28:31 -05:00
parent 50891f235e
commit 170e7934ca
2 changed files with 22 additions and 4 deletions

View File

@ -2,7 +2,16 @@ class ConfluentException(Exception):
pass
class NotFoundException(ConfluentException):
# Something that could be construed as a name was not found
# basically, picture an http error code 404
pass
class InvalidArgumentException(ConfluentException):
# Something from the remote client wasn't correct
# like http code 400
pass
class TargetEndpointTimeout(ConfluentException):
# A target system was unavailable. For example, a BMC
# was unreachable. http code 504
pass

View File

@ -1,4 +1,5 @@
import collections
import confluent.exceptions as exc
import confluent.interface.console as conapi
import confluent.messages as msg
import eventlet
@ -231,6 +232,7 @@ class IpmiHandler(object):
global chainpulled
global _ipmithread
global pullchain
self.broken = False
if _ipmithread is None:
pullchain = os.pipe()
_ipmithread = eventlet.spawn(_ipmi_evtloop)
@ -261,8 +263,10 @@ class IpmiHandler(object):
def logged(self, response, ipmicmd):
if 'error' in response:
raise Exception(response['error'])
self.loggedin = True
self.broken = True
self.error = response['error']
else:
self.loggedin = True
def call_ipmicmd(self, function, *args):
global chainpulled
@ -279,11 +283,16 @@ class IpmiHandler(object):
self.lastrsp = response
def handle_request(self):
while not self.loggedin:
wait_on_ipmi()
bootdevices = {
'optical': 'cd'
}
while not (self.loggedin or self.broken):
wait_on_ipmi()
if self.broken:
if self.error == 'timeout':
raise exc.TargetEndpointTimeout()
else:
raise Exception(self.error)
if self.element == [ 'power', 'state' ]:
if 'read' == self.op:
power = self.call_ipmicmd(self.ipmicmd.get_power)