Subversion Repositories DevTools

Rev

Rev 7261 | Rev 7286 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'
'   _iframe_build_logs.asp
'   This page is designed to be called from within an IFRAME
'
'   Locate log files for a specific build
'
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0    ' always load the page, dont store
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/formating.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/_form_window_common.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_general.asp"-->
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT> 
<%
'------------ Variable Definition -------------
Dim rsTemp
Dim Query
Dim parRtagId
Dim parBuildRef
Dim MachineNames
Dim BuildInfo
Dim BuildLogs
Dim sMessage

'------------ Constants Declaration -----------
'------------ Variable Init -------------------
parRtagId = Request("rtag_id")
parBuildRef = Request("build_ref")
Set MachineNames = CreateObject("Scripting.Dictionary")
Set BuildLogs = CreateObject("Scripting.Dictionary")
Set BuildInfo = CreateObject("Scripting.Dictionary")
sMessage = NULL
'----------------------------------------------
'
'   Build up a dictionary of build machine names
'   Get all amchine names as the config may have changed since the log was created
'
Query = "select display_name, UPPER(MACHINE_HOSTNAME) as MACHINE_HOSTNAME FROM release_manager.build_machine_config"
Set rsTemp = OraDatabase.DbCreateDynaset(Query, cint(0))
While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
    Dim mName, dName
    MachineNames.Add CStr(rsTemp("MACHINE_HOSTNAME")), CStr(rsTemp("display_name"))   
    rsTemp.MoveNext
WEnd
rsTemp.Close
Set rsTemp = nothing

'
'   Build up a dictionary of build machine config in this release - as it is now
'
Query = "select display_name, daemon_mode, gbe_value, gbe_buildfilter " &_
                         " from release_manager.release_config rc," &_
                         "      release_manager.build_machine_config bm," &_
                         "      release_manager.gbe_machtype gbe" &_
                         " where rc.rtag_id=" & parRtagId &_
                         "      and rc.bmcon_id=bm.bmcon_id(+)" &_
                         "      and rc.gbe_id=gbe.gbe_id" &_
                         "      and display_name is not NULL"
Set rsTemp = OraDatabase.DbCreateDynaset( Query, ORADYN_DEFAULT )

Dim mData(3)
While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
        mData(0) = IIf (CStr(rsTemp("daemon_mode")) = "M", "Master", "Slave")
        mData(1) = NiceCStr(rsTemp("gbe_value"), "") 
        mData(2) = NiceCStr(rsTemp("gbe_buildfilter"), "-Default-")
    BuildInfo.Add CStr(rsTemp("display_name")), mData
    rsTemp.MoveNext
WEnd
rsTemp.Close
Set rsTemp = nothing

'----------------------------------------------
' Test that specified package/version exists in dpkg_archive
' Can also test presence of the archive
'   Use http interface as it does not require authetication
Sub testLogExistence(sBuildRef)
    Dim objXML
    Dim testUrl
    Dim jJSON

    testUrl = HTTP_PKG_ARCHIVE
    testUrl = testUrl & "/cgi-bin/getBuildLogs.pl"
    testUrl = testUrl & "?buildRef=" &  sBuildRef
    testUrl = testUrl & "&rtagId=" &  parRtagId

    Err.Clear
    On Error Resume Next

    Set objXML = CreateObject("MSXML2.ServerXMLHTTP.3.0")
    objXML.Open "GET", testUrl, False
    objXML.Send

    if Err.Number <> 0 then
        sMessage = Err.Description
        On Error Goto 0
    else
        On Error Goto 0
        If  objXML.status = 403 then
            sMessage = "Package Server Access Denied"

        ElseIf  objXML.status <> 200 then
            sMessage = "Internal Error: Code " & objXML.status
            'sMessage = objXML.responseText
        Else
            Set jJSON = New aspJSON
            jJSON.loadJSON( objXML.responseText )

            Dim txt
                        txt = jJSON.data.item("error")
                        If txt <> "" Then
                sMessage = txt
                        Else
                Dim this, el
                Set this = jJSON.data.item("data") 
                For Each el in this.keys
                    Dim parts : parts = split( this(el), "/")
                    Dim mName : mName = parts(0)
                    Dim dName : dName = MachineNames.item(mName)
                                If dName = "" Then
                                        dName = mName & "*"
                    End If
                    BuildLogs.Add dName , CStr(this(el))   
                    'Response.Write "<pre>Key: " & el & " Value: " & ABTLOG_URL & this(el)
                Next
                Set jJSON = nothing
                Set this = nothing
            End If
       End If
    End If
    Set objXML = nothing
End Sub

'--- Bfore Render ---------------
testLogExistence(parBuildRef )
'----------------------------------------------
%>
<html>
<head>
<title>Release Manager</title>
<link rel="shortcut icon" href="<%=FavIcon%>"/>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="images/release_manager_style.css?ver=<%=VixVerNum%>" type="text/css">
<script language="JavaScript" src="images/common.js?ver=<%=VixVerNum%>"></script>
<!--#include file="_jquery_includes.asp"-->
<script language="javascript">
$(document).ready(function () {
    //  Cancel button must close this iFrame using a function provided by the parent
    $('#btn_cancel').on('click', function (e) {parent.closeIFrame()});

    // Kill the progress spinner
        $('#progressBar').hide();
});
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" >
<!----------------------------------------------------->
<!-- BODY ---->
<div class="panel tight">
        <div id='progressBar' class='vixSpinner' ></div>
        <div class='controlPanel'>
        <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
        <%Call Messenger ( sMessage , 1, "100%" )%>
        <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
        </div>
        <div class=textPanel>
                A package is built on one or more build machines. Each build machine will produce a log of the build for the package.
                The logs are retained for about 10 days and then discarded.
        </div>
        <div class=listPanel>
        <table width="100%" border="0" cellspacing="1" cellpadding="1" class=stdGrey style="border-collapse: unset;">
          <thead>
                <th nowrap>Build Machine</th>
                <th nowrap>Mode</th>
                <th nowrap>MACH_TYPE</th>
                <th nowrap>GBE_BUILDFILTER</th>
          </thead>
                <%
        Dim sName, sPath, hRef, aBuildInfo, sMaster, sMachType, sFilter
                If BuildLogs.Count <= 0 Then%>
                <tr>
                        <td>No Logs Found. They may have expired</td>
                </tr>
                <%Else
        For Each sName In BuildLogs.Keys
            sPath = BuildLogs.item(sName)
                        hRef = ABTLOG_URL & "/" & sPath
            aBuildInfo = BuildInfo.item(sName)
                        If TypeName(aBuildInfo) = "Variant()" Then
                sMaster = aBuildInfo(0) 
                sMachType = aBuildInfo(1) 
                sFilter = aBuildInfo(2)
            End If
                        %>
                        <tr>
                                <td><a href=<%=hRef%> target="_blank"><%=sName%></a></td>
                                <td><%=sMaster%></td>
                                <td><%=sMachType%></td>
                                <td><%=sFilter%></td>
                        </tr>
                        <%
        Next
                End If%>
        </table>
        </div>
        <div class=buttonPanelWhite>
                <button id="btn_cancel" class="form_btn">Done</button>
        </div>
</body>
</html>
<%
Call Destroy_All_Objects
%>