In the previous post, we collected all the datasources from our NetApp OCI servers. Now I want to collect the datasources from NetApp Cloud Insights. The main change is that CI uses an API Key, whereas OCI used username and password authentication, so I had to google the correct way to connect, and it turned out very simple.
Collecting NetApp Cloud Insights Datasources over REST API in Python Command Line >>>
- import requests
- api_key = 'ENTER_YOUR_API_KEY_HERE'
- url = 'https://YOUR_TENANT.cloudinsights.netapp.com/rest/v1/collector/datasources'
- headers = {'X-CloudInsights-ApiKey': '{key}'.format(key=api_key)}
- jsondata = requests.get(url, headers=headers).json()
Nice and simple. 5 lines. Of course jsondata is just that, JSON data. In a future post we'll process it.
Now to get Python to work with a Windows machine that's behind a proxy.
Getting the Above to Work With Python on a Windows Machine That's Behind a Proxy
Not much different to the above. First you will need to find your corporate web-proxy information (you might find this down the bottom of a .pac file), then you need to run this from the DOS Command Prompt>
set https_proxy=https://USERNAME:PASSWORD@proxy.server.fqdn:PORT
Then I needed to add verify = False to the requests.get which makes the final line in the above:
- jsondata = requests.get(url, headers=headers, verify = False).json()
- import urllib3
- urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
Comments
Post a Comment