Send a ping RPC to a device dest_ip The IP of the device to ping dev_timeout : 30 The NETCONF RPC timeout (in seconds) rapid : False When ``True``, executes ping at 100pps instead of 1pps ttl Maximum number of IP routers (IP hops) allowed betwee
(dest_ip=None, **kwargs)
| 779 | |
| 780 | @_timeout_decorator |
| 781 | def ping(dest_ip=None, **kwargs): |
| 782 | """ |
| 783 | Send a ping RPC to a device |
| 784 | |
| 785 | dest_ip |
| 786 | The IP of the device to ping |
| 787 | |
| 788 | dev_timeout : 30 |
| 789 | The NETCONF RPC timeout (in seconds) |
| 790 | |
| 791 | rapid : False |
| 792 | When ``True``, executes ping at 100pps instead of 1pps |
| 793 | |
| 794 | ttl |
| 795 | Maximum number of IP routers (IP hops) allowed between source and |
| 796 | destination |
| 797 | |
| 798 | routing_instance |
| 799 | Name of the routing instance to use to send the ping |
| 800 | |
| 801 | interface |
| 802 | Interface used to send traffic |
| 803 | |
| 804 | count : 5 |
| 805 | Number of packets to send |
| 806 | |
| 807 | CLI Examples: |
| 808 | |
| 809 | .. code-block:: bash |
| 810 | |
| 811 | salt 'device_name' junos.ping '8.8.8.8' count=5 |
| 812 | salt 'device_name' junos.ping '8.8.8.8' ttl=1 rapid=True |
| 813 | """ |
| 814 | conn = __proxy__["junos.conn"]() |
| 815 | ret = {} |
| 816 | |
| 817 | if dest_ip is None: |
| 818 | ret["message"] = "Please specify the destination ip to ping." |
| 819 | ret["out"] = False |
| 820 | return ret |
| 821 | |
| 822 | op = {"host": dest_ip} |
| 823 | if "__pub_arg" in kwargs: |
| 824 | if kwargs["__pub_arg"]: |
| 825 | if isinstance(kwargs["__pub_arg"][-1], dict): |
| 826 | op.update(kwargs["__pub_arg"][-1]) |
| 827 | else: |
| 828 | op.update(kwargs) |
| 829 | |
| 830 | op["count"] = str(op.pop("count", 5)) |
| 831 | if "ttl" in op: |
| 832 | op["ttl"] = str(op["ttl"]) |
| 833 | |
| 834 | ret["out"] = True |
| 835 | try: |
| 836 | ret["message"] = jxmlease.parse(etree.tostring(conn.rpc.ping(**op))) |
| 837 | except Exception as exception: # pylint: disable=broad-except |
| 838 | ret["message"] = f'Execution failed due to "{exception}"' |
nothing calls this directly
no test coverage detected