Skip to content

Commit 90760c8

Browse files
authored
Merge pull request ceph#56223 from guits/tracker_64951
node-proxy: support more Location value formats
2 parents 10f92c1 + d7ccf26 commit 90760c8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/ceph-node-proxy/ceph_node_proxy/redfish_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def login(self) -> None:
3030
oob_credentials = json.dumps({'UserName': self.username,
3131
'Password': self.password})
3232
headers = {'Content-Type': 'application/json'}
33+
location_endpoint: str = ''
3334

3435
try:
3536
_headers, _data, _status_code = self.query(data=oob_credentials,
@@ -43,8 +44,14 @@ def login(self) -> None:
4344
self.log.error(msg)
4445
raise RuntimeError
4546
self.token = _headers['X-Auth-Token']
46-
location_endpoint: str = _headers['Location'].split('/', 3)[-1:][0]
47-
self.location = f'/{location_endpoint}'
47+
if _headers['Location'].startswith('http'):
48+
# We assume the value has the following format:
49+
# scheme://address:port/redfish/v1/SessionService/Session
50+
location_endpoint = f"/{_headers['Location'].split('/', 3)[-1:][0]}"
51+
else:
52+
location_endpoint = _headers['Location']
53+
self.location = location_endpoint
54+
self.log.info(f'Logged in to {self.url}, Received header "Location": {self.location}')
4855

4956
def is_logged_in(self) -> bool:
5057
self.log.debug(f'Checking token validity for {self.url}')

0 commit comments

Comments
 (0)