10-29-2023 10:30 PM
while running 'aggregate-address x.x.0.0/17 summary-only' command on ASR 9k router from python code as part BGP routing protocol. It's throwing response 'aggregate-address x.x.0$' and the BGP configuration is not done successfully.
Can you share inputs to resolve the issue.
Thanks.
10-30-2023 12:15 AM
Hello @Krishna Reddy Malem,
Could you share please your python code as concerned this command ?
Thanks.
10-30-2023 12:53 AM
Please find the python code snippet concerned.
import netmiko
from jinj2 import Template
try:
device = ConnectHandler(device_type='cisco_ios', ip='x.x.x.x', username='xxxxx', password='xxxxx')
path = "./test.txt"
with open(path) as file:
template = Template(file.read(), keep_trailing_newline=True)
with device as conn:
config_set = commands.split('\n')
output = conn.send_config_set(config_set)
11-02-2023 03:31 AM
Thanks for looking into my issue. I have shared the sample python script to execute the command. Could you please check and help us to resolve the issue. Let me know if you need any additional information, currently we are not able to move a head on BGP configuration.
11-02-2023 03:57 AM - edited 11-02-2023 04:17 AM
You python snippet looks like it could work fine depending on the contents of test.txt. Could you post the contents of that file?
11-02-2023 04:47 AM
Hello @Krishna Reddy Malem,
The error message "aggregate-address x.x.0$" suggests that there might be an issue with how the command is being interpreted. The '$' character is indicative of an incomplete command.
In your code, you are splitting the commands by '\n' (newline), which is a common way to separate commands. Make sure there are no extra characters or typos that might be causing issues with the splitting.
Also, ensure that the template is rendering correctly with the actual values for 'x.x.0.0/17'. You should verify that the template is correctly substituting the IP prefix.
Proposal:
import netmiko
try:
device = netmiko.ConnectHandler(device_type='cisco_xr', ip='x.x.x.x', username='xxxxx', password='xxxxx')
path = "./test.txt"
with open(path) as file:
config_set = file.read().splitlines()
with device as conn:
output = conn.send_config_set(config_set)
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide