6.1. configuration on device(s) module

class nettoolkit.configure.configure.ConfigEnvironmentals(auth, log_folder, config_log, exec_log, exec_display)[source]

Bases: Multi_Execution

Configuration Object environmental properties. Inherits Multi_Execution

class nettoolkit.configure.configure.Config_common[source]

Bases: object

Common Methods and properties for Configuration classes

get_connection()[source]

retrive a new connection

Returns:

connection object

Return type:

conn

get_device_type(ip, auth)[source]

detecting device type (cisco, juniper)

Parameters:
  • ip (str) – device ip

  • auth (dict) – authentication dicationary with ‘un’, ‘pw’. ‘en’ keys.

Returns:

device type if detected, else None

Return type:

str

send_configuration(conf_list)[source]

sends provided list of configuration to self device connection

Parameters:

conf_list (list) – configuration change list

Returns:

success/fail

Return type:

bool

set_hostname()[source]

retrive hostname from current connection

terminate_connection()[source]

terminate active connection

write_config_log(host, log)[source]

send out the configuration log to a log file

Parameters:
  • host (str) – host/device name

  • log (str/multiline) – log to be write to

write_exec_log(host, s, ends='\n')[source]

writes execution log (internal)

Parameters:
  • host (str) – host/device name

  • s (str/multiline) – execution log content

  • ends (str, optional) – End string. Defaults to enter.

class nettoolkit.configure.configure.Configure(ip, auth, conf_list=None, conf_file=None, log_folder=None, config_log=True, exec_log=True, exec_display=True)[source]

Bases: Config_common

Configure class to do configuration on a Cisco IOS or Juniper Junos device Inherits Config_common

Parameters:
  • ip (str) – device ip address or FQDN

  • auth (dict) – authentication dicationary with ‘un’, ‘pw’. ‘en’ keys.

  • conf_list (list, optional) – configuration change list. Defaults to None. Either

  • conf_file (str, optional) – configuration change file. Defaults to None. Or

  • log_folder (str, optional) – folder where logs to be stored. Defaults to None.

  • config_log (bool, optional) – generate configuration log. Defaults to True.

  • exec_log (bool, optional) – generate execution log. Defaults to True.

  • exec_display (bool, optional) – on screen display execution log. Defaults to True.

apply()[source]

apply the configuration to active connection

cisco_commit()[source]

write mem on cisco device

Returns:

success or fail

Return type:

bool

cisco_enable()[source]

method to enable device mode

cisco_push()[source]

method defining configuration push for Cisco devices

Returns:

False if unable to connect, None after connection terminate

Return type:

bool/None

cisco_verify_push_op(op)[source]

verifications on cisco configuration push output

Parameters:

op (multiline str) – configuaration log output

Returns:

success or syntex error

Return type:

bool

juniper_commit()[source]

commiting the pushed juniper configurations.

Returns:

success or fail

Return type:

bool

juniper_push()[source]

method defining configuration push for Juniper devices

Returns:

False if unable to connect, None after connection terminate

Return type:

bool/None

juniper_verify_commit_op(op)[source]

verification of commit

Parameters:

op (multiline str) – configuaration log output

juniper_verify_push_op(op)[source]

verifications on juniper configuration push output

Parameters:

op (multiline str) – configuaration log output

Returns:

success or syntex error

Return type:

bool

class nettoolkit.configure.configure.ConfigureByExcel(auth, files=[], tab_sort_order=[], log_folder=None, config_log=True, exec_log=True, exec_display=True, configure=False, sleep_time_between_group=0)[source]

Bases: ConfigEnvironmentals

class to do configuration based on configuration changes provided in excel. All listed devices in a single Excel tab will be executed at once (simultaneously). Multiple Excel tabs/files can be provided to execute those in sequence.

Inherits ConfigEnvironmentals

Parameters:
  • auth (dict) – authentication dicationary with ‘un’, ‘pw’. ‘en’ keys.

  • files (list, optional) – list of excel files, will be executed in provided sequence. Defaults to [].

  • tab_sort_order (list, optional) – Excel tabs execution order. Defaults to []. ( options: privide in list manually, ascending, reversed)

  • log_folder (str, optional) – folder where logs to be stored. Defaults to None.

  • config_log (bool, optional) – generate configuration log. Defaults to True.

  • exec_log (bool, optional) – generate execution log. Defaults to True.

  • exec_display (bool, optional) – on screen display execution log. Defaults to True.

  • configure (bool, optional) – configure or it is for test only. Defaults to False.

  • sleep_time_between_group (int, optional) – sleep time between execution of two groups of executions. Defaults to 0.

static get_concurrance(i, cg, tso_list)[source]
run(**kwargs)
class nettoolkit.configure.configure.GroupsConfigure(auth, devices_config_dict={}, config_by_order=True, order_list=[], dev_apply_at_dict={}, log_folder=None, config_log=True, exec_log=True, exec_display=True, configure=False)[source]

Bases: Multi_Execution

Configure class to do configuration on a multiple group of devices at a time. Inherits Multi_Execution

Parameters:
  • auth (dict) – authentication dicationary with ‘un’, ‘pw’. ‘en’ keys.

  • devices_config_dict (dict, optional) – {device:[list of config], } . Defaults to {}.

  • config_by_order (bool, optional) – if True follows execution in provided order_list entries. Defaults to True.

  • order_list (list, optional) – order list in which execution to be done. Defaults to [].

  • dev_apply_at_dict (dict, optional) – time to apply config at (under implementation). Defaults to {}.

  • log_folder (str, optional) – folder where logs to be stored. Defaults to None.

  • config_log (bool, optional) – generate configuration log. Defaults to True.

  • exec_log (bool, optional) – generate execution log. Defaults to True.

  • exec_display (bool, optional) – on screen display execution log. Defaults to True.

  • configure (bool, optional) – configure or it is for test only. Defaults to False.

configure_by_orderlist(**kwargs)
execute(ip)[source]

executor

Parameters:

ip (str) – device ip or FQDN

remove_empty_config_lines()[source]

sanitizer: removes empty lines from configuration

remove_order_list_item(item, lst)[source]

sanitizer: Remove device from configuration sequence where no configuration changes provided.

Parameters:
  • item (str) – device ip or FQDN

  • lst (list) – configuration change list