diff --git a/ixnetwork/IxnConfigManagement.py b/ixnetwork/IxnConfigManagement.py index bfbbca9..3d972ee 100644 --- a/ixnetwork/IxnConfigManagement.py +++ b/ixnetwork/IxnConfigManagement.py @@ -56,12 +56,11 @@ def export_config(self, xpaths=['/descendant-or-self::*'], include_defaults=True 'arg4': export_format } if local_filename is not None: - self._file_mgmt.create(local_filename) - filename_only = self._file_mgmt._get_filename(local_filename) - payload['arg5'] = filename_only - if local_filename is not None: + remote_filename = self._file_mgmt._get_filename(local_filename) + self._file_mgmt.create(remote_filename) + payload['arg5'] = remote_filename response = resource_manager.operations.exportconfigfile(payload) - self._file_mgmt.download(filename_only, local_filename) + self._file_mgmt.download(remote_filename, local_filename) else: response = resource_manager.operations.exportconfig(payload) return json.loads(response.result) diff --git a/ixnetwork/IxnFileManagement.py b/ixnetwork/IxnFileManagement.py index a0a792c..fc5be70 100644 --- a/ixnetwork/IxnFileManagement.py +++ b/ixnetwork/IxnFileManagement.py @@ -1,5 +1,7 @@ -# from IxnHttp import IxnHttp +"""Encapsulates file transfer +""" import json +import os class IxnFileManagement(object): @@ -46,7 +48,7 @@ def files(self, match=None): return files def _get_filename(self, filename): - return filename.replace('\\', '/').split('/').pop() + return os.path.basename(os.path.normpath(filename)) def _add_href(self, file_object): file_object.href = '/api/v1/sessions/%s/ixnetwork/files/%s' % (self._ixnhttp.current_session.id, file_object.name)