def importJsonConfigObj(self, dataObj, option='modify', silentMode=False, timeout=90): """ Description For newConfig: This is equivalent to loading a saved .ixncfg file. To use this API, your script should have read a JSON config into an object variable. Then pass in the json object to the data parameter. For modify: Import the modified JSON data object to make a configuration modification on the API server. Supports one xpath at a time. Example: {"xpath": "/traffic/trafficItem[1]", "enabled": True, "name": "Topo-BGP"} Parameters data: (json object): The JSON config object. option: (str): newConfig|modify silentMode: (bool): If True, don't display REST API command on stdout. timeout: (int): The timeout value to declare as failed. Note arg2 value must be a string of JSON data: '{"xpath": "/traffic/trafficItem[1]", "enabled": false}' """ if option is 'modify': arg3 = False if option is 'newConfig': arg3 = True dataReformatted = {"arg1": "{0}/ixnetwork/resourceManager".format(self.ixnObj.headlessSessionId), "arg2": json.dumps(dataObj), "arg3": arg3} url = self.ixnObj.sessionUrl+'/resourceManager/operations/importconfig' response = self.ixnObj.post(url, data=dataReformatted, silentMode=silentMode) response = self.ixnObj.waitForComplete(response, url+'/'+response.json()['id'], silentMode=False, timeout=timeout) if response.json()['result'] != []: if option == 'modify': errorFlag = 0 for errorMsg in response.json()['result']: self.ixnObj.logError('JSON Import: %s' % errorMsg, timestamp=False) errorFlag = 1 if errorFlag: raise IxNetRestApiException('\nimportJsonConfigObj Error') else: self.ixnObj.logInfo('importJsonConfigObj: No error in JSON import')