Interface configuration mode #172
-
Dear all, I'm new to Scrapli and so far I guess I understand the basics. This might or might not be specific to huawei/smartax. When PRIVILEGE_LEVELS are defined properly I can send configurations e.g. with async with AsyncScrapli(**my_device) as conn:
result = await conn.send_config(
'some config line',
privilege_level="configuration",
) however if I need to enter an interface first, then do a config there and "leave" the interface again. Is there a best practice or a predefined "flow" how to do this? Do I need to create another privilege level or how would I attempt this properly? I could of course do: results = await conn.send_configs([
"interface gpon 0/1",
"some config on the interface",
"quit"],
privilege_level="configuration"
) but then what if "interface gpon 0/1" does not exist, then the 3rd line "quit" would make me leave the configuration mode. And also the parsing of the "some config line" seems a bit difficult. Maybe I missed something in the docs. Any help is appreciated :-) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
hey @seimnseimn what you've outlined here is what I would do (run the commands in the interface then "quit"). scrapli doesn't really care about/understand the config/structure of the router/switch/thing so its up to you to decide how to handle things. if you were worried about the interface not existing you could always do some show command then conditionally run your config based on that output. you could probably get nutty with adding privilege levels and stuff but I dont think id advise that for interfaces or anything like that. |
Beta Was this translation helpful? Give feedback.
hey @seimnseimn
what you've outlined here is what I would do (run the commands in the interface then "quit"). scrapli doesn't really care about/understand the config/structure of the router/switch/thing so its up to you to decide how to handle things. if you were worried about the interface not existing you could always do some show command then conditionally run your config based on that output.
you could probably get nutty with adding privilege levels and stuff but I dont think id advise that for interfaces or anything like that.