@ -10,7 +10,7 @@ import json
from itertools import chain
from ansible . module_utils . _text import to_ bytes, to_ text
from ansible . module_utils . _text import to_ text
from ansible . module_utils . network . common . utils import to_list
from ansible . plugins . cliconf import CliconfBase
@ -21,7 +21,7 @@ class Cliconf(CliconfBase):
device_info = { }
device_info [ ' network_os ' ] = ' edgeos '
reply = self . get ( b ' show version ' )
reply = self . get ( ' show version ' )
data = to_text ( reply , errors = ' surrogate_or_strict ' ) . strip ( )
match = re . search ( r ' Version: \ s*v?( \ S+) ' , data )
@ -32,24 +32,21 @@ class Cliconf(CliconfBase):
if match :
device_info [ ' network_os_model ' ] = match . group ( 1 )
reply = self . get ( b ' show host name ' )
reply = self . get ( ' show host name ' )
reply = to_text ( reply , errors = ' surrogate_or_strict ' ) . strip ( )
device_info [ ' network_os_hostname ' ] = reply
return device_info
def get_config ( self , source = ' running ' , format = ' text ' ) :
return self . send_command ( b ' show configuration commands ' )
return self . send_command ( ' show configuration commands ' )
def edit_config ( self , command ) :
for cmd in chain ( [ b ' configure ' ] , to_list ( command ) ) :
for cmd in chain ( [ ' configure ' ] , to_list ( command ) ) :
self . send_command ( cmd )
def get ( self , command , prompt = None , answer = None , sendonly = False ) :
return self . send_command ( to_bytes ( command ) ,
prompt = to_bytes ( prompt ) ,
answer = to_bytes ( answer ) ,
sendonly = sendonly )
return self . send_command ( command , prompt = prompt , answer = answer , sendonly = sendonly )
def commit ( self , comment = None ) :
if comment :
@ -59,7 +56,7 @@ class Cliconf(CliconfBase):
self . send_command ( command )
def discard_changes ( self , * args , * * kwargs ) :
self . send_command ( b ' discard ' )
self . send_command ( ' discard ' )
def get_capabilities ( self ) :
result = { }