Jake Larrimore

Utilizing Hitachi Command Suite REST API for Host Group WWN allocation, LDEV creation, and LUN Mapping: Part 1

Blog Post created by Jake Larrimore Employee on Sep 13, 2018

As technology continues to trend towards RESTful API programming, Hitachi Vantara’s Global Services group has utilized Hitachi Command Suite’s Configuration Management for automation tasks.

 

The goal of this blog post is to explain a workflow and implementation of one such automation script. I’ll be utilizing Python (2.7 or 3.6.x) and cURL. The script will be run on a Linux/Unix server that has Python installed.

We’ll be utilizing Python’s httpclient (Python 3) and Python’s httplib (Python 2) libraries, as these come as standard libraries, without having to install any other packages.

Here’s what the cmrequest method looks like that we’ll be using to communicate with the API:

1.       Let’s start the script so that it takes as a command line argument an array device ID, and any quantity of port numbers.

2.       Then, we grab the sever HBA WWPN’s (referred to as WWNs from here on). While we’re at it, lets grab the server’s host name to apply that to that as the Host Group Name.

3.       We then need to create a host group on that array and port for each port ID entered.

Note: After sending a POST or PUT command, HCS creates a job that will take care of that request. It’ll beneficial to monitor that job until it’s competition. We’ll utilize the Host Group Number that is returned with the JobID request’s “affectedResource” variable. Here’s what that code looks like:

4.       We then need to assign the WWN to that host group, and then store the resulting Host Group information in wwnDictResult for future use creating the pools. wwnDictResult will be a list of dictionaries.

5.       Once all the host groups are created on the desired ports, we need to find an appropriate pool and create a volume on that pool. For the sake of simplicity, lets assume the poolID = 1, and ldevId = 1.

6.       Lastly, for each host group that we created in step 3 & 4, we need to create the LUN mapping to the LDEV we created in step 5.

 

 

Outcomes