HP OneView Deployment and Management Guide 1.10

Technical white paper | HP OneView Deployment and Management Guide
151
'userName': username,
'password': password,
}
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Accept-Language': 'en_US',
}
url = 'https://' + hostname + uri
response = requests.request(method, url, data=json.dumps(data),
headers=headers, verify=False)
A request is made up for 4 items:
Method - HTTP Method (e.g. POST, PUT, GET, etc.)
URL - URL for the new Request object.
Body (or data) - Any data we want to pass in
Headers - HTTP headers, including request type and authentication key
Example: Logging In
Below is a fully working example of using Python + Requests to login to an appliance and collect the session ID:
#!/usr/bin/env python
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
import json
import requests
def main(hostname, username, password):
uri = '/rest/login-sessions'
method = 'POST'
data = {
'userName': username,
'password': password,
}
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Accept-Language': 'en_US',
}
url = 'https://' + hostname + uri
response = requests.request(method, url, data=json.dumps(data),
headers=headers, verify=False)
if response.status_code == 200:
print (response.json()['sessionID'])
else:
print (response.json()['errorCode'] + ': ' + response.json()['message'])
if __name__ == '__main__':
hostname = 'host.domain.com'
username = 'administrator'
password = 'password'
main(hostname, username, password)
Creating a Support Dump
As with any product, occasionally there will be a situation that will require you to engage support. HP OneView provides a
Support Dump option to help with this process. There are two Support Dump options, and each contain different
information: the Appliance and Logical Interconnects.