Пример #1
0
    def ping_ipv4_addr(self, ipv4_addr, interval=0.5, count=1, sync=False, size=56, should_succeed=True, do_arp=False):
        """Ping an IPv4 address."""

        if do_arp:
            # MidoNet requires some time to learn a new MAC address
            # since it has to write to Zookeeper and get an answer
            # We are advancing here MAC learning by sending an ARP
            # request one second before sending the ping. MN-662.
            self.send_arp_request(ipv4_addr)
            time.sleep(1)

        ping_cmd = ping4_cmd(ipv4_addr, interval, count, size)
        return self.execute(ping_cmd, should_succeed=should_succeed, sync=sync)
Пример #2
0
    def ping_ipv4_addr(self,
                       ipv4_addr,
                       interval=0.5,
                       count=3,
                       sync=False,
                       size=56,
                       suppress_failure=False,
                       do_arp=False):
        """Ping an IPv4 address."""

        if do_arp:
            # MidoNet requires some time to learn a new MAC address
            # since it has to write to Zookeeper and get an answer
            # We are advancing here MAC learning by sending an ARP
            # request one second before sending the ping. MN-662.
            self.send_arp_request(ipv4_addr)
            time.sleep(1)

        ping_cmd = ping4_cmd(ipv4_addr, interval, count, size)
        # Suppress an exception thrown by the future when the ping command
        # doesn't get any replies so that the execution terminates normally.
        if suppress_failure:
            ping_cmd += " || true"
        return self.execute(ping_cmd, sync=sync)