@ -83,12 +83,12 @@ class Cliconf(CliconfBase):
operations = self . get_device_operations ( )
self . check_edit_config_capability ( operations , candidate , commit , replace , comment )
if ( commit is False ) and ( not self . supports_sessions ):
if ( commit is False ) and ( not self . supports_sessions () ):
raise ValueError ( ' check mode is not supported without configuration session ' )
resp = { }
session = None
if self . supports_sessions :
if self . supports_sessions () :
session = ' ansible_ %s ' % int ( time . time ( ) )
resp . update ( { ' session ' : session } )
self . send_command ( ' configure session %s ' % session )
@ -125,7 +125,7 @@ class Cliconf(CliconfBase):
resp [ ' request ' ] = requests
resp [ ' response ' ] = results
if self . supports_sessions :
if self . supports_sessions () :
out = self . send_command ( ' show session-config diffs ' )
if out :
resp [ ' diff ' ] = out . strip ( )
@ -148,7 +148,7 @@ class Cliconf(CliconfBase):
def discard_changes ( self , session = None ) :
commands = [ ' end ' ]
if self . supports_sessions :
if self . supports_sessions () :
# to close session gracefully execute abort in top level session prompt.
commands . extend ( [ ' configure session %s ' % session , ' abort ' ] )
@ -213,7 +213,6 @@ class Cliconf(CliconfBase):
diff [ ' config_diff ' ] = dumps ( configdiffobjs , ' commands ' ) if configdiffobjs else ' '
return diff
@property
def supports_sessions ( self ) :
use_session = self . get_option ( ' eos_use_sessions ' )
try :
@ -262,16 +261,16 @@ class Cliconf(CliconfBase):
def get_device_operations ( self ) :
return {
' supports_diff_replace ' : True ,
' supports_commit ' : True if self . supports_sessions else False ,
' supports_commit ' : bool ( self . supports_sessions ( ) ) ,
' supports_rollback ' : False ,
' supports_defaults ' : False ,
' supports_onbox_diff ' : True if self . supports_sessions else False ,
' supports_onbox_diff ' : bool ( self . supports_sessions ( ) ) ,
' supports_commit_comment ' : False ,
' supports_multiline_delimiter ' : False ,
' supports_diff_match ' : True ,
' supports_diff_ignore_lines ' : True ,
' supports_generate_diff ' : False if self . supports_sessions else True ,
' supports_replace ' : True if self . supports_sessions else False
' supports_generate_diff ' : not bool ( self . supports_sessions ( ) ) ,
' supports_replace ' : bool ( self . supports_sessions ( ) ) ,
}
def get_option_values ( self ) :