Beispiel #1
0
def entRenewSubmitJob():
    """[新普通用户初次配置资源后进行续期,提交作业]"""
    title = "[新普通用户初次配置资源后进行续期,提交作业]"

    global res
    #新增企业用户
    newuser = casjc_user.auser()
    tmpuser = newuser.addControlUser()
    #申请审批配置资源并续期
    rescoure = casjc_resource.resource(tmpuser[0], tmpuser[1], tmpuser[2])
    rescoure.testRenew()
    #新增企业普通用户
    newuser2 = casjc_user.cuser(tmpuser[0])
    luser = newuser2.addQueueStoreUser()
    #登录企业普通用户
    userinfo = casjc_login.login(luser, casjc_config.cpasswd, 0)
    #等待610秒,等高性能配置生效
    time.sleep(610)
    url = "ws://10.8.14.181:11014/webshell?uid=" + str(
        userinfo[1]
    ) + "&id=42&queueName=" + casjc_config.queuename + "&token=" + userinfo[
        0] + "&cols=132&rows=15&width=1870&height=510"
    casjc_log_task.logging.info(newSubmitJob.__doc__ + " 登录webshell: " + url)
    jobname = str(time.strftime('%d%H%M', time.localtime()))
    try:
        ws = create_connection(url, timeout=60)
        print(ws.recv())
        sjob1 = 'nohup srun -p low -J casjc-' + jobname + ' sleep 180&\n'
        casjc_log_task.logging.info(newSubmitJob.__doc__ + '执行slurm命令:' +
                                    sjob1)
        print(ws.recv())
        print(json.loads(ws.recv())['data'])
        print(ws.recv())
        print(ws.recv())
        print(ws.recv())
        ws.send(sjob1)
        ws.send('\n')
        time.sleep(1)
        print(ws.recv())
        print(ws.recv())
        sjob2 = 'squeue\n'
        casjc_log_task.logging.info(newSubmitJob.__doc__ + '执行slurm命令:' +
                                    sjob2)
        ws.send(sjob2)
        print(ws.recv())
        time.sleep(2)
        squeue = ws.recv()
        print(squeue)
        res[title + sjob1] = [luser[0], squeue]
        return True
    except Exception as e:
        print('error', e)
        res[title] = [luser[0], "webServer timeout"]
        return False
Beispiel #2
0
    def testRenew(self, mytype="half"):
        self.applyOrder()
        self.applyPrice()
        self.generateContract()
        self.exaContract()
        self.confirmParam(mytype)
        self.confirmAll(mytype)
        #配置完存储后需要等给用户配置完成在进行续期
        time.sleep(30)
        self.renewResource()


if __name__ == "__main__":
    #mytest = resource('crazy03231701','100905','10831')
    tmp = casjc_user.auser()
    a, b, c = tmp.addControlUser()
    mytest = resource(a, b, c)
    print(a)
    #mytest = resource()
    '''
    try:
        if sys.argv[1] == "1":
            mytest.testNew()
        elif sys.argv[1] == "0":
            mytest.testTry()
    except IndexError:
        print('not have parames')
    '''

    #试用