Skip to content

Commit

Permalink
fix export and file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbalogh committed Jul 31, 2018
1 parent a177bdd commit 982793c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 4 additions & 5 deletions ixnetwork/IxnConfigManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions ixnetwork/IxnFileManagement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# from IxnHttp import IxnHttp
"""Encapsulates file transfer
"""
import json
import os


class IxnFileManagement(object):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 982793c

Please sign in to comment.