@@ -131,15 +131,16 @@ def syslog_wait_send_return(spawn, session):
131131 session ['buffer_len' ] = len (spawn .buffer )
132132
133133
134- def chatty_term_wait (spawn , trim_buffer = False ):
134+ def chatty_term_wait (spawn , trim_buffer = False , wait_time = None ):
135135 """ Wait some time for any chatter to cease from the device.
136136 """
137+ chatty_wait_time = wait_time or spawn .settings .ESCAPE_CHAR_CHATTY_TERM_WAIT
137138 for retry_number in range (spawn .settings .ESCAPE_CHAR_CHATTY_TERM_WAIT_RETRIES ):
138139
139- if buffer_settled (spawn , spawn . settings . ESCAPE_CHAR_CHATTY_TERM_WAIT ):
140+ if buffer_settled (spawn , chatty_wait_time ):
140141 break
141142 else :
142- buffer_wait (spawn , spawn . settings . ESCAPE_CHAR_CHATTY_TERM_WAIT * (retry_number + 1 ))
143+ buffer_wait (spawn , chatty_wait_time * (retry_number + 1 ))
143144
144145 else :
145146 spawn .log .warning ('The buffer has not settled because the device is chatty. '
@@ -334,35 +335,6 @@ def setup_enter_selection(spawn, context):
334335 spawn .sendline ('2' )
335336
336337
337- def enable_secret_handler (spawn , context , session ):
338- if 'password_attempts' not in session :
339- session ['password_attempts' ] = 1
340- else :
341- session ['password_attempts' ] += 1
342- if session .password_attempts > spawn .settings .PASSWORD_ATTEMPTS :
343- raise UniconAuthenticationError ('Too many enable password retries' )
344-
345- enable_credential_password = get_enable_credential_password (context = context )
346- if enable_credential_password and len (enable_credential_password ) >= \
347- spawn .settings .ENABLE_SECRET_MIN_LENGTH :
348- spawn .sendline (enable_credential_password )
349- else :
350- spawn .log .warning ('Using enable secret from TEMP_ENABLE_SECRET setting' )
351- enable_secret = spawn .settings .TEMP_ENABLE_SECRET
352- context ['setup_selection' ] = 0
353- spawn .sendline (enable_secret )
354-
355-
356- def setup_enter_selection (spawn , context ):
357- selection = context .get ('setup_selection' )
358- if selection is not None :
359- if str (selection ) == '0' :
360- spawn .log .warning ('Not saving setup configuration' )
361- spawn .sendline (f'{ selection } ' )
362- else :
363- spawn .sendline ('2' )
364-
365-
366338def ssh_tacacs_handler (spawn , context ):
367339 result = False
368340 start_cmd = spawn .spawn_command
@@ -758,6 +730,12 @@ def __init__(self):
758730 loop_continue = True ,
759731 continue_timer = False )
760732
733+ self .enter_your_encryption_selection_stmt = Statement (pattern = pat .enter_your_encryption_selection_2 ,
734+ action = setup_enter_selection ,
735+ args = None ,
736+ loop_continue = True ,
737+ continue_timer = True )
738+
761739#############################################################
762740# Statement lists
763741#############################################################
@@ -803,7 +781,8 @@ def __init__(self):
803781
804782initial_statement_list = [generic_statements .init_conf_stmt ,
805783 generic_statements .mgmt_setup_stmt ,
806- generic_statements .enter_your_selection_stmt
784+ generic_statements .enter_your_selection_stmt ,
785+ generic_statements .enter_your_encryption_selection_stmt
807786 ]
808787
809788
@@ -817,4 +796,5 @@ def __init__(self):
817796 default_statement_list + \
818797 authentication_statement_list + \
819798 initial_statement_list + \
820- pre_connection_statement_list
799+ pre_connection_statement_list
800+
0 commit comments