def exportJsonConfigFile(self, jsonFileName, xpathList=None): """ Description Export the current configuration to a JSON format config file and copy it to local filesystem. Parameters jsonFileName: (str): The JSON config file name to create. Could include absolute path also. xpathList: To get entire configuration = ['/descendant-or-self::*'] To get code fragments such as /vport = ['/vport/descendant-or-self::*'] Requirements self.ixnObj.waitForComplete() self.copyFileLinuxToLocalLinux() self.copyFileWindowsToLocalLinux() self.jsonReadConfig() self.jsonWriteToFile() Syntax POST /api/v1/sessions/{id}/ixnetwork/resourceManager/operations/exportconfigfile DATA = {'arg1': '/api/v1/sessions/{id}/ixnetwork/resourceManager', 'arg2': ['/descendant-or-self::*'], 'arg3': True, 'arg4': 'json', 'arg5': '/api/v1/sessions/{id}/ixnetwork/files/'+fileName } Example restObj.exportJsonConfigFile(jsonFileName='/path/exportedJsonConfig.json') """ if xpathList == None: xpathList = ['/descendant-or-self::*'] jsonFileNameTemp = jsonFileName.split('/') if jsonFileNameTemp[0] == '': jsonFileNameTemp.pop(0) if len(jsonFileNameTemp) > 1: destinationPath = '/' destinationPath = destinationPath + '/'.join(jsonFileNameTemp[:-1]) else: destinationPath = os.getcwd() self.ixnObj.logInfo('Storing the exported file to: %s' % destinationPath) fileName = jsonFileNameTemp[-1] # sessionId example: /api/v1/sessions/{id}/ixnetwork sessionId = self.ixnObj.sessionUrl.split(self.ixnObj.httpHeader)[1] data = {'arg1': sessionId+"/resourceManager", 'arg2': xpathList, 'arg3': True, 'arg4': 'json', 'arg5': sessionId+'/files/'+fileName } url = self.ixnObj.sessionUrl+'/resourceManager/operations/exportconfigfile' response = self.ixnObj.post(url, data=data) self.ixnObj.waitForComplete(response, url+'/'+response.json()['id'], silentMode=False) response = self.ixnObj.get(self.ixnObj.sessionUrl+'/files') absolutePath = response.json()['absolute'] if self.ixnObj.serverOs in ['windows', 'windowsConnectionMgr']: absolutePath = absolutePath.replace('\\', '\\\\') absolutePath = absolutePath + '\\\\'+fileName if self.ixnObj.serverOs == 'linux': absolutePath = absolutePath+'/'+fileName if self.ixnObj.serverOs in ['windows', 'windowsConnectionMgr']: self.copyFileWindowsToLocalLinux(windowsPathAndFileName=absolutePath, localPath=destinationPath, renameDestinationFile=None, includeTimestamp=False) if self.ixnObj.serverOs == 'linux': self.copyFileLinuxToLocalLinux(linuxApiServerPathAndFileName=absolutePath, localPath=destinationPath, renameDestinationFile=None, includeTimestamp=False) # Indent the serialized json config file jsonObj = self.jsonReadConfig(jsonFileName) self.jsonWriteToFile(jsonObj, jsonFileName)