System

This section gives examples of the following system functionality:

Health Checks

This example of system calls demonstrates performing a system health check, retrieving information from the last health check, querying for all installed disk IDs in an array and outputting information about each.

 1"""docs/source/programmers_guide_src/code/system-health_check.py."""
 2
 3import PyU4V
 4
 5# Initialise PyU4V connection to Unisphere
 6conn = PyU4V.U4VConn()
 7
 8# Perform a system health check, this call can take 15-20 minutes to
 9# complete in Unisphere due to the nature of the checks performed
10conn.system.perform_health_check(description='test-hc-dec19')
11
12# Get details of the last system health check
13health_check = conn.system.get_system_health()
14
15# Get a list of physical disks installed in the array
16disk_list = conn.system.get_disk_id_list()
17# Get disk information for each disk installed
18for disk in disk_list.get('disk_ids'):
19    disk_info = conn.system.get_disk_details(disk_id=disk)
20
21# Close the session
22conn.close_session()

Audit Logs

The storage system audit records include all actions that are taken on that storage system. The storage system audit records come from the SYMAPI database and include all actions that are taken on that storage system. The audit log resides on the storage system and currently has a maximum size of 40 MB. Once the 40 MB limit is reached, the log begins to overwrite itself. Beginning in Unisphere release 9.2, operations that are executed through Unisphere UI have been added to the audit log.

Warning

Audit logs can be very large. You are warned that the operation may take a long time if you attempt to retrieved audit log records for a time period of greater than 7 days.

In the example below a query is made to return audit logs for the last hour which match a provided user name and client host name. A sample audit log record is then queried to return more detailed information.

 1"""docs/source/programmers_guide_src/code/system-audit_log_query.py."""
 2
 3import random
 4import time
 5
 6import PyU4V
 7
 8# Initialise PyU4V connection to Unisphere
 9conn = PyU4V.U4VConn()
10
11# Get a list of audit logs for the last ten minutes where the user name and
12# host name are defined as filters to return only matching results. Note, the
13# time interval here, similar to performance calls, is also in milliseconds
14# since epoch
15current_time = int(time.time()) * 1000
16start_time = current_time - (60 * 10 * 1000)
17audit_log_list = conn.system.get_audit_log_list(
18    start_time=start_time, end_time=current_time, user_name='PyU4V',
19    host_name='PyU4V-Host')
20
21# Select an audit log record from the list of audit logs and get the
22# associated audit log record ID
23audit_log_record = random.choice(audit_log_list)
24audit_log_record_id = audit_log_record.get('record_id')
25
26# Retrieve detailed information on a record returned in the audit log list
27audit_log_detailed = conn.system.get_audit_log_record(
28    record_id=audit_log_record_id)
29
30# Close the session
31conn.close_session()

In addition to querying audit logs via REST it is possible to download a PDF audit log record for the previous week. The example below demonstrates this.

Note

When providing a file_name there is no need to add the .pdf extension, PyU4V will do this automatically.

Note

When downloading an audit log record, it is possible to return the binary data instead of writing to pdf automatically, this allows you to handle the file writing process yourself. To do so just set return_binary=True. The data will be stored in the response dict under the key binary_data.

 1"""docs/source/programmers_guide_src/code/system-audit_log_download.py."""
 2
 3import PyU4V
 4
 5# Initialise PyU4V connection to Unisphere
 6conn = PyU4V.U4VConn()
 7
 8# Download PDF audit log record for the last week for primary array
 9audit_log_details = conn.system.download_audit_log_record(
10    return_binary=False, dir_path='~/datastore/audit_records',
11    file_name='audit-log-sept2020')
12
13# Assert the download operation was successful
14assert audit_log_details.get('success') is True
15print('The audit log has been downloaded to: {loc}'.format(
16    loc=audit_log_details.get('audit_record_path')))
17
18# Close the session
19conn.close_session()

Download & Upload Settings

Unisphere allows an authorized user with appropriate access to manage system settings. Settings can also be cloned, that is, settings can be copied from one array and applied to one or more target arrays subject to compatibility checks. In addition to cloning system settings from one array to another, it is also possible to clone Unisphere settings from one instance to another.

The exported settings have a generic format and do not contain any specific information regarding particular storage array or Unisphere instance, thus making it applicable in any environment.

The intention is to help users to port the system wide settings to another instance of Unisphere, and also to capture single array settings so that they can be applied to another storage array within single instance or another instance of Unisphere at any point of time.

The example below downloading system settings for the primary array and applying those same settings to another array registered to the same instance of Unisphere.

Note

A file_password is required not to protect the file when it is downloaded to a local computer, it is to verify the settings when they are being applied to another system or instance of Unisphere. This prevents unauthorised settings changes by people who have access to the data file.

 1"""docs/source/programmers_guide_src/code/system-settings_management.py."""
 2
 3import PyU4V
 4
 5# Initialise PyU4V connection to Unisphere
 6conn = PyU4V.U4VConn()
 7
 8# Download system settings for primary array defined in PyU4V.conf, exclude the
 9# system thresholds settings
10settings_info = conn.system.download_system_settings(
11    file_password='PyU4V', dir_path='~/datastore/system_settings',
12    file_name='settings_gold_master', exclude_system_threshold_settings=True)
13
14# Assert the download operation was successful and print the location of the
15# downloaded file
16assert settings_info.get('success') is True
17print('The system settings for {array} are saved to: {loc}'.format(
18    array=conn.array_id, loc=settings_info.get('settings_path')))
19
20# Upload the settings and apply to target array
21upload_details = conn.system.upload_settings(
22    file_password='PyU4V', file_path=settings_info.get('settings_path'),
23    array_id='000111222333')
24
25# Close the session
26conn.close_session()