########################################################################
#
# All Rights Reserved.
# Copyright (C) 2024, Hitachi Vantara, Ltd.
#
########################################################################
#
# bcmapi_scan - This sample script shows how to generate
# a host discovered array configuration file using the BCM Web API
# for YKBTSCAN, YKBTSCAN, YKGETHDA.
#
# This sample script assumes the following settings.
# 1) The prefix and dadid are defined in the CLIDFLTS dataset.
#
########################################################################
# To execute this script, need the following steps:
# 1) Put bcmapi.py in the same directory as this script.
# 2) Write bcmapi.ini and put it in the same directory as this script.
# 3) Change the following parameters according to the environment.
# 4) Execute this script from python.
YKBTSCAN_cliparms = [ \
"DAD(DADP)",\
"DEVN(0000,0002,0005:0007,0009)",\
"VOLSER('VOL001','VOL003','VOL007':'VOL009')",\
"ROUTE(ROUTEID,ROUTE1)",\
"RDAD(DADS)", "SN(10000) RANGE(2000:21FF) DUMMY(0F00,CCA)",\
"NGDAD(DADNG)","SN(20000) RANGE(2000:21FF) DUMMY(1100,CCA)" ]
########################################################################
import bcmapi
import json
import pprint
# Scan local, nongen'd, and remote volumes.
def scan_volumes():
# Generate disk configuration files using YKBTSCAN.
operands = ""
rc,appData = bcmapi.bcmreq(\
"YKBTSCAN", operands, YKBTSCAN_cliparms)
if rc != 0:
return 8
# Get disk configuration file IDs using YKLISTID.
operands = "CONFIG(HDA)"
rc,appData = bcmapi.bcmreq("YKLISTID", operands)
if rc != 0:
return 8
configList = appData["config"]
hdaList = []
for config in configList:
if config["type"] == "HDA":
hdaList.append(config["ID"])
# Display disk configuration file using YKGETHDA.
for hda in hdaList:
hdaID = hda.split()
SN = hdaID[0]
DAD = hdaID[1]
operands = "SN(" + SN + ") DAD(" + DAD + ")"
offset = 0
total = 1
while offset<total:
rc,appData = bcmapi.bcmreq(\
"YKGETHDA", operands, offset=offset)
if rc != 0:
return 8
if offset == 0:
print(appData["snHda"])
else:
print(appData["snHda"][0]["ccaHda"])
offset = appData["offset"]
limit = appData["limit"]
total = appData["total"]
offset = offset + limit
return 0
tsoStart = False
bcmStart = False
# Before using the BCM Web API, you need to perform
# z/OSMF authentication, start a TSO/E session,
# and then start the BCM Web API server.
respBody = bcmapi.start_tso()
if respBody != "":
tsoStart = True
respBody = bcmapi.start_bcm()
if respBody != "":
bcmStart = True
rc = scan_volumes()
# To exit the BCM Web API server,
# you need to send a "submit":"exit" request.
if bcmStart:
respBody = bcmapi.end_bcm()
# You must send DELETE /zosmf/tsoApp/tso/<servletKey>
# to terminate TSO/E address space of BCM Web API server.
if tsoStart:
respBody = bcmapi.end_tso()
exit()