Ejemplo n.º 1
0
def test_hpc_connection(user):
    """returns True/False after trying to connect to the cluster,
    sets a flag if successful and returns True if flag is set as
    True without testing the connection first"""
    try:
        hpcuser = MrTUser.objects.get(pk=user.id)
    except MrTUser.DoesNotExist:
        return False
#    logger.debug(dir(hpcuser))
    if hpcuser.testedConnection:
#        logger.debug("testConnection = True")
        return True
    myHPC = hpc.hpc(secrets.hostname,
                    hpcuser.hpc_username,
                    queuetype="sge", authtype="key",
                    key=secrets.privatekey, keytype="rsa")
    if myHPC.testConnection():
        hpcuser.testedConnection = True
#        logger.debug("tested for real: " + `hpcuser.testedConnection`)
        hpcuser.save()
        return True
    else:
        hpcuser.testedConnection = False
        hpcuser.save()
        return False
Ejemplo n.º 2
0
 def updateStatus(self):
     if self.jobstatus == "Finished" or self.jobstatus == "Retrieved":
         return self.jobstatus
     myHPC = hpc.hpc(secrets.hostname, self.user.hpc_username,
                     key=secrets.privatekey,
                     keytype=secrets.keytype)
     (out, err) = myHPC.getOutputError(
         "source /etc/profile;qstat -j " + self.hpcjobid)
     if err.startswith("Following jobs do not exist"):
         status = "Finished"
     else:
         lines = out.split("\n")
         for line in lines:
             if line.startswith("Following jobs do not exist"):
                 status = "Finished"
                 break
             elif line.startswith("usage"):
                 status = "Running"
                 break
             else:
                 status = "Queuing"
     self.jobstatus = status
     self.save()
     return status
Ejemplo n.º 3
0
 def _ensureHPC(self):
     if self.myHPC == None or not self.myHPC.testConnection():
         self.myHPC = hpc.hpc(secrets.hostname, self.username,
                              key=secrets.privatekey,
                              keytype=secrets.keytype)