@ -211,6 +211,8 @@ def get_hsrp_group(group, interface, module):
try :
try :
body = run_commands ( module , [ command ] ) [ 0 ]
body = run_commands ( module , [ command ] ) [ 0 ]
hsrp_table = body [ ' TABLE_grp_detail ' ] [ ' ROW_grp_detail ' ]
hsrp_table = body [ ' TABLE_grp_detail ' ] [ ' ROW_grp_detail ' ]
if ' unknown enum: ' in str ( hsrp_table ) :
hsrp_table = get_hsrp_group_unknown_enum ( module , command , hsrp_table )
except ( AttributeError , IndexError , TypeError , KeyError ) :
except ( AttributeError , IndexError , TypeError , KeyError ) :
return { }
return { }
@ -239,6 +241,19 @@ def get_hsrp_group(group, interface, module):
return hsrp
return hsrp
def get_hsrp_group_unknown_enum ( module , command , hsrp_table ) :
''' Some older NXOS images fail to set the attr values when using structured output and
instead set the values to < unknown enum > . This fallback method is a workaround that
uses an unstructured ( text ) request to query the device a second time .
' sh_preempt ' is currently the only attr affected . Add checks for other attrs as needed .
'''
if ' unknown enum: ' in hsrp_table [ ' sh_preempt ' ] :
cmd = { ' output ' : ' text ' , ' command ' : command . split ( ' | ' ) [ 0 ] }
out = run_commands ( module , cmd ) [ 0 ]
hsrp_table [ ' sh_preempt ' ] = ' enabled ' if ( ' may preempt ' in out ) else ' disabled '
return hsrp_table
def get_commands_remove_hsrp ( group , interface ) :
def get_commands_remove_hsrp ( group , interface ) :
commands = [ ' interface {0} ' . format ( interface ) , ' no hsrp {0} ' . format ( group ) ]
commands = [ ' interface {0} ' . format ( interface ) , ' no hsrp {0} ' . format ( group ) ]
return commands
return commands