diff --git a/confluent_server/confluent/plugins/hardwaremanagement/deltapdu.py b/confluent_server/confluent/plugins/hardwaremanagement/deltapdu.py index a413f1e9..7a607545 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/deltapdu.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/deltapdu.py @@ -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() diff --git a/confluent_server/confluent/plugins/hardwaremanagement/pdu.py b/confluent_server/confluent/plugins/hardwaremanagement/pdu.py index 7eaa3330..b19c9b22 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/pdu.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/pdu.py @@ -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 = {}