noc.core.script.cli.base

Module Contents

class noc.core.script.cli.base.CLI(script, tos=None)

Bases: object

name = cli
default_port
iostream_class
BUFFER_SIZE
MATCH_TAIL = 256
MATCH_MISSED_CONTROL_TAIL = 8
CONNECT_RETRIES
CONNECT_TIMEOUT
HAS_TCP_KEEPALIVE
HAS_TCP_KEEPIDLE
HAS_TCP_KEEPINTVL
HAS_TCP_KEEPCNT
HAS_TCP_NODELAY
KEEP_IDLE = 10
KEEP_INTVL = 10
KEEP_CNT = 3
SYNTAX_ERROR_CODE = +@@@NOC:SYNTAXERROR@@@+
close(self)
close_iostream(self)
set_state(self, state)
deferred_close(self, session_timeout)
_set_close_timeout(self, session_timeout)

Wrapper to deal with IOLoop.add_timeout thread safety problem :param session_timeout: :return:

create_iostream(self)
set_timeout(self, timeout)
run_sync(self, func, *args, **kwargs)

Simplified implementation of IOLoop.run_sync to distinguish real TimeoutErrors from incomplete futures :param func: :param args: :param kwargs: :return:

execute(self, cmd, obj_parser=None, cmd_next=None, cmd_stop=None, ignore_errors=False, allow_empty_response=True)
submit(self, parser=None)
cleaned_input(self, s)

Clean up received input and wipe out control sequences and rogue chars

send(self, cmd)
read_until_prompt(self)
parse_object_stream(self, parser=None, cmd_next=None, cmd_stop=None)
Parameters:
  • cmd
  • command_submit
  • parser – callable accepting buffer and returning (key, data, rest) or None. key - string with object distinguisher data - dict containing attributes rest – unparsed rest of string
  • cmd_next – Sequence to go to the next page
  • cmd_stop – Sequence to stop
Returns:

send_pager_reply(self, data, match)

Send proper pager reply

expect(self, patterns, timeout=None)

Send command if not none and set reply patterns

on_start(self, data=None, match=None)
on_username(self, data, match)
on_password(self, data, match)
on_unprivileged_prompt(self, data, match)
on_failure(self, data, match, error_cls=None)
on_prompt(self, data, match)
on_super_username(self, data, match)
on_super_password(self, data, match)
on_setup_sequence(self, data, match)
resolve_pattern_prompt(self, match)

Resolve adaptive pattern prompt

push_prompt_pattern(self, pattern)

Override prompt pattern

pop_prompt_pattern(self)

Restore prompt pattern

get_motd(self)

Return collected message of the day

set_script(self, script)
setup_session(self)
shutdown_session(self)
on_error_sequence(self, seq, command, error_text)

Process error sequence :param seq: :param command: :param error_text: :return: