######################################################################## # # All Rights Reserved. # Copyright (C) 2024, Hitachi Vantara, Ltd. # ######################################################################## # # bcmapi_remote - This sample script shows how to generate # generate route list and command device configuration files # and build a remote command environment # using BCM Web API of YKDEFRMT,YKBLDRMT,YKDSPRMT. # # 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. routeListID = 'ROUTE' YKDEFRMT_cliparms = [ \ "ROUTEID " + routeListID,\ "ROUTE APID(1001)",\ "CDEV DAD(LOCAL) DEVN(1101) SN(11111) CU(11) CCA(11) SSID(1111)",\ "CDEV DAD(REMOTE) SN(22222) CU(22) CCA(11) SSID(2211)",\ "CDEV DAD(REMOTE) SN(33333) CU(33) CCA(11) SSID(3311)"] ######################################################################## import bcmapi import json import pprint # Generate remote DKC command environment. def gen_remote_env(): # Generate route list and command device configuration files. rc,appData = bcmapi.bcmreq(\ "YKDEFRMT", "", YKDEFRMT_cliparms) if rc != 0: return 8 # Check generated configuration file's contents. cliparms = ["ROUTEID " + routeListID] rc,appData = bcmapi.bcmreq("YKDSPRMT", "", cliparms) if rc != 0: return 8 print(appData["route"]) # Register in order all command devices on the command device lines # defined in the route list, which starts with the local host. cliparms = ["ROUTEID " + routeListID] rc,appData = bcmapi.bcmreq("YKBLDRMT", "", cliparms) if rc != 0: return 8 # Check whether command devices are registered. cliparms = ["ROUTEID " + routeListID, "STATUS YES"] rc,appData = bcmapi.bcmreq("YKDSPRMT", "", cliparms) if rc != 0: return 8 print(appData['route']) 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 = gen_remote_env() # 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()