######################################################################## # # All Rights Reserved. # Copyright (C) 2024, Hitachi Vantara, Ltd. # ######################################################################## # # bcmapi_cgdef - This sample script demonstrates how to use the # BCM Web API about copy group configuration file generation # using BCM Web API of YKDEFGRP,YKIMPORT,YKLOAD,YKGETGRP. # # This sample script assumes the following settings. # 1) The prefix and dadid are defined in the CLIDFLTS dataset. # 2) Before you execute this script, # you must allocate and write CSV files. # ######################################################################## # 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. copyGroupID = '<copy group id to generate>' csvPrefix = '<prefix of all csv data sets for YKIMPORT>' YKDEFGRP_cliparms = [ \ "GROUP " + copyGroupID,\ "DESCRIPTION UR copy group",\ "PRIDAD LOCAL",\ "SECDAD REMOTE",\ "PRISCHSET 0",\ "SECSCHSET 0",\ "COPYTYPE UR",\ "COPYPACE NORMAL",\ "PROTECTMODE PROTECT",\ "CTTIMEMODE ASIS",\ "ERRORLEVEL GROUP",\ "MIRRORID 1"] ######################################################################## import bcmapi import json import pprint def generate_cg(): # Generate copy group configuration file. operands = "" rc,appData = bcmapi.bcmreq(\ "YKDEFGRP", operands, YKDEFGRP_cliparms) if rc != 0: return 8 # Add or update copy pairs to the copy group configuration file. operands = "BASEGROUP(" + copyGroupID+")"\ + " NEWGROUP(" + copyGroupID+")"\ + " INPAIR(" + csvPrefix + ".PAIR.CSV)"\ + " INCTG(" + csvPrefix + ".CTG.CSV)"\ + " INEXCTG(" + csvPrefix + ".EXCTG.CSV)" rc,appData = bcmapi.bcmreq("YKIMPORT", operands) if rc != 0: return 8 # Load the copy group configuration file. operands = "GROUP(" + copyGroupID + ")" rc,appData = bcmapi.bcmreq("YKLOAD", operands) if rc != 0: return 8 # Display the copy group configuration file. operands = "GROUP(" + copyGroupID + ")" rc,appData = bcmapi.bcmreq("YKGETGRP", operands) offset = 0 total = 1 while offset < total: rc,appData = bcmapi.bcmreq(\ "YKGETGRP", operands, offset=offset) if rc != 0: return 8 if offset == 0: print(appData["copyGroup"]) else: print(appData["copyGroup"]["CTGroup"]) offset = appData["offset"] limit = appData["limit"] total = appData["total"] print(offset, limit, 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 = generate_cg() # 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()