コード例 #1
0
    def GET(self, session):
        print("LoadConfig Session:%s" % (session))
        webInsMgr.AddIns(int(session))
        webInsMgr.InstanceList[int(session)].ConfigMgr = configmgr.ConfigMgr(
        )  # Intializeds ConfigMgr within Instance
        #print ("Load Config: %s" %(webInsMgr.InstanceList[int(session)].ConfigMgr.GetConfigFileList()))
        #FileListDict =
        print()

        FileChoiceFormTable = HtmlTable(['Available Config Files'])
        FileChoiceFormTableSub = HtmlTable(['', 'Config File'])
        fpstring = 'LoadConfig/%s' % (session)
        print("Fpstring %s" % (fpstring))
        GetConfigFileDict = webInsMgr.InstanceList[int(
            session)].ConfigMgr.GetConfigFileList()
        for fileIndex in GetConfigFileDict:
            temp_Form = form.Form(
                form.Button('Load',
                            type="submit",
                            value=fileIndex,
                            target=fpstring,
                            id="submit"))
            FileChoiceFormTableSub.AddRow(
                [temp_Form.render(),
                 '%s' % (GetConfigFileDict[fileIndex])])

        FileChoiceFormTable.AddRow([FileChoiceFormTableSub])

        webInsMgr.InstanceList[int(session)].UpdateAccessTime()

        return render2.LoadExisting(0, FileChoiceFormTable.GetFormattedHtml(),
                                    session)
コード例 #2
0
ファイル: websession.py プロジェクト: codemation/py-k8s
    def GetAdminTableOutput(self):
        #self.Logger.addLog("AddInstance called")
        TableBase = HtmlTable(['Admin'])
        TableFreeSessionView = HtmlTable(
            ['# Active Sessions', '# Available Sessions for New Connections'])
        SessCount = self.GetCurrentCount()
        TableFreeSessionView.AddRow([SessCount, self.MaxInstances - SessCount])
        TableManageSessions = HtmlTable(
            ['Session Number', 'Last Active Time', 'Action'])
        TableManageServer = HtmlTable(['Restart Manager', 'Restart Server'])
        ManagerActionForm = form.Form(
            form.Button('RestartMan',
                        type="submit",
                        value='restart_man',
                        id="submit"))
        ServerActionForm = form.Form(
            form.Button('RestartSer',
                        type="submit",
                        value='restart_ser',
                        id="submit"))
        TableManageServer.AddRow([
            render2.Admin(ManagerActionForm),
            render2.Admin(ServerActionForm)
        ])
        SessionTrack = {}
        for session in self.InstanceList:
            ActionForm = form.Form(
                form.Button('kill: %d' % (session), value=session,
                            id="submit"))
            SessionIns = ActionForm()
            SessionTrack[session] = SessionIns
            TableManageSessions.AddRow([
                session, self.InstanceList[session].LastAccessTime,
                render2.Admin(SessionTrack[session])
            ])
        for Table in [
                TableFreeSessionView, TableManageSessions, TableManageServer
        ]:
            TableBase.AddRow([Table])

        return TableBase.GetFormattedHtml()
コード例 #3
0
def GetHtmlOut(session, formMgr, tableName, table):
    BaseTb = HtmlTable([tableName], tableName + '_base')
    xyTable = HtmlTable(['X', 'Y'], tableName + '_data')
    for xOrY in table:
        xyTable.AddRow([xOrY[0], xOrY[1]])
    xyAddToTable = HtmlTable(['Add To Table'], '%s_addTb' % (tableName))
    testTextBox = GlobalFormMgr.GetTextBox('noSession', 'xAddTb', '')
    testTextBox2 = GlobalFormMgr.GetTextBox('noSession', 'yAddTb', '')
    testButton1 = GlobalFormMgr.GetButton('noSession', 'submit', tableName,
                                          tableName + '_base', tableName)
    testButton2 = GlobalFormMgr.GetButton('noSession', 'delete', tableName,
                                          tableName + '_base', tableName)
    #RenderedForm = GlobalFormMgr.GetRenderedForm('noSession', [testTextBox,testTextBox2, testButton1, testButton2], tableName,'/getposttest/', 'POST', True)
    InputTable = HtmlTable(
        [testTextBox, testTextBox2,
         HtmlTable([testButton1, testButton2])], tableName, '/getposttest/',
        'POST')
    xyAddToTable.AddRow([InputTable])
    BaseTb.AddRow([xyTable])
    BaseTb.AddRow([xyAddToTable])
    return BaseTb.GetFormattedHtml()
コード例 #4
0
    def POST(self):
        TableBase = HtmlTable(['Admin'])
        TableFreeSessionView = HtmlTable(
            ['# Active Sessions', '# Available Sessions for New Connections'])
        SessCount = webInsMgr.GetCurrentCount()
        TableFreeSessionView.AddRow(
            [SessCount, webInsMgr.MaxInstances - SessCount])
        TableManageSessions = HtmlTable(
            ['Session Number', 'Last Active Time', 'Action'])
        TableManageServer = HtmlTable(['Restart Manager', 'Restart Server'])
        ManagerActionForm = form.Form(
            form.Button('RestartMan',
                        type="submit",
                        value='restart_man',
                        id="submit"))
        ServerActionForm = form.Form(
            form.Button('RestartSer',
                        type="submit",
                        value='restart_ser',
                        id="submit"))
        TableManageServer.AddRow([
            render2.Admin(ManagerActionForm),
            render2.Admin(ServerActionForm)
        ])
        SessionTrack = {}

        to_clean = []

        for session in webInsMgr.InstanceList:
            ActionForm = form.Form(
                form.Button('kill: %d' % (session), value=session,
                            id="submit"))
            SessionIns = ActionForm()
            SessionTrack[session] = SessionIns
            if SessionTrack[session].validates():
                for item in SessionTrack[session].d:
                    if not SessionTrack[session].d[item] == None:
                        to_clean.append(int(SessionTrack[session].d[item]))
                pass
            else:
                pass
        for clean_up_item in to_clean:
            webInsMgr.CleanUpSession(clean_up_item)
        for session in webInsMgr.InstanceList:
            TableManageSessions.AddRow([
                session, webInsMgr.InstanceList[session].LastAccessTime,
                render2.Admin(SessionTrack[session])
            ])

        for Table in [
                TableFreeSessionView, TableManageSessions, TableManageServer
        ]:
            TableBase.AddRow([Table])

        Manager = ManagerActionForm()
        Server = ServerActionForm()
        if not Manager.validates() or not Server.validates():
            return render2.AdminBase(TableBase.GetFormattedHtml())
        else:
            print(Manager.d)
            print(Server.d)

            for item in Manager.d:
                if not Manager.d[item] == None:
                    print("Restart Manager called")
                    webInsMgr.RestartManager()
                    webInsMgr.CleanCache()
            for item in Server.d:
                if not Server.d[item] == None:
                    import os
                    os.system(
                        'echo place-holder for restart of ignition service')

            TableBase = HtmlTable(['Admin'])
            TableFreeSessionView = HtmlTable([
                '# Active Sessions', '# Available Sessions for New Connections'
            ])
            SessCount = webInsMgr.GetCurrentCount()
            TableFreeSessionView.AddRow(
                [SessCount, webInsMgr.MaxInstances - SessCount])
            TableManageSessions = HtmlTable(
                ['Session Number', 'Last Active Time', 'Action'])
            TableManageServer = HtmlTable(
                ['Restart Manager', 'Restart Server'])
            ManagerActionForm = form.Form(
                form.Button('RestartMan',
                            type="submit",
                            value='restart_man',
                            id="submit"))
            ServerActionForm = form.Form(
                form.Button('RestartSer',
                            type="submit",
                            value='restart_ser',
                            id="submit"))
            TableManageServer.AddRow([
                render2.Admin(ManagerActionForm),
                render2.Admin(ServerActionForm)
            ])
            SessionTrack = {}
            for session in webInsMgr.InstanceList:
                ActionForm = form.Form(
                    form.Button('kill: %d' % (session),
                                value=session,
                                id="submit"))
                SessionIns = ActionForm()
                SessionTrack[session] = SessionIns
                TableManageSessions.AddRow([
                    session, webInsMgr.InstanceList[session].LastAccessTime,
                    render2.Admin(SessionTrack[session])
                ])
            for Table in [
                    TableFreeSessionView, TableManageSessions,
                    TableManageServer
            ]:
                TableBase.AddRow([Table])

            return render2.AdminBase(TableBase.GetFormattedHtml())