jsonConfigFile = 'bgpSimplified.json' # Where to store the exported JSON config file #exportJsonConfigFile = '/home/hgee/exportedJsonConfig.json' exportJsonConfigFile = 'bgp_ngpf_hw_8.40.json' try: restObj = Connect(apiServerIp='192.168.70.3', serverIpPort='11009') fileMgmtObj = FileMgmt(restObj) # How to export a configuration into a JSON format file. # This will export your current configuration into a specified json filename. fileMgmtObj.exportJsonConfigFile(jsonFileName=exportJsonConfigFile) # How to load a complete json config file fileMgmtObj.importJsonConfigFile(jsonConfigFile, option='newConfig') # Read a JSON config file and store all the datas into an object. # Use the jsonData object to make your modifications. jsonData = fileMgmtObj.jsonReadConfig(exportJsonConfigFile) # How to use XPATH to modify IxNetwork configurations. xpathObj = [{"xpath": "/multivalue[@source = '/topology[1]/deviceGroup[1]/ethernet[1]/ipv4[1]/bgpIpv4Peer[1] flap']/singleValue", "value": "true"}, {"xpath": "/multivalue[@source = '/topology[1]/deviceGroup[1]/ethernet[1]/ipv4[1]/bgpIpv4Peer[1] uptimeInSec']/singleValue", "value": "28"}, {"xpath": "/multivalue[@source = '/topology[1]/deviceGroup[1]/ethernet[1]/ipv4[1]/bgpIpv4Peer[1] downtimeInSec']/singleValue", "value": "68"} ] fileMgmtObj.importJsonConfigObj(dataObj=xpathObj, option='modify')
from IxNetRestApiFileMgmt import FileMgmt # The path to your exported JSON config file: jsonConfigFile = 'bgpSimplified.json' exportJsonConfigFile = '/home/hgee/exportedJsonConfig.json' try: restObj = Connect(apiServerIp='192.168.70.3', serverIpPort='11009') fileMgmtObj = FileMgmt(restObj) # How to export a configuration into a JSON format file. # This will export your current configuration into a specified json filename. fileMgmtObj.exportJsonConfigFile(jsonFileName=exportJsonConfigFile) # How to load a complete json config file fileMgmtObj.importJsonConfigFile(jsonConfigFile, type='newConfig') # Read a JSON config file and store all the datas into an object. # Use the jsonData object to make your modifications. jsonData = fileMgmtObj.jsonReadConfig(exportJsonConfigFile) # How to use XPATH to modify IxNetwork configurations. xpathObj = [{ "xpath": "/multivalue[@source = '/topology[1]/deviceGroup[1]/ethernet[1]/ipv4[1]/bgpIpv4Peer[1] flap']/singleValue", "value": "true" }, { "xpath": "/multivalue[@source = '/topology[1]/deviceGroup[1]/ethernet[1]/ipv4[1]/bgpIpv4Peer[1] uptimeInSec']/singleValue", "value": "28" }, {