示例#1
0
    def test_send_cmd(self):
        # pass test
        result = ssh.send_cmd("localhost", "ls", {})
        self.assertEquals(result["exit_status"], 0)
        self.assertTrue(len(result["stdout"]) > 0)

        # fail test
        result = ssh.send_cmd("randomhost", "ls", {})
        self.assertEquals(result["exit_status"], -1)
        self.assertEquals(result["stdout"], None)
        self.assertEquals(result["stderr"], None)
示例#2
0
    def test_remote_check_file(self):
        node = "localhost"
        ssh.send_cmd(node, "touch test.txt", {})
        pass_target = os.path.expanduser("~/test.txt")
        fail_target = os.path.expanduser("~/non-existent-file")

        # pass test
        result = ssh.remote_check_file(node, pass_target, {})
        self.assertTrue(result)

        # fail test
        result = ssh.remote_check_file(node, fail_target, {})
        self.assertFalse(result)

        os.unlink(pass_target)
示例#3
0
    def test_parse_netadaptor_details(self):
        result = ssh.send_cmd("localhost", "ifconfig", {})
        result = ssh.parse_netadaptor_details(result["stdout"])

        self.assertTrue(result[0]["ip"] is not None)
        self.assertTrue(result[0]["mac_addr"] is not None)