Basic Operations
First connection to PyU4V
In this basic example we initialise a connection with Unisphere, retrieving version and array information, and finishing by closing the REST session.
1"""docs/source/programmers_guide_src/code/basic-unisphere_connect.py."""
2
3import PyU4V
4
5# Initialise PyU4V connection to Unisphere
6conn = PyU4V.U4VConn(
7 server_ip='10.0.0.75', port=8443, verify='~/.PyU4V/Unisphere91.pem',
8 username='pyu4v-user', password='secret-pass')
9
10# Get the Unisphere version
11version = conn.common.get_uni_version()
12
13# Retrieve a list of arrays managed by your instance of Unisphere
14array_list = conn.common.get_array_list()
15
16# Output results to screen
17print('Congratulations on your first connection to Unisphere, your '
18 'version is: {ver}'.format(ver=version[0]))
19print('This instance of Unisphere instance manages the following arrays: '
20 '{arr_list}'.format(arr_list=array_list))
21
22# GET those arrays which are local to this instance of Unisphere
23local_array_list = list()
24for array_id in array_list:
25 array_details = conn.common.get_array(array_id)
26 if array_details['local']:
27 local_array_list.append(array_id)
28
29# Output results to screen
30print('The following arrays are local to this Unisphere instance: '
31 '{arr_list}'.format(arr_list=local_array_list))
32
33# Close the session
34conn.close_session()