@ -103,26 +103,26 @@ EXAMPLES = '''
'''
def map_obj_to_command ( want , have , module ) :
def map_obj_to_command s ( want , have , module ) :
""" Define ovs-vsctl command to meet desired state """
command = None
command s = list ( )
if module . params [ ' state ' ] == ' absent ' :
if ' key ' in have . keys ( ) :
templatized_command = " % (ovs-vsctl)s -t %(timeout)s remove %(table)s %(record)s " \
" %(col)s %(key)s = %(value)s "
command = templatized_command % module . params
command s. append ( templatized_command % module . params )
else :
if ' key ' not in have . keys ( ) :
templatized_command = " % (ovs-vsctl)s -t %(timeout)s add %(table)s %(record)s " \
" %(col)s %(key)s = %(value)s "
command = templatized_command % module . params
command s. append ( templatized_command % module . params )
elif want [ ' value ' ] != have [ ' value ' ] :
templatized_command = " % (ovs-vsctl)s -t %(timeout)s set %(table)s %(record)s " \
" %(col)s : %(key)s = %(value)s "
command = templatized_command % module . params
command s. append ( templatized_command % module . params )
return command
return command s
def map_config_to_obj ( module ) :
@ -190,12 +190,13 @@ def main():
want = map_params_to_obj ( module )
have = map_config_to_obj ( module )
command = map_obj_to_command ( want , have , module )
result [ ' command ' ] = command
command s = map_obj_to_command s ( want , have , module )
result [ ' command s ' ] = command s
if command :
if command s :
if not module . check_mode :
module . run_command ( command , check_rc = True )
for c in commands :
module . run_command ( c , check_rc = True )
result [ ' changed ' ] = True
module . exit_json ( * * result )