%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'| |
'| ADMIN Build Status Information |
'| |
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0 ' always load the page, dont store
%>
<% '------------ ACCESS CONTROL ------------------ %>
<%
'------------ Variable Definition -------------
Dim rsQry
Dim query_string
Dim styleAlt1
Dim styleAlt2
Dim styleNow
Dim param_refreshPeriod
Dim param_inactivity
Dim param_refreshEnabled
Dim buildStatus
Dim bShowProblemDaemonSets ' Indicates if problem daemons must be shown during filtering
Dim bShowDisabledDaemons ' Indicates if a disabled daemon must be shown during filtering
Dim bShowActiveBuilds ' Indicates if active builds must be shown during filtering
Dim bShowIdleBuilds ' Indicates if idle builds must be shown during filtering
Dim bShowPausedBuilds ' Indicates if paused builds must be shown during filtering
Dim bShowAutoProject ' Hide projects that have no active components
Dim bProjectToggle ' State of the Project toggler
'------------ Constants Declaration -----------
Const Min_Refresh_Time = 10 ' Seconds
Const Max_DeltaBuild = 31 ' Days
'------------ Variable Init -------------------
styleAlt1="class='body_rowg1'"
styleAlt2="class='body_rowg2'"
styleNow = styleAlt1
'----------------------------------------------
%>
<%
'------------------------------------------------------------------------------
' Populate the buildStatus dictionary
' Get all the required data into a hash of hashes
' It will make the following processing so much easier
'
Sub getBuildStatus
Dim bms
query_string = "SELECT rc.RCON_ID, " &_
" rc.RTAG_ID, " &_
" bm.DISPLAY_NAME, " &_
" rc.DAEMON_MODE, "&_
" rt.RTAG_NAME, " &_
" rt.OFFICIAL, " &_
" rt.BUILD_AGE, " &_
" p.PROJ_ID, " &_
" p.PROJ_NAME, " &_
" rl.CURRENT_PKG_ID_BEING_BUILT, "&_
" rl.CURRENT_RUN_LEVEL, "&_
" NVL(rl.PAUSE,0) as PAUSE, " &_
" TRUNC (86400*(SYSDATE - rl.KEEP_ALIVE)) as delta," &_
" TO_CHAR(rl.LAST_BUILD, 'DD-MON-YYYY') as last_build," &_
" TRUNC (SYSDATE - rl.LAST_BUILD) as last_build_days," &_
" pkg.PKG_NAME, NVL(ACTIVE, 'U') as ACTIVE" &_
" FROM RELEASE_CONFIG rc, RELEASE_TAGS rt, PROJECTS p, RUN_LEVEL rl, BUILD_MACHINE_CONFIG bm, PACKAGES pkg " &_
" WHERE rt.RTAG_ID = rc.RTAG_ID " &_
" AND rc.bmcon_id is not null" &_
" AND rt.PROJ_ID = p.PROJ_ID " &_
" AND rt.OFFICIAL in ( 'N', 'R', 'C')" &_
" AND rl.RCON_ID(+) = rc.RCON_ID" &_
" AND rc.bmcon_id = bm.bmcon_id(+)" &_
" AND pkg.PKG_ID(+) = rl.CURRENT_PKG_ID_BEING_BUILT" &_
" ORDER BY p.PROJ_NAME, rt.RTAG_NAME, rc.DAEMON_MODE, bm.DISPLAY_NAME, rc.DAEMON_MODE"
Set buildStatus = CreateObject("Scripting.Dictionary")
Set rsQry = OraDatabase.DbCreateDynaset( query_string, ORADYN_DEFAULT )
Do While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
Set bms = CreateObject("Scripting.Dictionary")
bms.Item("RCON_ID") = rsQry("RCON_ID")
bms.Item("RTAG_ID") = rsQry("RTAG_ID")
bms.Item("DISPLAY_NAME") = rsQry("DISPLAY_NAME")
bms.Item("RTAG_NAME") = rsQry("RTAG_NAME")
bms.Item("DAEMON_MODE") = rsQry("DAEMON_MODE")
bms.Item("OFFICIAL") = rsQry("OFFICIAL")
bms.Item("BUILD_AGE") = NiceInt(rsQry("BUILD_AGE"), 31)
bms.Item("PROJ_ID") = rsQry("PROJ_ID")
bms.Item("PROJ_NAME") = rsQry("PROJ_NAME")
bms.Item("CURRENT_PKG_ID_BEING_BUILT") = rsQry("CURRENT_PKG_ID_BEING_BUILT")
bms.Item("CURRENT_RUN_LEVEL") = rsQry("CURRENT_RUN_LEVEL")
bms.Item("PAUSE") = CInt(rsQry("PAUSE"))
bms.Item("delta") = rsQry("delta")
bms.Item("last_build") = rsQry("last_build")
bms.Item("last_build_days") = NiceInt(rsQry("last_build_days"), 100)
bms.Item("PKG_NAME") = rsQry("PKG_NAME")
bms.Item("ACTIVE") = rsQry("ACTIVE")
' Calculate some values
bms.Item("dState") = Classify_Run_Level(bms.Item("CURRENT_RUN_LEVEL"),_
IndefPause,_
bms.Item("PAUSE"), _
bms.Item("delta") ,_
bms.Item("CURRENT_PKG_ID_BEING_BUILT"),_
bms.Item("ACTIVE"))
bms.Item("dStateText") = Get_Run_Level(bms.Item("CURRENT_RUN_LEVEL"),_
IndefPause,_
bms.Item("PAUSE"),_
bms.Item("ACTIVE"))
' Kill package name on disabled daemons
If bms.Item("PAUSE") = 2 Then bms.Item("PKG_NAME") = Null
' Add to buildStatus
' This is a three level hash (Project,Release, Daemon)
Dim ProjRef, RelRef, DRef
ProjRef = bms.Item("PROJ_NAME")
RelRef = bms.Item("RTAG_NAME")
DRef = bms.Item("DISPLAY_NAME")
If Not buildStatus.Exists(ProjRef) Then
Set buildStatus(ProjRef) = CreateObject("Scripting.Dictionary")
Set buildStatus(ProjRef).Item("data") = CreateObject("Scripting.Dictionary")
'buildStatus(ProjRef).Item("PROJ_ID") = bms.Item("PROJ_ID")
'buildStatus(ProjRef).Item("PROJ_NAME") = bms.Item("PROJ_NAME")
End If
If Not buildStatus(ProjRef).Item("data").Exists(RelRef) Then
Set buildStatus(ProjRef).Item("data").Item(RelRef) = CreateObject("Scripting.Dictionary")
Set buildStatus(ProjRef).Item("data").Item(RelRef).Item("data") = CreateObject("Scripting.Dictionary")
'buildStatus(ProjRef).Item("data").Item(RelRef).Item("RTAG_NAME") = bms.Item("RTAG_NAME")
'buildStatus(ProjRef).Item("data").Item(RelRef).Item("RTAG_ID") = bms.Item("RTAG_ID")
End If
Set buildStatus(ProjRef).Item("data").Item(RelRef).Item("data").Item(DRef) = bms
rsQry.MoveNext
Loop
rsQry.Close()
Set rsQry = nothing
' Iterate over each deamon set and flag some of its characteristics
' This could be done inline, as the data is processed from the SQL source
Dim project,release,machine
Dim eProject,eRelease,eMachine
For Each project in buildStatus
Set eProject = buildStatus.Item(project)
For Each release in eProject.Item("data")
Set eRelease = eProject.Item("data").Item(release)
For Each machine in eRelease.Item("data")
Set eMachine = eRelease.Item("data").Item(machine)
Dim dState
dState = eMachine.Item("dState")
If dState = "active" Then
If bShowActiveBuilds Then eMachine.Item("bRow_displayed") = "ShowActive"
ElseIf dState = "idle" Then
If bShowIdleBuilds Then eMachine.Item("bRow_displayed") = "ShowIdle"
ElseIf dState = "paused" Then
If bShowPausedBuilds Then eMachine.Item("bRow_displayed") = "ShowPaused"
ElseIf dState = "disabled" Then
If bShowDisabledDaemons Then eMachine.Item("bRow_displayed") = "ShowDisabled"
ElseIf dState = "problem" Then
If bShowProblemDaemonSets Then eMachine.Item("bRow_displayed") = "ShowProblem"
If bShowProblemDaemonSets Then eRelease.Item("bDisplay_whole_set") = true
Else
eRelease.Item("bDisplay_whole_set") = true
eMachine.Item("bRow_displayed") = "ShowUnknownState"
End If
If bShowProblemDaemonSets AND eMachine.Item("BUILD_AGE") > 0 Then
If (eMachine.Item("last_build_days") > eMachine.Item("BUILD_AGE")) OR (eMachine.Item("last_build_days") > param_inactivity) Then
If dState = "active" OR dState = "idle" Then
eRelease.Item("bDisplay_whole_set") = true
eRelease.Item("bShowAge") = true
eMachine.Item("bRow_displayed") = "ShowInactiveWarning"
End If
End If
End If
If eMachine.Exists("bRow_displayed") Then
eRelease.Item("bDisplay_some") = true
eProject.Item("bDisplay_some") = true
End If
Next
Next
Next
' Debug the data structure
' Requires common/DictDump.vbs to be included to work
'Response.Write " Pretty Dictionary Display
"
'Response.Write DICToutput(buildStatus)
End Sub
'--------------------------------------------------------------------------------------------------------------------------
' Toggle row style between the two alternative styles
Sub ToggleStyleNow
If styleNow = styleAlt1 Then
styleNow = styleAlt2
Else
styleNow = styleAlt1
End If
End Sub
'--------------------------------------------------------------------------------------------------------------------------
' Convert run level into a meaningful filter state as a string
' Will be one of: active, idle, paused, disabled, problem, unknown
Function Classify_Run_Level( nLevel, indefinitePause, astate, nDelta, pkgId, bActive)
If bActive = "N" AND astate <> 2 Then
Classify_Run_Level = "problem"
ElseIf indefinitePause Then
Classify_Run_Level = "problem"
ElseIf astate = 1 Then ' if build daemon paused
Classify_Run_Level = "paused"
ElseIf astate = 2 Then ' if build daemon disabled
Classify_Run_Level = "disabled"
ElseIf Int(nDelta) > Max_Delta Then
Classify_Run_Level = "problem"
ElseIf (IsNull(pkgId)) OR (pkgId = "") Then
Classify_Run_Level = "idle"
ElseIf astate = 0 Then ' if build daemon enabled
If nLevel = 1 Then
Classify_Run_Level = "problem"
ElseIf nLevel = 2 Then
Classify_Run_Level = "paused"
ElseIf nLevel = 3 Then
Classify_Run_Level = "active"
ElseIf nLevel = 4 Then
Classify_Run_Level = "idle"
ElseIf nLevel = 5 Then
Classify_Run_Level = "idle"
ElseIf nLevel = 6 Then
Classify_Run_Level = "active"
Else
Classify_Run_Level = "unknown"
End If
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Use this function to determine the state of a specified project checkbox
Function Is_Project_Checked( nProjId )
Dim hiddenProjects_arr
Dim hiddenProjects
Dim str
hiddenProjects = Request("HideProj")
Is_Project_Checked = "checked"
hiddenProjects_arr = Split(hiddenProjects, ",")
For Each str in hiddenProjects_arr
If str = nProjId Then
Is_Project_Checked = ""
Exit For
End If
Next
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Use this function to set/clear the filter on/off radio button checked state
' Format of Filter Param : Filter=[problemBuilds}[,ActiveBuilds]
Function Display_Filtered(id)
Dim filter
Display_Filtered = ""
filter = Request("Filter")
If NOT IsNull(filter) AND filter <> "" Then
If InStr(filter, id) > 0 Then
Display_Filtered = "checked"
End If
Else
If id = "OFF" Then
Display_Filtered = "checked"
End If
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Use this function to set/clear a filter option check box with the given ID
' If no Filter is present, then assume defaults
Function Filter_Checked(id)
Dim filter
Filter_Checked = ""
filter = Request("Filter")
If IsNull(filter) OR filter = "" Then
filter="problemBuilds,activeBuilds" ' Defaults
End If
If InStr(filter, id) > 0 Then
Filter_Checked = "checked"
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Test to see if a particular filter option is on
Function Filter_Is_On(id)
If Filter_Checked(id) = "checked" Then
Filter_Is_On = True
Else
Filter_Is_On = False
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
%>
<%
'------------ RUN BEFORE PAGE RENDER ----------
' Default values for Auto Refresh checkbox and edit input box
param_refreshEnabled = False
param_refreshPeriod = "0"
' Read the Refresh parameter which is of the form Refresh=,ON|OFF
Dim param_refresh
param_refresh = Request("Refresh")
If param_refresh <> "" Then
Dim pr_arr
pr_arr = Split(param_refresh,",")
param_refreshPeriod = pr_arr(0)
' Range check and end-stop the refresh period if necessary
If NiceInt(param_refreshPeriod, 0) < Min_Refresh_Time Then
param_refreshPeriod = CStr(Min_Refresh_Time)
End If
' determine checkbox state
If UBound(pr_arr) >= 1 Then
If InStr(UCase(pr_arr(1)), "ON") > 0 Then
param_refreshEnabled = True
Else
param_refreshEnabled = False
End If
End If
End If
' Read the Inactivity Period
param_inactivity = NiceInt( Request("Inactivity"), Max_DeltaBuild)
If param_inactivity = 0 Then param_inactivity = Max_DeltaBuild
' Populate display controls
bShowProblemDaemonSets = Filter_Is_On("problemBuilds")
bShowActiveBuilds = Filter_Is_On("activeBuilds")
bShowDisabledDaemons = Filter_Is_On("disabledDaemons")
bShowIdleBuilds = Filter_Is_On("idleBuilds")
bShowPausedBuilds = Filter_Is_On("pausedBuilds")
bShowAutoProject = Filter_Is_On("autoProjects")
bProjectToggle = RequestBool("pAll", True)
'----------------------------------------------
%>
<%
'------------------------------------------------------------------------------
Sub SidePanelContent
%>
<%
End Sub
'------------------------------------------------------------------------------
Sub DisplayProjectHeader(bProjectHeaderDone, eMachine, strProject_checked)
If NOT bProjectHeaderDone Then%>
<%
End If
End Sub
'------------------------------------------------------------------------------
Sub ShowDaemonStatus
%>
BUILD DAEMON STATUS INFORMATION
title='Show/Hide all active releases' onclick=toggle_all_projects(this)>Project
Release
Release Mode
Daemon Mode
Daemon Host
Daemon State
Building Package
Last Change Delta (secs)
<%
Dim bProject_changed ' Signals a row change due to a different project
Dim strProject_checked ' Can be "" or "checked". Determines appearance of project enable checkbox
Dim bRelease_changed ' signals a row change due to a different release
Dim bReleaseHeaderDone ' indicates whether the release name has been rendered yet
Dim bProjectHeaderDone ' Project Header done
Dim bShowAge ' Display age warning
Dim bToggleStyle ' Data shown so toggle style
Dim bShowReleaseSep ' Show Release Seperator
Dim bShowProject ' Show this project
' Iterate over all projects, releases and machines
'
Dim project,release,machine
Dim eProject,eRelease,eMachine
For Each project in buildStatus
' Start of a new Project
Set eProject = buildStatus.Item(project)
bProjectHeaderDone = false
bProject_changed = true
bShowReleaseSep = False
bShowProject = True
If bShowAutoProject AND NOT eProject.Item("bDisplay_some") Then
bShowProject = False
End If
If bShowProject Then
For Each release in eProject.Item("data")
' Start of a new Release
Set eRelease = eProject.Item("data").Item(release)
bReleaseHeaderDone = False
bRelease_changed = true
bShowAge = eRelease("bShowAge")
If bToggleStyle Then Call ToggleStyleNow
bToggleStyle = false
For Each machine in eRelease.Item("data")
' Start of a new Machine
Set eMachine = eRelease.Item("data").Item(machine)
strProject_checked = Is_Project_Checked(eMachine("PROJ_ID"))
' Consider displaying the body of this machine entry
If strProject_checked = "checked" Then
If eRelease.Exists("bDisplay_whole_set") OR eMachine.Exists("bRow_displayed") Then
bToggleStyle = true
' Display Project and Release Header - Once, or a filler
If NOT bReleaseHeaderDone Then
bReleaseHeaderDone = True
' Display Project Header - ONCE. The
is open
Call DisplayProjectHeader(bProjectHeaderDone,eMachine, strProject_checked)
bProjectHeaderDone = TRUE
' Display Release seperator, if this is not the first release in the project
If bShowReleaseSep Then
%>
<%
End If
' Display the Release Header, with a marker to show aged releases
%>
<%
End If
' End of Display
bRelease_changed = false
bProject_changed = false
Next
Next
Call DisplayProjectHeader(bProjectHeaderDone,eMachine, strProject_checked)
End If
Next
%>
<%
End Sub
%>
Release Manager
<%If param_refreshEnabled AND param_RefreshPeriod <> 0 Then%>
>
<%End If%>
<% getBuildStatus() %>