Skip to content

visubramaniam/VSP1Block_Rest_API_Sample_Code

Repository files navigation

VSP One Block REST API Sample Code

Python sample scripts demonstrating how to interact with the Hitachi VSP One Block storage array using the Configuration Manager Simple REST API.

Prerequisites

  • Python 3.6+
  • requests library (pip install requests)

Project Structure

Common Modules

Module Description
array_connection.py Array connection setup, session login, and HTTP auth header helpers. Used by all sample scripts.
command_status.py Asynchronous command status handling — URL conversion, status polling, cleanup, and result processing for write operations.

Sample Scripts

Script Description
GetArrayDetails.py Retrieves and displays storage array information (model, serial number, firmware, etc.).
GetPools.py Retrieves and displays the list of storage pools on the array.
CreateServer.py Creates a server (host group) on the array and optionally adds HBA WWNs to it. Demonstrates asynchronous command status handling.
CreateVolume.py Creates a volume (LDEV) in a storage pool with deduplication and compression enabled. Demonstrates asynchronous command status handling.

Configuration

Each sample script contains an array_obj dictionary at the top of its main() function. Update these values to match your environment:

array_obj = {
    'ipAddress': '192.168.52.23',   # Array management IP
    'protocol': 'https',             # Protocol (https recommended)
    'port': 443,                     # Management port
    'username': 'maintenance',       # Login username
    'password': 'password123',       # Login password
}

Usage

Run any sample script directly:

python GetPools.py
python CreateServer.py
python CreateVolume.py

Each script will:

  1. Build the base URL from the connection details (setup_array_obj)
  2. Log in to the array and obtain a session ID (login_to_array)
  3. Perform its specific operation using session-based authentication

For write operations (CreateServer.py, CreateVolume.py), the script will also: 4. Poll the asynchronous command status until completion 5. Report success or failure 6. Clean up the command status resource

Common Module Details

array_connection.py

Function Purpose
setup_array_obj(array_obj) Builds the base URL and Basic auth header from connection details.
login_to_array(array_obj) Posts to /sessions to obtain a session ID.
get_session_headers(array_obj) Returns headers with Session authorization for API calls.
get_basic_auth_headers(array_obj) Returns headers with Basic authorization for login.

command_status.py

Function Purpose
convert_return_url_to_full_url(array_obj, return_url) Converts a relative status URL to a full URL.
convert_return_urls_to_full_url(array_obj, return_url_list) Converts multiple relative status URLs into a single batch query URL.
check_command_status_by_url(array_obj, status_url) Polls the status URL every 2 seconds until the command completes. Returns True on success.
delete_command_status_url(array_obj, status_url) Deletes the status resource after processing.
process_single_command_status(command_status) Parses a single command status response.
process_multiple_command_status(command_status_list) Parses a batch of command status responses and returns overall state.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages