from utils.auth import IntersightAuth import requests import json from env import config import pprint auth = IntersightAuth(secret_key_filename=config['INTERSIGHT_CERT'], api_key_id=config['INTERSIGHT_API_KEY']) BASE_URL = 'https://www.intersight.com/api/v1' def getAlarms(): url = f"{BASE_URL}/cond/Alarms" response = requests.get(url, auth=auth) alarms_res = response.json()['Results'] print("######Alarms########### ") for alarm in alarms_res: print(alarm['Description']) # retreive Alarms getAlarms() def getPhysicalInfra(): infra_url = f"{BASE_URL}/compute/PhysicalSummaries" infra_resp = requests.get(infra_url, auth=auth) print("###### PhysicalSummaries ########### ") results = infra_resp.json()['Results']
import requests import json from utils.auth import IntersightAuth from env import config privatekey = config['INTERSIGHT_CERT'] publickey = config['INTERSIGHT_API_KEY'] auth = IntersightAuth(secret_key_filename=privatekey, api_key_id=publickey) base_url = 'https://intersight.com/api/v1' endpoint = '/cond/Alarms' try: response = requests.get(url=f"{base_url}{endpoint}", auth=auth) if response.status_code == 200: response_json = json.loads(response.text) print("---------------Alarms--------------") for name in response_json["Results"]: print(name["Name"]) print(name["Description"]) print("\n") except Exception as ex: print(ex) endpoint2 = "/compute/PhysicalSummaries" try: response = requests.get(url=f"{base_url}{endpoint2}", auth=auth) if response.status_code == 200: response_json = json.loads(response.text)