Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Issue Getting Output from device CLI via NetMRI API
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2021 06:23 AM
1921     0
Hello,
I need to get output from a device CLI via the NetMRI API from an external server. I am testing with the python script below which was posted here by SBaksh
The issue seems to be with dis_sessions. This line just returns None:
cli_connection = client.api_request('dis_sessions/open_session_and_connection', params={'device_id': i.DeviceID})
Here is the complete script:
# BEGIN-SCRIPT-BLOCK # # Script-Filter: # true # # Script-Login: # false # # Script-Variables: # # Script-Timeout: # 3670 # # END-SCRIPT-BLOCK import infoblox_netmri from infoblox_netmri.client import InfobloxNetMRI client = infoblox_netmri.client.InfobloxNetMRI( host='netmri.mydomain.com', username=http_username, password=http_password, api_version='3.7', use_ssl='true', ssl_verify='true' ) # Get brokers for required objects device_broker = client.get_broker('Device') # Search for our 2 devices to get the Id's devices = device_broker.search(DeviceName=[ 'nameOfDevice1','nameOfDevice2' ]) for i in devices: # Open Dis and Cli Session print('Opening DIS and Cli Session for device_id: ',i.DeviceID) cli_connection = client.api_request('dis_sessions/open_session_and_connection', params={'device_id': i.DeviceID}) print("Cli Connection: ",cli_connection) # Send Command response = client.api_request('cli_connections/send_command', params={'SessionID': cli_connection['cli_connection']['SessionID'], 'device_id': i.DeviceID, 'command': 'sh ip int brief'}) print("Send Response: ",response) # Close the Session response = client.api_request('dis_sessions/close', params={'SessionID': cli_connection['cli_connection']['SessionID']}) print("Close response: ",response)
Labels:
Re: Issue Getting Output from device CLI via NetMRI API
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 05:05 PM
1922     0
Hi, Did you ever get this to work? I tested my script again and it is working fine (with show cdp nei).
Rgds