noc.core.profile.base

Module Contents

class noc.core.profile.base.BaseProfileMetaclass

Bases: type

classmethod __new__(mcs, name, bases, attrs)
class noc.core.profile.base.BaseProfile

Bases: six.with_metaclass()

Equipment profile. Contains all equipment personality and specific

name
supported_schemes = []
pattern_username = ([Uu]ser ?[Nn]ame|[Ll]ogin): ?
pattern_password = [Pp]ass[Ww]ord: ?
pattern_super_password
pattern_prompt = ^\S*[>#]
pattern_unprivileged_prompt
pattern_more = ^---MORE---
pattern_syntax_error
pattern_operation_error
pattern_start_setup
pattern_multiline_commands
pattern_mml_end
pattern_mml_continue
can_strip_hostname_to
command_more =
command_submit =
username_submit
password_submit
setup_script
setup_session
shutdown_session
setup_http_session
http_request_middleware
shutdown_http_session
command_disable_pager
command_exit
command_super
command_enter_config
command_leave_config
command_save_config
send_on_syntax_error
rogue_chars = ['\r']
telnet_send_on_connect
telnet_slow_send_password = False
telnet_naws
setup_sequence
requires_netmask_conversion = False
max_scripts
default_parser
cli_timeout_start = 60
cli_timeout_user = 30
cli_timeout_password = 30
cli_timeout_super = 10
cli_timeout_setup = 10
cli_retries_super_password = 1
snmp_metrics_get_chunk = 15
snmp_metrics_get_timeout = 3
snmp_ifstatus_get_chunk = 15
snmp_ifstatus_get_timeout = 2
enable_cli_session = True
batch_send_multiline = True
mml_header_separator =
mml_always_quote = False
config_tokenizer
config_tokenizer_settings
config_normalizer
config_normalizer_settings
confdb_defaults
config_applicators
default_config_applicators = ['noc.core.confdb.applicator.rebase.RebaseApplicator', 'noc.core.confdb.applicator.interfacetype.InterfaceTypeApplicator', 'noc.core.confdb.applicator.adminstatus.DefaultAdminStatusApplicator', 'noc.core.confdb.applicator.fitype.DefaultForwardingInstanceTypeApplicator', 'noc.core.confdb.applicator.lldpstatus.DefaultLLDPStatusApplicator', 'noc.core.confdb.applicator.loopdetectstatus.DefaultLoopDetectStatusApplicator', 'noc.core.confdb.applicator.stpstatus.DefaultSTPStatusApplicator', 'noc.core.confdb.applicator.stppriority.DefaultSTPPriorityApplicator', 'noc.core.confdb.applicator.cdpstatus.DefaultCDPStatusApplicator', 'noc.core.confdb.applicator.ntp.DefaultNTPModeApplicator', 'noc.core.confdb.applicator.ntp.DefaultNTPVersionApplicator', 'noc.core.confdb.applicator.meta.MetaApplicator']
matchers
patterns
convert_mac
rx_cisco_interface_name
rx_num1
rx_num2
config_volatile
convert_prefix(self, prefix)

Convert ip prefix to the format accepted by router’s CLI

convert_mac_to_colon(self, mac)

Leave 00:11:22:33:44:55 style MAC-address untouched

convert_mac_to_cisco(self, mac)

Convert 00:11:22:33:44:55 style MAC-address to 0011.2233.4455

convert_mac_to_huawei(self, mac)

Convert 00:11:22:33:44:55 style MAC-address to 0011.2233.4455

convert_mac_to_dashed(self, mac)

Convert 00:11:22:33:44:55 style MAC-address to 00-11-22-33-44-55

convert_interface_name(self, s)

Normalize interface name

convert_interface_name_cisco(self, s)
>>> Profile().convert_interface_name_cisco("Gi0")
'Gi 0'
>>> Profile().convert_interface_name_cisco("GigabitEthernet0")
'Gi 0'
>>> Profile().convert_interface_name_cisco("Gi 0")
'Gi 0'
>>> Profile().convert_interface_name_cisco("tengigabitethernet 1/0/1")
'Te 1/0/1'
>>> Profile().convert_interface_name_cisco("tengigabitethernet 1/0/1.5")
'Te 1/0/1.5'
>>> Profile().convert_interface_name_cisco("Se 0/1/0:0")
'Se 0/1/0:0'
>>> Profile().convert_interface_name_cisco("Se 0/1/0:0.10")
'Se 0/1/0:0.10'
>>> Profile().convert_interface_name_cisco("ATM1/1/ima0")
'At 1/1/ima0'
>>> Profile().convert_interface_name_cisco("Port-channel5B")
'Po 5B'
root_interface(self, name)

Returns root interface >>> Profile().root_interface(“Gi 0/1”) ‘Gi 0/1’ >>> Profile().root_interface(“Gi 0/1.15”) ‘Gi 0/1’

get_interface_names(self, name)

Return possible alternative interface names, i.e. for LLDP discovery Local method

get_linecard(self, interface_name)

Returns linecard number related to interface >>> Profile().get_linecard(“Gi 4/15”) 4 >>> Profile().get_linecard(“Lo”) >>> Profile().get_linecard(“ge-1/1/0”) 1

get_stack_number(self, interface_name)

Returns stack number related to interface >>> Profile().get_stack_number(“Gi 1/4/15”) 1 >>> Profile().get_stack_number(“Lo”) >>> Profile().get_stack_number(“Te 2/0/1.5”) 2 >>> Profile().get_stack_number(“Se 0/1/0:0.10”) 0 >>> Profile().get_stack_number(“3:2”) 3 >>> Profile().get_stack_number(“3/2”) 3

generate_prefix_list(self, name, pl)

Generate prefix list: name - name of prefix list pl - is a list of (prefix, min_len, max_len) Strict - should tested prefix be exactly matched or should be more specific as well

cleaned_input(self, input)

Preprocessor to clean up and normalize input from device. Delete ASCII sequences by default. Can be overriden to achieve desired behavior

cleaned_config(self, cfg)

Clean up config

clean_lldp_neighbor(self, obj, neighbor)

Normalize and rewrite IGetLLDPNeighbors.neighbors structure in LLDP topology discovery. Remote object profile’s .clean_lldp_neighbor() used

Parameters:
  • obj – Managed Object reference
  • neighbor – IGetLLDPNeighbors.neighbors item
Returns:

IGetLLDPNeighbors.neighbors item

static add_script_method(script, name, method)
classmethod cmp_version(cls, v1, v2)

Compare two versions. Must return:

<0 , if v1<v2
0 , if v1==v2

>0 , if v1>v2

None , if v1 and v2 cannot be compared

Default implementation compares a versions in format N1. .. .NM

classmethod get_parser(cls, vendor, platform, version)

Returns full path to BaseParser instance to be used as config parser. None means no parser for particular platform

classmethod get_interface_type(cls, name)

Return IGetInterface-compatible interface type :param Name: Normalized interface name

classmethod initialize(cls)

Called once by profile loader

classmethod get_telnet_naws(cls)
classmethod allow_cli_session(cls, platform, version)
classmethod send_backspaces(cls, cli, command, error_text)
get_mml_login(self, script)

Generate MML login command. .get_mml_command may be used for formatting :param script: BaseScript instance :return: Login command

get_mml_command(self, cmd, **kwargs)

Generate MML command :param cmd: :param kwargs: :return:

parse_mml_header(self, header)

Parse MML response header :param header: Response header :return: error code, error message

classmethod get_config_tokenizer(cls, object)

Returns config tokenizer name and settings. object.matchers.XXXX can be used :param object: ManagedObject instance :return: config tokenizer name, config tokenizer settings

classmethod get_config_normalizer(cls, object)

Returns config normalizer name and settings :param object: ManagedObject instance :return:

classmethod get_confdb_defaults(cls, object)

Returns a list of confdb defaults to be inserted on every ConfDB creation :param object: :return:

classmethod iter_config_applicators(cls, object, confdb)

Returns config applicators and settings :param object: Managed Object instance :param confdb: ConfDB Engine instance :return: Iterate active config applicators (BaseApplicator instances)

classmethod get_http_request_middleware(cls, script)

Returns list of http_request_middleware. matchers.XXXX can be used? :param script: Script instance :return:

classmethod has_confdb_support(cls, object)
classmethod _get_patterns(cls)

Return dict of compiled regular expressions