def run_cli(module, cli):
 cliswitch = module.params['pn_cliswitch']
 state = module.params['state']
 command = get_command_from_state(state)
 cmd = shlex.split(cli)
 (result, out, err) = module.run_command(cmd)
 print_cli = cli.split(cliswitch)[1]
 if (result != 0):
  module.exit_json(command=print_cli, stderr=err.strip(), msg=('%s operation failed' % command), changed=False)
 if out:
  module.exit_json(command=print_cli, stdout=out.strip(), msg=('%s operation completed' % command), changed=True)
 else:
  module.exit_json(command=print_cli, msg=('%s operation completed' % command), changed=True)

def run_cli ( module , cli ) : cliswitch = module . params [ 'pn_cliswitch' ] state = module . params [ 'state' ] command = get_command_from_state ( state ) cmd = shlex . split ( cli ) ( result , out , err ) = module . run_command ( cmd ) print_cli = cli . split ( cliswitch ) [ 1 ] if ( result != 0 ) : module . exit_json ( command = print_cli , stderr = err . strip ( ) , msg = ( '%s operation failed' % command ) , changed = False ) if out : module . exit_json ( command = print_cli , stdout = out . strip ( ) , msg = ( '%s operation completed' % command ) , changed = True ) else : module . exit_json ( command = print_cli , msg = ( '%s operation completed' % command ) , changed = True )
command line execution entry point for running tests .