Beispiel #1
0
 def dump_pcap_on_host(self, pcapfile, timeout=5):
     """
     Does tcpdump to a pcap file for "n" seconds on the host veth device
     corresponding to the eth0 interface inside the docker container.
     """
     veth_index = self.run(
         "cat /sys/class/net/eth0/iflink")[1].strip()
     veth = self.run_from_root(
         "grep -l " + veth_index + " /sys/class/net/veth*/ifindex")[1].split("/")[4]
     run_cmd("timeout " + str(timeout) + " tcpdump -nn -A -i " + veth + " -w test/trn_func_tests/output/" +
             self.ip + "_" + pcapfile + "_dump.pcap >/dev/null 2>&1 &")
Beispiel #2
0
    def local(self, cmd):
        ret_value = None
        logger.info("[LOCAL {}]: running: {}".format(self.id, cmd))
        try:
            out = run_cmd(cmd)
            ret_value = (out[0], out[1])
            if (ret_value[0] != 0):
                logger.error("[LOCAL {}]: {}".format(self.id, ret_value[1]))

            logger.debug(
                "[LOCAL {}]: running\n    command:\n {}, \n    exit_code: {},\n    output:\n {}"
                .format(self.id, cmd, ret_value[0], ret_value[1]))

            return ret_value
        except Exception as e:
            logger.error("[LOCAL {}]: {}".format(self.id, str(e)))
            return None
Beispiel #3
0
 def run_from_root(self, cmd):
     ret_value = run_cmd(cmd)
     logger.debug(
         "[DROPLET {}]: running from root\n    command:\n {}, \n    exit_code: {},\n    output:\n {}"
         .format(self.id, cmd, ret_value[0], ret_value[1]))
     return ret_value