cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
619
Views
0
Helpful
5
Replies

logfile option in pyats testbed

Shesh
Level 1
Level 1

Hi,

I am trying to use the "logfile" option in pyats testbed. Unfortunately, the logs are not getting saved.

Has anyone tried this? Any suggestions on how to get this working? Thanks

Sample:

 

testbed:
  name: testbed_file
  credentials:
    default:
      username: 'cisco'
      password: 'cisco'
devices:
  SWITCH_1:
    os: nxos
    type: nxos
    connections:
      cli:
        protocol: ssh
        ip: 10.10.10.1
        arguments:
          log_stdout: false
          logfile: logfile_1.log
          init_config_commands: []
          init_exec_commands:
            - terminal length 0

 

PS: I am able to connect to device and run commands.

Thanks in advance!

 

5 Replies 5

ammahend
VIP Alumni
VIP Alumni

try complete path for the logfile where the program has write permissions.

logfile: ./logs/logfile_1.log # Ensure this path is valid and writable

-hope this helps-

Thanks for the reply @ammahend.

I provided the entire path "/Users/shesh/.../logfile_1.log" But it did not work, still writes to /tmp.

I am saving another file in the same folder from within the code, so I don't think it's an access issue.

Update the args section with

arguments: # Remove log_stdout as it's not needed when using logfile logfile: '/path/to/logs/logfile_1.log' # Use absolute path init_config_commands: [] init_exec_commands: - terminal length 0

Ensure you have the correct permissions to write to the location you are attempting. You can create the log directory before running the script, sometimes if this isn’t present the log file will not create and write the file.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Thanks @bigevilbeard 

I removed the log_stdout (though I don't think it's causing any issue). Still can't get the log file in desired place.

If I directly pass the logfile: '/path/to/logs/logfile_1.log' as a parameter to device.connect, it works. So it's not permission issue.

For some reason logfile from testbed is not getting picked up.

 

As directly passing logfile to device.connect() works, the issue would be in how the testbed configuration is being processed I think.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io