def uploadFile(self, localPathAndFilename, ixLoadSvrPathAndFilename, overwrite=True): """ Description For Linux server only. You need to upload the config file into the Linux server location first: /mnt/ixload-share Parameters localPathAndFilename: The config file on the local PC path to be uploaded. ixLoadSvrPathandFilename: Default path on the Linux REST API server is '/mnt/ixload-share' Ex: '/mnt/ixload-share/IxL_Http_Ipv4Ftp_vm_8.20.rxf' Notes To log into IxLoad Linux gateway API server, password:ixia123 To view or set the IP address, open a terminal and enter: ip address """ url = self.httpHeader+'/api/v0/resources' headers = {'Content-Type': 'multipart/form-data'} params = {'overwrite': overwrite, 'uploadPath': ixLoadSvrPathAndFilename} self.logInfo('\nUploadFile: {0} file to {1}...'.format(localPathAndFilename, ixLoadSvrPathAndFilename)) self.logInfo('\n\tPOST: {0}\n\tDATA: {1}\n\tHEADERS: {2}'.format(url, params, self.jsonHeader)) try: with open(localPathAndFilename, 'rb') as f: response = requests.post(url, data=f, params=params, headers=headers, verify=self.verifySsl) if response.status_code != 200: raise IxLoadRestApiException('uploadFile failed', response.json()['text']) except requests.exceptions.ConnectionError as e: raise IxLoadRestApiException( 'Upload file failed. Received connection error. One common cause for this error is the size of the file to be uploaded.' ' The web server sets a limit of 1GB for the uploaded file size. Received the following error: %s' % str(e) ) except IOError as e: raise IxLoadRestApiException('Upload file failed. Received IO error: %s' % str(e)) except Exception: raise IxLoadRestApiException('Upload file failed. Received the following error: %s' % str(e)) else: self.logInfo('Upload file finished.')