@cherrypy.expose
    def log(self, host, size=25, fn="/var/log/install.log"):
        status = self.compute.servers.find(public_ip=host).status

        if status == "ACTIVE":
            try:
                import paramiko
                privatekeyfile = self.private_key
                mykey = paramiko.RSAKey.from_private_key_file(privatekeyfile)
                ssh = paramiko.SSHClient()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect(host, username='root', pkey=mykey, timeout=2)
                stdin, stdout, stderr = \
                    ssh.exec_command('tail -n %d "%s"' % (int(size), fn))
                log = stdout.read()
                ssh.close()
            except Exception, e:
                log = "Exception: %s" % e
        else:
            log = "Slice is not ready to be used, we are currently in status: %s" % status

        tmpl = open(self.base + '/templates/log.html').read()
        return jsontemplate.expand(tmpl, {'log': log, 'host': host})
dataset/ETHPy150Open cloudbuilders/radioedit/radioedit.py/RadioEdit.log/original