White Papers

Configuration details
10 Dell Storage Manager REST API Cookbook | 3089-WP-SAN
2 Connecting to a DSM Data Collector
This section discusses using the configured Python environment to interact with the DSM Data Collector.
Python is a natively object-oriented language; methods such as opening a connection to the DSM Data
Collector involve using and interacting with the connection object previously created.
All subsequent REST API calls are defined between the open and close connection code segments shown in
the following subsections.
2.1 Open a connection
This code defines the REST API request and opens a connection to the DSM Data Collector by using the
HTTP POST call.
# login to DSM instance
# declare and define the payload variable
payload = {}
# define the REST API call
REST = '/ApiConnection/Login'
# build the complete REST API URL
completeURL = '%s%s' % (baseURL, REST if REST[0] != '/' else REST[1:])
# execute REST API call via the HTTP POST method
print connection.post(completeURL
,data=json.dumps(payload
,ensure_ascii=False).encode('utf-8')
,headers=header
,verify=verify_cert)
STDOUT
<Response [200]>
2.2 Close a connection
In a similar fashion, it is a good practice to close any open object connections prior to exiting a script as
shown in the following.
# logout from DSM instance
# declare and define the payload variable
payload = {}