Skip to content

sros md-cli: premature end when issuing command #67

@nskalis

Description

@nskalis

Hi,

And thank you for making unicon available. I encountered an issue when trying to dump the configuration of a sros router using md-cli. More specifically,

  • the connection object is defined like:
uni_conn = unicon.Connection(
    hostname="some-name",
    os="sros",
    start=["{} {}".format("ssh", "x.x.x.x")],
    learn_hostname=True,
    credentials={
        "default": {
            "username": os.environ["NETWORK_USERNAME"],
            "password": os.environ["NETWORK_PASSWORD"],
        }
    },
    init_config_commands=[],
    log_stdout=True,
    debug=True,
    connection_timeout=10,
    overwrite_settings=False,
    settings={"DEFAULT_CLI_ENGINE": "mdcli"},
)
  • The command issued is:
    (the purpose is to dump the router's configuration)
uni_conn.execute("admin show configuration flat | no-more", timeout=10)
  • But, the output stops being produced, the last lines look like this:
...
    configure { policy-options as-path-group "BOGON_ASNS_IN" }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 1 }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 1 expression ".* 0 .*" }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 2 }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 2 expression ".* 23456 .*" }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 3 }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 3 expression ".*

While the router's configuration is:

...
    configure { policy-options as-path-group "BOGON_ASNS_IN" }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 1 }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 1 expression ".* 0 .*" }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 2 }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 2 expression ".* 23456 .*" }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 3 }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 3 expression ".* [64496-64511] .*" }
    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 4 }
...

It seems there is a problem with the [ character.

  • What the debug option prints out is:
\r\n    configure { policy-options as-path-group "BOGON_ASNS_IN" }\r\n    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 1 }\r\n    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 1 expression ".* 0 .*" }\r\n    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 2 }\r\n    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 2 expression ".* 23456 .*" }\r\n    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 3 }\r\n    configure { policy-options as-path-group "BOGON_ASNS_IN" entry 3 expression ".* ',)


2022-10-29 19:46:43,132: %UNICON-DEBUG: Statement matched: '[pattern='^(.*?)\[.*\][\r\n]+[AB]:.*@some-name#\s?$', action=None, args=None, loop_continue=False, continue_timer=False, trim_buffer=True]'
2022-10-29 19:46:43,206: %UNICON-DEBUG: Statement matched: '[pattern='^(.*?)\[.*\][\r\n]+[AB]:.*@some-name#\s?$', action=None, args=None, loop_continue=False, continue_timer=False, trim_buffer=True]'
2022-10-29 19:46:43,211: %UNICON-DEBUG: >>> Unicon Sending (target=some-name):: '\r'
2022-10-29 19:46:43,229: %UNICON-DEBUG: <<< Unicon Got (target=some-name):: '\r\n'
2022-10-29 19:46:43,229: %UNICON-DEBUG: *** Pattern List (target=some-name):: 
2022-10-29 19:46:43,229: %UNICON-DEBUG: 	'.+$'
2022-10-29 19:46:43,230: %UNICON-DEBUG: 
2022-10-29 19:46:43,230: %UNICON-DEBUG: *** Pattern Matched (target=some-name):: '.+$'
2022-10-29 19:46:43,230: %UNICON-DEBUG: <unicon.eal.MatchMode mode_id=0, mode_name='search multi-line re.S'>
2022-10-29 19:46:43,230: %UNICON-DEBUG: 
[]
A:user_awesome@some-name# 
2022-10-29 19:46:43,230: %UNICON-DEBUG: <<< Unicon Got (target=some-name):: '\r\n\r\n[]\r\nA:user_awesome@some-name# '
2022-10-29 19:46:43,230: %UNICON-DEBUG: *** Pattern List (target=some-name):: 
2022-10-29 19:46:43,230: %UNICON-DEBUG: 	'^(.*?)\\*?[AB]:some-name(>.*)?#\\s?$'
2022-10-29 19:46:43,230: %UNICON-DEBUG: 	'^(.*?)\\[.*\\][\\r\\n]+[AB]:.*@some-name#\\s?$'
2022-10-29 19:46:43,230: %UNICON-DEBUG: 
2022-10-29 19:46:43,230: %UNICON-DEBUG: *** Pattern Matched (target=some-name):: '^(.*?)\\[.*\\][\\r\\n]+[AB]:.*@some-name#\\s?$'
2022-10-29 19:46:43,230: %UNICON-DEBUG: <unicon.eal.MatchMode mode_id=0, mode_name='search multi-line re.S'>
2022-10-29 19:46:43,230: %UNICON-DEBUG: *** Match Groups:: ('\r\n\r\n',)
2022-10-29 19:46:43,230: %UNICON-DEBUG: Statement matched: '[pattern='^(.*?)\[.*\][\r\n]+[AB]:.*@some-name#\s?$', action=update_cur_state, args={'transition': <unicon.statemachine.statetransition.AnyStateTransition object at 0x7f4e9ffa94f0>, 'state': mdcli}, loop_continue=False, continue_timer=False, trim_buffer=True]'
2022-10-29 19:46:43,237: %UNICON-DEBUG: >>> Unicon Sending (target=some-name):: '\x1a'
[]
A:user_awesome@some-name# 
2022-10-29 19:46:43,259: %UNICON-DEBUG: <<< Unicon Got (target=some-name):: '\r\n\r\n[]\r\nA:user_awesome@some-name# '
2022-10-29 19:46:43,259: %UNICON-DEBUG: *** Pattern List (target=some-name):: 
2022-10-29 19:46:43,259: %UNICON-DEBUG: 	'Discard uncommitted changes\\? \\[y,n\\]'
2022-10-29 19:46:43,259: %UNICON-DEBUG: 	'^(.*?)\\[.*\\][\\r\\n]+[AB]:.*@some-name#\\s?$'
2022-10-29 19:46:43,259: %UNICON-DEBUG: 
2022-10-29 19:46:43,260: %UNICON-DEBUG: *** Pattern Matched (target=some-name):: '^(.*?)\\[.*\\][\\r\\n]+[AB]:.*@some-name#\\s?$'
2022-10-29 19:46:43,260: %UNICON-DEBUG: <unicon.eal.MatchMode mode_id=0, mode_name='search multi-line re.S'>
2022-10-29 19:46:43,260: %UNICON-DEBUG: *** Match Groups:: ('\r\n\r\n',)
2022-10-29 19:46:43,260: %UNICON-DEBUG: Statement matched: '[pattern='^(.*?)\[.*\][\r\n]+[AB]:.*@some-name#\s?$', action=None, args=None, loop_continue=False, continue_timer=False, trim_buffer=True]'

Would you be so kind to look into it and advise what is going wrong?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions