示例#1
0
    def wmGetUsersTable(self):
        sHTML = ""
        pager_html = ""
        sFilter = uiCommon.getAjaxArg("sSearch")
        sPage = uiCommon.getAjaxArg("sPage")
        maxrows = 25

        u = catouser.Users(sFilter)
        if u.rows:
            start, end, pager_html = uiCommon.GetPager(len(u.rows), maxrows, sPage)

            for row in u.rows[start:end]:
                sHTML += "<tr user_id=\"" + row["user_id"] + "\">"
                sHTML += "<td class=\"chkboxcolumn\">"
                sHTML += "<input type=\"checkbox\" class=\"chkbox\"" \
                " id=\"chk_" + row["user_id"] + "\"" \
                " tag=\"chk\" />"
                sHTML += "</td>"

                sHTML += "<td class=\"selectable\">" + row["status"] + "</td>"
                sHTML += "<td class=\"selectable\">" + row["full_name"] + "</td>"
                sHTML += "<td class=\"selectable\">" + row["username"] + "</td>"
                sHTML += "<td class=\"selectable\">" + row["role"] + "</td>"
                sHTML += "<td class=\"selectable\">" + str(row["last_login_dt"]) + "</td>"

                if row["Tags"]:
                    tags = row["Tags"].split(",")
                    tags = "Tags:\n%s" % ("\n".join(tags))
                    sHTML += '<td class="selectable"><span class="ui-icon ui-icon-tag" title="' + tags + '"></span></td>'
                else:
                    sHTML += '<td class="selectable">&nbsp;</td>'

                sHTML += "</tr>"

        return json.dumps({"pager": uiCommon.packJSON(pager_html), "rows": uiCommon.packJSON(sHTML)})
示例#2
0
    def wmGetTemplatesTable(self):
        """ Get a list of all Deployment Templates"""
        sHTML = ""
        pager_html = ""
        sFilter = uiCommon.getAjaxArg("sSearch")
        sPage = uiCommon.getAjaxArg("sPage")
        maxrows = 25

        deps = deployment.DeploymentTemplates(sFilter, show_unavailable=True)
        if deps.rows:
            start, end, pager_html = uiCommon.GetPager(len(deps.rows), maxrows, sPage)

            for row in deps.rows[start:end]:
                available = 'Yes' if row["Available"] else 'No'

                sHTML += """
                <tr template_id="{0}">
                <td class="chkboxcolumn">    
                    <input type="checkbox" class="chkbox" id="chk_{0}" object_id="{0}" tag="chk" />
                </td>""".format(row["ID"])

                sHTML += '<td class="selectable">' + row["Name"] + '</td>'
                sHTML += '<td class="selectable">' + row["Version"] + '</td>'
                sHTML += '<td class="selectable">' + (row["Description"] if row["Description"] else "") + '</td>'
                sHTML += '<td class="selectable">' + available + '</td>'

                sHTML += "</tr>"

        return json.dumps({"pager": uiCommon.packJSON(pager_html), "rows": uiCommon.packJSON(sHTML)})
示例#3
0
    def wmGetDeploymentsTable(self):
        """ Get a list of all Deployments"""
        sHTML = ""
        pager_html = ""
        sFilter = uiCommon.getAjaxArg("sSearch")
        sPage = uiCommon.getAjaxArg("sPage")
        maxrows = 25

        deps = deployment.Deployments(sFilter)
        if deps.rows:
            start, end, pager_html = uiCommon.GetPager(len(deps.rows), maxrows, sPage)

            for row in deps.rows[start:end]:
                sHTML += u"""
                <tr deployment_id="{0}">
                <td class="chkboxcolumn">    
                    <input type="checkbox" class="chkbox" id="chk_{0}" object_id="{0}" tag="chk" />
                </td>
                
                <td class="selectable">{1}</td>
                <td class="selectable">{2}</td>
                <td class="selectable">{3}</td>
                
                </tr>
                """.format(row["ID"], row["Name"], row["RunState"], row.get("Description", ""))

        return json.dumps({"pager": uiCommon.packJSON(pager_html), "rows": uiCommon.packJSON(sHTML)})
示例#4
0
    def wmGetCloudsTable(self):
        sHTML = ""
        pager_html = ""
        sFilter = uiCommon.getAjaxArg("sSearch")
        sPage = uiCommon.getAjaxArg("sPage")
        maxrows = 25

        c = cloud.Clouds(sFilter)
        if c.rows:
            start, end, pager_html = uiCommon.GetPager(len(c.rows), maxrows, sPage)

            for row in c.rows[start:end]:
                sHTML += "<tr cloud_id=\"" + row["ID"] + "\">"
                sHTML += "<td class=\"chkboxcolumn\">"
                sHTML += "<input type=\"checkbox\" class=\"chkbox\"" \
                " id=\"chk_" + row["ID"] + "\"" \
                " tag=\"chk\" />"
                sHTML += "</td>"

                sHTML += "<td class=\"selectable\">%s</td>" % row["Name"]
                sHTML += "<td class=\"selectable\">%s</td>" % row["Provider"]
                sHTML += "<td class=\"selectable\">%s</td>" % row["APIUrl"]
                sHTML += "<td class=\"selectable\">%s</td>" % row["APIProtocol"]
                sHTML += "<td class=\"selectable\">%s</td>" % (row["DefaultAccount"] if row["DefaultAccount"] else "&nbsp;")

                sHTML += "</tr>"

        return json.dumps({"pager": uiCommon.packJSON(pager_html), "rows": uiCommon.packJSON(sHTML)})
示例#5
0
    def wmGetProcessLogfile(self):
        component = uiCommon.getAjaxArg("component")
        logfile = ""
        if component:
            logfile = "%s/%s.log" % (catolog.LOGPATH, component)
            if os.path.exists(logfile):
                with open(logfile, 'r') as f:
                    f.seek(0, 2)  # Seek @ EOF
                    fsize = f.tell()  # Get Size
                    f.seek(max(fsize - 102400, 0), 0)  # Set pos @ last n chars
                    tail = f.readlines()  # Read to end

                    return uiCommon.packJSON("".join(tail))

        return uiCommon.packJSON("Unable to read logfile. [%s]" % logfile)
示例#6
0
文件: cskui.py 项目: AsherBond/cato
 def GET(self):
     try:
         result, msg, lic = catolicense.check_license("legato")
         if lic:
             lic = uiCommon.packJSON(uiCommon.FixBreaks(uiCommon.SafeHTML(lic)))
         return json.dumps({"result": result, "message": msg, "license": lic})
     except Exception as ex:
         logger.error(ex.__str__())
示例#7
0
    def wmGetLog(self):
        sObjectID = uiCommon.getAjaxArg("sObjectID")
        sObjectType = uiCommon.getAjaxArg("sObjectType")
        sSearch = uiCommon.getAjaxArg("sSearch")
        sRecords = uiCommon.getAjaxArg("sRecords", "100")
        sFrom = uiCommon.getAjaxArg("sFrom", "")
        sTo = uiCommon.getAjaxArg("sTo", "")

        logtype = "Security" if not sObjectID and not sObjectType else "Object"
        rows = catocommon.get_security_log(oid=sObjectID, otype=sObjectType, logtype=logtype,
                                           search=sSearch, num_records=sRecords, _from=sFrom, _to=sTo)

        out = []
        if rows:
            for row in rows:
                r = []
                r.append(row["log_dt"])
                r.append(uiCommon.packJSON(row["full_name"]))
                r.append(uiCommon.packJSON(uiCommon.SafeHTML(row["log_msg"])))
                out.append(r)

        return json.dumps({"log": out})
示例#8
0
    def wmGetAssetsTable(self):
        sHTML = ""
        pager_html = ""
        sFilter = uiCommon.getAjaxArg("sSearch")
        sPage = uiCommon.getAjaxArg("sPage")
        maxrows = 25

        a = asset.Assets(sFilter)
        if a.rows:
            # before we break the results into pages, we first filter it by tag
            # THIS IS DEPENDANT on the results containing a list of tags.
            allowedrows = uiCommon.FilterSetByTag(a.rows)

            start, end, pager_html = uiCommon.GetPager(len(allowedrows), maxrows, sPage)

            for row in allowedrows[start:end]:
                sHTML += "<tr asset_id=\"" + row["ID"] + "\">"
                sHTML += "<td class=\"chkboxcolumn\">"
                sHTML += "<input type=\"checkbox\" class=\"chkbox\"" \
                " id=\"chk_" + row["ID"] + "\"" \
                " tag=\"chk\" />"
                sHTML += "</td>"

                sHTML += "<td class=\"selectable\">%s</td>" % row["Name"]
                sHTML += "<td class=\"selectable\">%s</td>" % row["Status"]
                sHTML += "<td class=\"selectable\">%s</td>" % (row["Address"] if row["Address"] else "")
                sHTML += "<td class=\"selectable\">%s</td>" % (row["Credentials"] if row["Credentials"] else "")

                if row["Tags"]:
                    tags = row["Tags"].split(",")
                    tags = "Tags:\n%s" % ("\n".join(tags))
                    sHTML += '<td class="selectable"><span class="ui-icon ui-icon-tag" title="' + tags + '"></span></td>'
                else:
                    sHTML += '<td class="selectable">&nbsp;</td>'
                    
                sHTML += "</tr>"

        return json.dumps({"pager": uiCommon.packJSON(pager_html), "rows": uiCommon.packJSON(sHTML)})
示例#9
0
    def wmGetCredentialsTable(self):
        sHTML = ""
        pager_html = ""
        sFilter = uiCommon.getAjaxArg("sSearch")
        sPage = uiCommon.getAjaxArg("sPage")
        maxrows = 25

        c = asset.Credentials(sFilter)
        if c.rows:
            start, end, pager_html = uiCommon.GetPager(len(c.rows), maxrows, sPage)

            for row in c.rows[start:end]:
                sHTML += """<tr credential_id="{0}">
                    <td class="chkboxcolumn">
                        <input type="checkbox" class="chkbox" id="chk_{0}" tag="chk" />
                    </td>
                    <td class="selectable">{1}</td>
                    <td class="selectable">{2}</td>
                    <td class="selectable">{3}</td>
                </tr>
                """.format(row["ID"], row["Name"], row["Type"], row["Description"])

        return json.dumps({"pager": uiCommon.packJSON(pager_html), "rows": uiCommon.packJSON(sHTML)})