Skip to content

linliwan/getting-start-with-intersight-sdk

Repository files navigation

Getting start with Intersight REST API and Python SDK

Prepare .env

Log in to Intersight, find the OAuth2 and key options in settings, generate the corresponding account, and write its information to .env and .private.key. You can refer to .env.example and private.key.example, remove the .example from the end of the filename, and fill in the information.

About the example codes

Explanation and use of example code:

  • src/01_rest_api_oauth.py It uses OAuth authentication to connect to intersight.com and retrieve data.

  • src/02_rest_api_ec.py It uses signature authentication header to connect to intersight.com and retrievedata.

  • src/03_sdk_minimal.py This the minimal case using the Intersight Python SDK.

  • src/04_sdk_example01.py Use the Intersight SDK to obtain physical server information and generate an Excel spreadsheet.

  • src/05_sdk_example02.py Example code for retrieving physical server information using the Intersight SDK by passing query parameters.

  • src/06_sdk_example03.py Sample code for adding, deleting, modifying, and querying NTP policies using the Intersight SDK.

  • src/07_time_series_query.py Use the Intersight Telemetry API to query the energy consumption of a specific server over the past 24 hours

  • src/08_cimc-device-connector-reset.py Restore the Standalone UCSC CIMC device connector to factory settings.

Appendix: Initialize the poetry project and install necessary dependencies

(poetry will automatically create virtual environments)

# Install poetry
# https://python-poetry.org/docs/#installing-with-the-official-installer

# initialize poetry
poetry init -n

# check poetry config
poetry config --list
# make sure virtualenvs.in-project set to true
poetry config virtualenvs.in-project true

# install necessary dependencies - for 01 and 02 examples
poetry add requests
poetry add python-dotenv
poetry add pycryptodome

# install offical intersight SDK - for intersight python SDK related examples
poetry add intersight

# (optional) check the env info, to confirm that it points to the .venv file in the project directory.
poetry env info

# (optional) activate venv in CLI
source .venv/Scripts/activate

About

Intersight API learning case

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages