lenovo / python-redfish-lenovo

Sample Python scripts and Ansible playbooks for using the Redfish API on Lenovo servers
Apache License 2.0
86 stars 49 forks source link

python-redfish-lenovo

Sample Python scripts for using the Redfish API on Lenovo servers

Description

This project includes a set of sample Python scripts that utilize the Redfish API to manage Lenovo ThinkSystem servers. The scripts use the DMTF python-redfish-library https://github.com/DMTF/python-redfish-library

For more information on the Redfish API, visit http://redfish.dmtf.org/

Installing

Requirements

Usage

A set of python examples is provided under the examples directory of this project.

Simply run the python script to print out the values from the HTTP GET operation.

This example prints the current system power state (such as On or Off)

cd examples
python get_power_state.py

This example prints the system reset types that are supported by this server, then passes one of the values (ForceOff) to force the server to shutdown:

cd examples
python lenovo_get_reset_types.py
['On', 'Nmi', 'GracefulShutdown', 'GracefulRestart', 'ForceOn', 'ForceOff', 'ForceRestart']

Python lenovo_set_reset_types.py ForceOff

Note: There are three scripts (rawcommand*.py) to support raw redfish get/patch/post requests. If existing scripts can't meet your requirement, please try them.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Copyright and License

Copyright 2019 Lenovo Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.