DMTF/python-redfish-library

Unable to logout()

Closed this issue · 2 comments

Using python 3.5.2 I set up a client;
rclient = redfish.redfish_client("https://172.17.45.207:8098","Admin","administrator")
and logged in;
rclient.login()
then tried to logout()

rclient.logout()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/redfish/rest/v1.py", line 946, in logout
"return code: %d" % (session_loc, resp.status))
redfish.rest.v1.BadRequestError: Invalid session resource: SessionService/Sessions/c48228132d1a1941, return code: 404

I created a new module logoff();

    def logoff(self):
        """ Logout of session. YOU MUST CALL THIS WHEN YOU ARE DONE TO FREE"""
        """ UP SESSIONS"""
        if self.__session_key:
            session_loc = "{}{}".format(self.default_prefix,self.__session_location)
            resp = self.delete(session_loc)
            if resp.status not in [200, 202, 204]:
                raise BadRequestError("Invalid session resource: %s, "\
                                   "return code: %d" % (session_loc, resp.status))

            LOGGER.info("User logged out: %s", resp.text)

            self.__session_key = None
            self.__session_location = None
            self.__authorization_key = None

which is a copy of logout() with the session_log modified. This worked for me. But I can't say for certain if the failure was due to the redfish module or the redfish implementation on the product I was testing.

I think this is a problem with your Redfish service. The value of self.__session_location is the Location header returned from the creation (POST) of the Redfish session. It must be the URI of the created session. It should either be of the form /redfish/v1/SessionService/Sessions/c48228132d1a1941 or https://172.17.45.207:8098/redfish/v1/SessionService/Sessions/c48228132d1a1941.

But from the output you show above, it appears your service is returning a Location header of SessionService/Sessions/c48228132d1a1941, which is missing the root of the URI (/redfish/v1/).