mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 19:10:10 +00:00
Provide helpful error on bad user/password in delta pdu
This commit is contained in:
parent
25c66e163c
commit
0c08d8f6d3
@ -155,7 +155,9 @@ class PDUClient(object):
|
||||
if not username or not passwd:
|
||||
raise Exception('Missing username or password')
|
||||
body = 'User={0}&Password={1}&B1=Login'.format(username, passwd)
|
||||
self.wc.grab_response('/login.htm', body)
|
||||
rsp = self.wc.grab_response('/login.htm', body)
|
||||
if b'Incorrect User Name' in rsp[0]:
|
||||
raise exc.TargetEndpointBadCredentials()
|
||||
|
||||
|
||||
def logout(self):
|
||||
@ -184,8 +186,12 @@ def retrieve(nodes, element, configmanager, inputdata):
|
||||
yield msg.ConfluentResourceUnavailable(node, 'Not implemented')
|
||||
return
|
||||
for node in nodes:
|
||||
gc = PDUClient(node, configmanager)
|
||||
state = gc.get_outlet(element[-1])
|
||||
try:
|
||||
gc = PDUClient(node, configmanager)
|
||||
state = gc.get_outlet(element[-1])
|
||||
except exc.TargetEndpointBadCredentials:
|
||||
yield msg.ConfluentTargetInvalidCredentials(node)
|
||||
continue
|
||||
yield msg.PowerState(node=node, state=state)
|
||||
gc.logout()
|
||||
|
||||
|
@ -39,10 +39,13 @@ def retrieve(nodes, element, configmanager, inputdata):
|
||||
for pgroup in outlets[node]:
|
||||
pdu = outlets[node][pgroup]['pdu']
|
||||
outlet = outlets[node][pgroup]['outlet']
|
||||
for rsp in core.handle_path(
|
||||
'/nodes/{0}/power/outlets/{1}'.format(pdu, outlet),
|
||||
'retrieve', configmanager):
|
||||
yield msg.KeyValueData({pgroup: rsp.kvpairs['state']['value']}, node)
|
||||
try:
|
||||
for rsp in core.handle_path(
|
||||
'/nodes/{0}/power/outlets/{1}'.format(pdu, outlet),
|
||||
'retrieve', configmanager):
|
||||
yield msg.KeyValueData({pgroup: rsp.kvpairs['state']['value']}, node)
|
||||
except exc.TargetEndpointBadCredentials:
|
||||
yield msg.ConfluentTargetInvalidCredentials(pdu)
|
||||
|
||||
def get_outlets(nodes, emebs, inletname):
|
||||
outlets = {}
|
||||
|
Loading…
Reference in New Issue
Block a user