コード例 #1
0
 def __init__(self, host, port, username, password):
     self.device = SSHArchDevice(host, port, username,
                                 password)  # Unbridged
     self.connection = None
     self.responder = None
     self.result = None
     self.stdout = ""
     self.stderr = ""
コード例 #2
0
    def test_connect_ssh(self):
        """Tests the main function of connecting through SSH."""
        TEST_LOG.info("SSH connection")
        test_dev = SSHArchDevice(host, port, username, password)

        test_dev._connect_ssh()

        self.assertIsNotNone(test_dev.ssh)
コード例 #3
0
    def test_execute_list(self):
        """Test send a command."""
        test_dev = SSHArchDevice(host, port, username, password)
        res = test_dev.execute(["uname -a", "whoami", "free -hg"])
        self.assertIn("GNU/Linux", res)

        test_dev.add_root_password('root')
        res = test_dev.execute(["uname -a", "whoami", "free -hg"], su=True)
        self.assertIn("GNU/Linux", res)
コード例 #4
0
    def test_execute(self):
        """Test send a command."""
        test_dev = SSHArchDevice(host, port, username, password)
        res = test_dev.execute("whoami")
        self.assertIn("alarm", res)

        test_dev.add_root_password('root')
        res = test_dev.execute("whoami", su=True)
        self.assertIn("root", res)
コード例 #5
0
    def test_bind_unbind(self):
        """Tests the main function of connecting through SSH."""
        TEST_LOG.info("SSH channel close connection")
        test_dev = SSHArchDevice(host, port, username, password)

        self.assertIsNone(test_dev.ssh)
        self.assertIsNone(test_dev.channel)

        test_dev.bind()
        self.assertIsNotNone(test_dev.ssh)
        self.assertIsNotNone(test_dev.channel)

        test_dev.unbind()
        self.assertIsNone(test_dev.ssh)
        self.assertIsNone(test_dev.channel)