How to use the redfish.ris.rmc_helper.SessionExpired function in redfish

To help you get started, we’ve selected a few redfish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DMTF / python-redfish-utility / src / rdmc.py View on Github external
except redfish.ris.InstanceNotFoundError as excp:
            self.retcode = ReturnCodes.RIS_INSTANCE_NOT_FOUND_ERROR
            UI().printmsg(excp)
        except redfish.ris.CurrentlyLoggedInError as excp:
            self.retcode = ReturnCodes.RIS_CURRENTLY_LOGGED_IN_ERROR
            UI().error(excp)
        except redfish.ris.NothingSelectedError as excp:
            self.retcode = ReturnCodes.RIS_NOTHING_SELECTED_ERROR
            UI().nothing_selected()
        except redfish.ris.NothingSelectedSetError as excp:
            self.retcode = ReturnCodes.RIS_NOTHING_SELECTED_SET_ERROR
            UI().nothing_selected_set()
        except redfish.ris.InvalidSelectionError as excp:
            self.retcode = ReturnCodes.RIS_INVALID_SELECTION_ERROR
            UI().error(excp)
        except redfish.ris.rmc_helper.SessionExpired as excp:
            self.retcode = ReturnCodes.RIS_SESSION_EXPIRED
            self.app.logout()
            UI().printmsg(u"Current session has expired or is invalid, "\
                    "please login again with proper credentials to continue.\n")
        # ****** RMC/RIS ERRORS ******
        except redfish.rest.v1.RetriesExhaustedError as excp:
            self.retcode = ReturnCodes.V1_RETRIES_EXHAUSTED_ERROR
            UI().retries_exhausted_attemps()
        except redfish.rest.v1.InvalidCredentialsError as excp:
            self.retcode = ReturnCodes.V1_INVALID_CREDENTIALS_ERROR
            UI().invalid_credentials(excp)
        except redfish.rest.v1.ServerDownOrUnreachableError as excp:
            self.retcode = \
                    ReturnCodes.V1_SERVER_DOWN_OR_UNREACHABLE_ERROR
            UI().error(excp)
        except redfish.ris.rmc_helper.InvalidPathError as excp:
github DMTF / python-redfish-library / src / redfish / ris / rmc.py View on Github external
:param response: flag to return the response.
        :type response: str.
        :returns: returns RestResponse object containing response data

        """
        if sessionid:
            results = RmcClient(url=url, sessionkey=sessionid).set(put_path, \
                                                    body=body, headers=headers)
        else:
            results = self.current_client.set(put_path, body=body, \
                                                                headers=headers)

        if not silent:
            self.invalid_return_handler(results, verbose=verbose)
        elif results.status == 401:
            raise SessionExpired()

        if response:
            return results

github DMTF / python-redfish-library / src / redfish / ris / rmc.py View on Github external
def invalid_return_handler(self, results, verbose=False):
        """Main worker function for handling all error messages

        :param results: dict of the results.
        :type results: sict.
        :param verbose: flag to enable additional verbosity.
        :type verbose: boolean.

        """
        if results.status == 401:
            raise SessionExpired()
        else:
            if results.status == 200 or results.status == 201:
                if verbose:
                    self.warning_handler("[%d] The operation completed " \
                                            "successfully.\n" % results.status)
                else:
                    self.warning_handler("The operation completed "\
                                                            "successfully.\n")
            else:
                self.warning_handler("[%d] No message returned.\n" % \
                                                                results.status)
github DMTF / python-redfish-library / src / redfish / ris / rmc.py View on Github external
:param url: originating URL.
        :type url: str.
        :param sessionid: session id to be used instead of credentials.
        :type sessionid: str.
        :returns: returns a RestResponse object from client's Head command

        """
        if sessionid:
            results = RmcClient(url=url, sessionkey=sessionid).head(put_path)
        else:
            results = self.current_client.head(put_path)

        if not silent:
            self.invalid_return_handler(results, verbose=verbose)
        elif results.status == 401:
            raise SessionExpired()

        if results.status == 200:
            return results
        else:
            return None
github DMTF / python-redfish-library / src / redfish / ris / rmc.py View on Github external
:param response: flag to return the response.
        :type response: str.
        :returns: returns a RestResponse from client's Post command

        """
        if sessionid:
            results = RmcClient(url=url, sessionkey=sessionid).toolpost(\
                                        put_path, body=body, headers=headers)
        else:
            results = self.current_client.toolpost(put_path, body=body, \
                                                                headers=headers)

        if not silent:
            self.invalid_return_handler(results, verbose=verbose)
        elif results.status == 401:
            raise SessionExpired()

        if response:
            return results
github DMTF / python-redfish-library / src / redfish / ris / rmc.py View on Github external
:param response: flag to return the response.
        :type response: str.
        :returns: returns a RestResponse object from client's Put command

        """
        if sessionid:
            results = RmcClient(url=url, sessionkey=sessionid).toolput(\
                                           put_path, body=body, headers=headers)
        else:
            results = self.current_client.toolput(put_path, body=body, \
                                                                headers=headers)

        if not silent:
            self.invalid_return_handler(results, verbose=verbose)
        elif results.status == 401:
            raise SessionExpired()

        if response:
            return results
github DMTF / python-redfish-library / src / redfish / ris / rmc.py View on Github external
:param response: flag to return the response.
        :type response: str.
        :returns: returns a RestResponse object from client's get command

        """
        if sessionid:
            results = RmcClient(url=url, sessionkey=sessionid).get(put_path, \
                                                               headers=headers)
        else:
            results = self.current_client.get(put_path, uncache=uncache, \
                                                                headers=headers)

        if not silent:
            self.invalid_return_handler(results, verbose=verbose)
        elif results.status == 401:
            raise SessionExpired()

        if results.status == 200 or response:
            return results
        else:
            return None
github DMTF / python-redfish-library / src / redfish / ris / rmc.py View on Github external
:type headers: str.
        :param silent: flag to disable output.
        :type silent: boolean.
        :returns: returns a RestResponse object from client's Delete command

        """
        if sessionid:
            results = RmcClient(url=url, sessionkey=sessionid).tooldelete(\
                                                    put_path, headers=headers)
        else:
            results = self.current_client.tooldelete(put_path, headers=headers)

        if not silent:
            self.invalid_return_handler(results, verbose=verbose)
        elif results.status == 401:
            raise SessionExpired()

        return results