From 99f533b4cbc77857d3eaf3d331bd8a835925fb10 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 22 Sep 2020 14:31:28 -0400 Subject: [PATCH] Implement redfish resilient discovery for TSM TSM redfish stack has an issue where it refuses to recognize any non-redfish password change. Use redfish to change. Regretably, it takes about 10 seconds for that change to propogate to the practical API, so we have a discovery delay now. --- .../confluent/discovery/handlers/tsm.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/discovery/handlers/tsm.py b/confluent_server/confluent/discovery/handlers/tsm.py index 0fba1b05..69e103f4 100644 --- a/confluent_server/confluent/discovery/handlers/tsm.py +++ b/confluent_server/confluent/discovery/handlers/tsm.py @@ -16,6 +16,7 @@ import confluent.discovery.handlers.generic as generic import confluent.exceptions as exc import confluent.netutil as netutil import confluent.util as util +import eventlet import eventlet.support.greendns import json try: @@ -85,7 +86,22 @@ class NodeHandler(generic.NodeHandler): 'username': self.DEFAULT_USER } if authmode == 2: - rsp, status = wc.grab_json_response_with_status('/api/reset-pass', passchange) + passchange = { + 'Password': self.targpass, + } + rwc = webclient.SecureHTTPConnection( + self.ipaddr, 443, + verifycallback=self.validate_cert) + rwc.set_basic_credentials(authdata['username'], + authdata['password']) + rwc.set_header('If-Match', '*') + rwc.set_header('Content-Type', 'application/json') + rsp, status = rwc.grab_json_response_with_status( + '/redfish/v1/AccountService/Accounts/1', + passchange, method='PATCH') + if status >= 200 and status < 300: + authdata['password'] = self.targpass + eventlet.sleep(10) else: rsp, status = wc.grab_json_response_with_status('/api/reset-pass', urlencode(passchange)) authdata['password'] = self.targpass