def ping(<EOL>self,<EOL>destination,<EOL>source=c.PING_SOURCE,<EOL>ttl=c.PING_TTL,<EOL>timeout=c.PING_TIMEOUT,<EOL>size=c.PING_SIZE,<EOL>count=c.PING_COUNT,<EOL>vrf=c.PING_VRF,<EOL>):
ping_dict = {}<EOL>version = "<STR_LIT>"<EOL>try:<EOL><INDENT>version = "<STR_LIT>" if IPAddress(destination).version == <NUM_LIT:6> else "<STR_LIT>"<EOL><DEDENT>except AddrFormatError:<EOL><INDENT>pass<EOL><DEDENT>command = "<STR_LIT>".format(<EOL>version=version, destination=destination<EOL>)<EOL>command += "<STR_LIT>".format(timeout)<EOL>command += "<STR_LIT>".format(size)<EOL>command += "<STR_LIT>".format(count)<EOL>if source != "<STR_LIT>":<EOL><INDENT>command += "<STR_LIT>".format(source)<EOL><DEDENT>if vrf != "<STR_LIT>":<EOL><INDENT>command += "<STR_LIT>".format(vrf)<EOL><DEDENT>output = self._send_command(command, raw_text=True)<EOL>if "<STR_LIT>" in output:<EOL><INDENT>ping_dict["<STR_LIT:error>"] = output<EOL><DEDENT>elif "<STR_LIT>" in output:<EOL><INDENT>ping_dict["<STR_LIT:success>"] = {<EOL>"<STR_LIT>": <NUM_LIT:0>,<EOL>"<STR_LIT>": <NUM_LIT:0>,<EOL>"<STR_LIT>": <NUM_LIT:0.0>,<EOL>"<STR_LIT>": <NUM_LIT:0.0>,<EOL>"<STR_LIT>": <NUM_LIT:0.0>,<EOL>"<STR_LIT>": <NUM_LIT:0.0>,<EOL>"<STR_LIT>": [],<EOL>}<EOL>results_array = []<EOL>for line in output.splitlines():<EOL><INDENT>fields = line.split()<EOL>if "<STR_LIT>" in line:<EOL><INDENT>if "<STR_LIT>" in line:<EOL><INDENT>if "<STR_LIT:(>" in fields[<NUM_LIT:2>]:<EOL><INDENT>results_array.append(<EOL>{<EOL>"<STR_LIT>": py23_compat.text_type(<EOL>fields[<NUM_LIT:2>][<NUM_LIT:1>:-<NUM_LIT:1>]<EOL>),<EOL>"<STR_LIT>": <NUM_LIT:0.0>,<EOL>}<EOL>)<EOL><DEDENT>else:<EOL><INDENT>results_array.append(<EOL>{<EOL>"<STR_LIT>": py23_compat.text_type(fields[<NUM_LIT:1>]),<EOL>"<STR_LIT>": <NUM_LIT:0.0>,<EOL>}<EOL>)<EOL><DEDENT><DEDENT>elif "<STR_LIT>" in line:<EOL><INDENT>if "<STR_LIT:(>" in fields[<NUM_LIT:4>]:<EOL><INDENT>results_array.append(<EOL>{<EOL>"<STR_LIT>": py23_compat.text_type(<EOL>fields[<NUM_LIT:4>][<NUM_LIT:1>:-<NUM_LIT:2>]<EOL>),<EOL>"<STR_LIT>": <NUM_LIT:0.0>,<EOL>}<EOL>)<EOL><DEDENT>else:<EOL><INDENT>results_array.append(<EOL>{<EOL>"<STR_LIT>": py23_compat.text_type(fields[<NUM_LIT:3>][:-<NUM_LIT:1>]),<EOL>"<STR_LIT>": <NUM_LIT:0.0>,<EOL>}<EOL>)<EOL><DEDENT><DEDENT>elif fields[<NUM_LIT:1>] == "<STR_LIT>":<EOL><INDENT>if version == "<STR_LIT>":<EOL><INDENT>m = fields[<NUM_LIT:5>][<NUM_LIT:5>:]<EOL><DEDENT>else:<EOL><INDENT>m = fields[<NUM_LIT:6>][<NUM_LIT:5>:]<EOL><DEDENT>results_array.append(<EOL>{<EOL>"<STR_LIT>": py23_compat.text_type(fields[<NUM_LIT:3>][:-<NUM_LIT:1>]),<EOL>"<STR_LIT>": float(m),<EOL>}<EOL>)<EOL><DEDENT><DEDENT>elif "<STR_LIT>" in line:<EOL><INDENT>ping_dict["<STR_LIT:success>"]["<STR_LIT>"] = int(fields[<NUM_LIT:0>])<EOL>ping_dict["<STR_LIT:success>"]["<STR_LIT>"] = int(fields[<NUM_LIT:0>]) - int(<EOL>fields[<NUM_LIT:3>]<EOL>)<EOL><DEDENT>elif "<STR_LIT>" in line:<EOL><INDENT>m = fields[<NUM_LIT:3>].split("<STR_LIT:/>")<EOL>ping_dict["<STR_LIT:success>"].update(<EOL>{<EOL>"<STR_LIT>": float(m[<NUM_LIT:0>]),<EOL>"<STR_LIT>": float(m[<NUM_LIT:1>]),<EOL>"<STR_LIT>": float(m[<NUM_LIT:2>]),<EOL>}<EOL>)<EOL><DEDENT><DEDENT>ping_dict["<STR_LIT:success>"].update({"<STR_LIT>": results_array})<EOL><DEDENT>return ping_dict<EOL>
Execute ping on the device and returns a dictionary with the result.
Output dictionary has one of following keys:
    * success
    * error
In case of success, inner dictionary will have the followin keys:
    * probes_sent (int)
    * packet_loss (int)
    * rtt_min (float)
    * rtt_max (float)
    * rtt_avg (float)
    * rtt_stddev (float)
    * results (list)
'results' is a list of dictionaries with the following keys:
    * ip_address (str)
    * rtt (float)