def importJsonConfigFile(self, jsonFileName, option='modify'): """ Description To import a JSON config file to IxNetwork. You could state it to import as a modified config or creating a new config. The benefit of importing an actual JSON config file is so you could manually use IxNetwork Resource Manager to edit any part of the JSON config and add to the current configuration Parameters jsonFileName: (json object): The JSON config file. Could include absolute path also. option: (str): newConfig|modify """ if option is 'modify': arg3 = False if option is 'newConfig': arg3 = True fileName = jsonFileName.split('/')[-1] uploadFile = self.ixnObj.sessionUrl+'/files?filename='+fileName if self.ixnObj.serverOs == 'linux': headers = {'content-type': 'application/octet-stream', 'x-api-key': self.ixnObj.apiKey} else: headers = {'content-type': 'application/octet-stream'} # 1> Upload the config file to the server and give it any name you want for the filename self.ixnObj.logInfo('Uploading file to server: %s' % uploadFile) with open(jsonFileName, mode='rb') as file: configContents = file.read() configContents = io.BytesIO(configContents) response = self.ixnObj.post(uploadFile, data=configContents, noDataJsonDumps=True, headers=headers, silentMode=False) # 2> Tell IxNetwork to import the JSON config file data = {"arg1": "{0}/ixnetwork/resourceManager".format(self.ixnObj.headlessSessionId), "arg2": "{0}/ixnetwork/files/{1}".format(self.ixnObj.headlessSessionId, fileName), "arg3": arg3} url = self.ixnObj.sessionUrl+'/resourceManager/operations/importconfigfile' response = self.ixnObj.post(url, data=data) self.ixnObj.waitForComplete(response, url+'/'+response.json()['id'], silentMode=False, timeout=300)