Subversion Repositories DevTools

Rev

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

<% @LANGUAGE = VBScript %>
<%
'=====================================================
'
'  Build Status and Plan Information
'
'=====================================================
%>
<%
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"-->
<!--#include file="_action_buttons.asp"-->
<!--#include file="common/daemon_instructions.asp"-->
<!--#include file="common/common_daemon.asp"-->
<% '------------ ACCESS CONTROL ------------------ %>
<!--#include file="_access_control_login_optional.asp"-->
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_action_project.asp"-->
<% '------------ Scripts -------------------------- %>
<%
'------------ Variable Definition -------------
Dim rsQry
Dim parRtagId
Dim query_string
Dim rcon_id
Dim canControl
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
parRtagId = Request("rtag_id")
objPMod.PersistInQryString("rtag_id")
canControl = canActionControlInProject("BuildControl")
'-------------------------------------------------
' 
Sub ShowDaemonStatus
%>
<div>
    <div class="panel">
        <div class=rounded_box_caption>
                <table align="center" class="full_table">
                   <tr>
                      <td nowrap class="form_ttl">DAEMON STATUS INFORMATION
                      </td>
                      <td  valign="bottom" class="body_rowg">
                        Last Build: <%=GetLastBuildAge(parRtagId)%> [<%=GetModifiedSeqNo(parRtagId)%>]
                      </td>
                      <td align="right" valign="bottom">
                        <a class="txt_linked" href="<%=scriptName%>?rtag_id=<%=parRtagId%>" title="Refresh Page">[Refresh]</a>
                      </td>
                   </tr>
                </table>
        </div>
        <div class='rounded_box'>
            <div  class=listPanel>
                <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
                <!--#include file="messages/_msg_inline.asp"-->
                <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
                <table width="100%" border="0" cellspacing="2" cellpadding="0">
                   <%
                   Dim bInactiveMachine : bInactiveMachine = false
                   %>
                   <td width="9%" valign="top"></td>
                   <thead>
                      <th>Daemon Host</th>
                      <th>Machine Type</th>
                      <th>Mode</th>
                      <th>Run Level</th>
                      <th>Current Package</th>
                      <th>Est Duration<%=Quick_Help("h_buildtime")%></th>
                      <th>Last Change<%=Quick_Help("h_lastchange")%></th>
                      <th>Control State</th>
                   </thead>
                   <%
                   ' Get Build Information for this Release
                   query_string = _
                        "SELECT rc.rcon_id, display_name, gbe_value, daemon_mode, NVL(ACTIVE, 'U') AS ACTIVE," &_
                        "       rl.pause, rl.current_run_level, rl.current_pkg_id_being_built, TRUNC (86400*(SYSDATE - rl.KEEP_ALIVE)) AS delta," &_
                        "       pk.pkg_name, rl.current_pv_id, pv.build_time, TRUNC (86400*(SYSDATE - rl.LAST_BUILD)) AS build_delta" &_
                        " FROM release_config rc," &_
                        "   gbe_machtype gm," &_
                        "   build_machine_config bm," &_
                        "   run_level rl," &_
                        "   packages pk," &_
                        "   package_versions pv" &_
                        " WHERE rc.rtag_id     = " & parRtagId &_
                        "  AND gm.gbe_id        = rc.gbe_id" &_
                        "  AND rl.rcon_id(+)    = rc.rcon_id" &_
                        "  AND rc.bmcon_id      =bm.bmcon_id(+)" &_
                        "  AND pk.pkg_id(+)     = rl.current_pkg_id_being_built" &_
                        "  AND rl.current_pv_id = pv.pv_id(+)" &_
                        " ORDER BY bm.display_name, rc.rcon_id"

                   Set rsQry = OraDatabase.DbCreateDynaset( query_string, ORADYN_DEFAULT )

                   Do While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
                      Dim pkgName
                      Dim pkgPvid
                      Dim pkgBuildTime
                      Dim currentRunLevel
                      Dim daemonState
                      Dim delta
                      Dim PkgBuildDelta
                      Dim pkgId
                      Dim bActive
                      Dim estDuration
                      Dim daemonMode 
                      Dim lastChange

                      rcon_id = rsQry("rcon_id")
                      ' = rsQry("display_name")
                      ' = rsQry("gbe_value")
                      daemonMode = rsQry("daemon_mode")
                      bActive = rsQry("ACTIVE")
                      daemonState = rsQry("pause")
                      currentRunLevel = rsQry("current_run_level")
                      pkgId = rsQry("current_pkg_id_being_built")
                      delta = rsQry("delta")
                      pkgName = rsQry("pkg_name")
                      pkgPvid = rsQry("current_pv_id")
                      pkgBuildTime = rsQry("build_time")
                      PkgBuildDelta = rsQry("build_delta")
                      lastChange = NULL
                      bInactiveMachine = FALSE
                      estDuration = NULL

                      If bActive = "N" Then bInactiveMachine = true
                      If IsNull(daemonState) Then daemonState = 0
                      If daemonState = "2" Then pkgId = Null
                      If IsNull(currentRunLevel) Then currentRunLevel = -1
                      If daemonMode = "M" AND not IsNull(pkgName) Then estDuration = pkgBuildTime & "[" & PkgBuildDelta & "]"
                      If bActive <> "U" Then lastChange = PrettyDelta(delta, daemonState,pkgName )

                      ' --- Now render HTML for this release configuration ---
                      %>
                      <tr class=border>
                         <td><%=rsQry("display_name")%></td>
                         <td><%=rsQry("gbe_value")%></td>
                         <td><%=Get_Daemon_Mode(daemonMode)%></td>
                         <td><%=Get_Run_Level(currentRunLevel, IndefPause, daemonState, bActive)%></td>
                         <td><%=Get_Package_Name(pkgName,parRtagId,pkgPvid, daemonState, bActive)%></td>
                         <td><%=estDuration%></td>
                         <td><%=lastChange%></td>
                         <td>
                            <%
                            If NOT IndefPause  Then
                                If bActive = "U" Then
                                ElseIf bActive = "N" Then
                                    Call Action_Buttons ( "Daemon Unavailable" )
                                ElseIf daemonState = 0 Then
                                    Call Action_Buttons_State ( "Daemon Pause", canControl )
                                ElseIf daemonState = 1 Then
                                    Call Action_Buttons_State ( "Daemon Resume", canControl )
                                ElseIf daemonState = 2 Then
                                    Call Action_Buttons_State ( "Daemon Start", canControl )
                                Else
                                    Call Action_Buttons_State ( "Daemon Resume", canControl )
                              End If
                            Else
                               %>Unavailable<%
                            End If
                            %>
                         </td>
                      </tr>
                      <%
                      rsQry.MoveNext
                   Loop
                   %>
                   <tr class=foot>
                     <td colspan=7>
                     <%If CheckConfigErrors(parRtagId) OR bInactiveMachine Then%><span class="err_alert">&nbsp;Daemon configuration errors detected</span>
                        <a class="txt_linked" href="release_config.asp?rtag_id=<%=parRtagId%>">
                            <img src="images/i_link.gif" hspace="2" border="0" align="absmiddle" title="Goto Configuration">
                        </a>
                     <%End If%>
                     </td>
                     <td>
                     <%
                       If (rsQry.RecordCount > 0) AND NOT IndefPause Then
                           Call Action_Buttons_State ( "Daemon Control All", objAccessControl.UserLogedIn AND canControl )
                       Else
                         %>&nbsp<%
                       End If
                     %>
                     </td>
                   </tr>
                   <%
                     rsQry.Close()
                     Set rsQry = nothing
                   %>
                </table>
            </div>
        </div>
    </div>
</div>
<%
End Sub
'-------------------------------------------------
' 
Sub ShowBuildPlan
Set rsQry = OraDatabase.DbCreateDynaset( "SELECT TRUNC (86400*(SYSDATE - rl.LAST_BUILD)) as delta, rl.LAST_BUILD as BuildStart, rl.current_pv_id, SYSDATE" &_
                                        " FROM release_config rc,  run_level rl " &_
                                        " WHERE rc.rtag_id   = " & parRtagId &_
                                        " AND rc.daemon_mode = 'M' AND rl.rcon_id(+) = rc.rcon_id", ORADYN_DEFAULT )
Dim BuildStart
Dim BuildDelta
Dim BuildPvId
Dim BuildNow
Dim bFirstPlan : bFirstPlan = TRUE
If (rsQry.RecordCount > 0) Then
    BuildStart = rsQry("BuildStart")
    BuildDelta = rsQry("delta")
    BuildPvId  = rsQry("current_pv_id")
    BuildNow  = rsQry("SYSDATE")
End If
rsQry.Close()
Set rsQry = nothing
%>
<!-- Planned Builds Display -->
<div>
<div class=panel>
        <div class=rounded_box_caption>
                <table align="center" class="full_table">
                   <tr>
                      <td nowrap class="form_ttl">DAEMON BUILD PLAN<%=Quick_Help("h_buildplan")%></td>
                      <td class="body_rowg" align="right" valign="bottom">Now: <%=DisplayShortDateTimeSecs(BuildNow)%> AWST</td>
                   </tr>
                </table>
        </div>
        <div class="rounded_box">
            <div class='listPanel'>
                <table class='embedded_table'>
                   <thead>
                      <th>Package</th>
                      <th>Version</th>
                      <th>Duration<%=Quick_Help("h_buildDuration")%></th>
                      <th>Build Completion<%=Quick_Help("h_buildEnd")%></th>
                   </thead>
                   <%
                   Dim PkgVersion, buildDuration, durationDisplay, durationText, completionText
                   Set rsQry = OraDatabase.DbCreateDynaset( "SELECT p.PKG_NAME," &_
                                                            "  pv.PKG_VERSION, pv.BUILD_TIME," &_
                                                            "  bp.PV_ID" &_
                                                            " FROM build_plan bp," &_
                                                            "  packages p," &_
                                                            "  package_versions pv" &_
                                                            " WHERE bp.PV_ID = pv.pv_id" &_
                                                            " AND RTAG_ID = " & parRtagId &_
                                                            " AND pv.PKG_ID  = p.pkg_id" &_
                                                            " ORDER BY build_order" , ORADYN_DEFAULT )
                   If rsQry.RecordCount = 0 Then
                       %>
                       <tr>
                        <td nowrap colspan="4" align="center" class="body_txt">No packages to be built </td>
                       </tr>
                       <%
                   End If
                   While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
                       completionText = ""
                       buildDuration = rsQry("BUILD_TIME")
                       durationDisplay = buildDuration

                       If rsQry("PV_ID") = 0 Then
                            bFirstPlan = FALSE
                       %>
                           <tr class=border>
                            <td colspan4>New Plan<%=Quick_Help("h_newPlan")%></td>
                          </tr>
                       <%
                       Else
                           ' If the current package build it taking longer than expected , then bump the build times
                           ' and allow another 30 seconds.
                           If BuildPvId = rsQry("PV_ID") AND bFirstPlan Then
                               completionText = "&nbsp;<"
                               durationDisplay = durationDisplay & " ["& BuildDelta &"]"
                               If CLng(BuildDelta) > CLng(buildDuration) Then
                                    buildDuration = BuildDelta + 30
                                    completionText = "&nbsp;+"
                               End If
                           End If

                           ' If the duration is not known - guess at 300 sconds
                           durationText = ""
                           If (ISNULL(buildDuration)  OR buildDuration = 0) Then
                                buildDuration = 300
                                durationText = "&nbsp;~"
                          End If

                          BuildStart = DateAdd("s", buildDuration, BuildStart)
                          %>
                          <tr class=border>
                             <td><%=Get_Package_Name(rsQry("PKG_NAME"), parRtagId, rsQry("PV_ID"), 0, "Y")%></td>
                             <td><%=rsQry("PKG_VERSION")%></td>
                             <td><%=durationDisplay%></td>
                             <td><%=DisplayShortDateTimeSecs(BuildStart) & durationText  & completionText%></td>
                          </tr>
                          <%
                          ' Allow for 20 seconds of planning between builds
                          BuildStart = DateAdd("s", 20, BuildStart)
                       End If
                      rsQry.MoveNext()
                   Wend
                   rsQry.Close()
                   Set rsQry = nothing
                   %>
                </table>
            </div>
        </div>
    </div>
</div>
<%
End Sub
'-------------------------------------------------
Sub PlanControlPane
    Dim planDropChecked : planDropChecked = ""
    Dim planValue : planValue = 0
    Dim planOff : planOff = ""
    Dim planCautious : planCautious = ""
    Dim planAggressive : planAggressive = ""
' Get the planning control information
    query_string = _
        "SELECT PLAN_THRESHOLD, PLAN_DROP" &_
        " FROM release_tags rt" &_
        " WHERE rt.rtag_id  = " & parRtagId

    Set rsQry = OraDatabase.DbCreateDynaset( query_string, ORADYN_DEFAULT )

    If (NOT rsQry.BOF) AND (NOT rsQry.EOF) Then

        If rsQry("PLAN_DROP") <> "N" Then
            planDropChecked = " Checked"
        End If

        planValue = CInt(rsQry("PLAN_THRESHOLD"))
        Select Case planValue
        Case 0 : planOff = "Checked"
        Case 20 : planCautious = "Checked"
        Case 100  : planAggressive = "Checked"
        Case Else : planCautious = "Checked"
        End Select

    End If
    rsQry.Close()
    Set rsQry = nothing
%>
<fieldset class="body_rowg fset" <%=IIF(canControl, "", "disabled")%>>
    <legend class="body_scol">Plan Control</legend>
        <span id=planMode>
            <input     type="radio" name="plan"  <%=planOff%> value="0">Off
            <br><input type="radio" name="plan"  <%=planCautious%> value="20">Cautious
            <br><input type="radio" name="plan"  <%=planAggressive%> value="100">Aggressive
        </span>
        <hr>
        <input id=planDrop type=checkbox <%=planDropChecked%>>Drop Plan
</fieldset>
<%
End Sub
'-------------------------------------------------
Sub InsertJavaScript %>
<script language="JavaScript" type="text/JavaScript">
    formTips.tips.h_buildplan       = stdTip(300, 'Build Plan', 'The build plan is a guess as to the order in which packages will be built.' +
                                                              '<p>It will be recalculated before each build.' + 
                                                              '<p>The plan includes test builds, new builds and resultant ripples.' 
                                                              );
    formTips.tips.h_buildDuration    = stdTip(300, 'Planned Duration', 'The build duration (seconds) of the last build of this package - if known.' +
                                                              '<p>This is used as a guess as to the duration of the planned build.' 
                                                              );
    formTips.tips.h_buildEnd         = stdTip(300, 'Planned Completion', 'An educated guess as to the build completion time of the package.' +
                                                              '<p>It is based on the start time of the current build and the durations of each preceeding builds.' + 
                                                              '<p>If the duration of a build is not known then a time of 300 seconds will be assumed.' +
                                                              ' It also assumes 20 seconds to plan the next build.'
                                                              );
    formTips.tips.h_lastchange       = stdTip(300, 'Last Change', 'This is an indication of the time since the daemon interogated the database.' +
                                                              '<p>Short times will be shown as seconds. Longer times will be shown as a time within ' + 
                                                              'the last 24 hours. Longer times will be shown as a date.' 
                                                              );
    formTips.tips.h_newPlan       = stdTip(300, 'New Plan', 'New package versions added to the release have would extend the existing'  +
                                                          ' ripple by more than 20%.<p>The changes will not be included in the current ripple, but will' +
                                                          ' be processed once the ripple is complete.'
                                                              );
<%If canControl Then%>
    var planTime = 0;
    var planDrop = 0;
    $(document).ready(function() {
        
        //  Update the table when the Plan Control is modified
        $('#planMode').change(function(event){
            planTime = $("input[name='plan']:checked").val();
            updatePlanTime();
        });

        $('#planDrop').change(function(event){
            planDrop = $('#planDrop').is(":checked");
            updatePlanDrop();
        });
    });

    function updatePlanTime()
    {
        $.ajax({
            type : 'POST',
            url : '_json_plan_control.asp',
            data : {Opr : 'setThreshold', threshold : planTime,  rtag_id : <%=parRtagId%> },
            dataType : 'json',
        }).done(function (data){
            if(data.result) {
                console.log("notDone:", data);
                vixAlert("The action failed due to some internal error<br>Error: " + data.emsgSummary + "<br>Details:" + data.emsgDetails);

            }
        }).fail(function (data,textStatus,errorThrown){
            vixAlert("The action failed due to some internal error<br>Error: " + errorThrown);
        })
    }

    function updatePlanDrop()
    {
        $.ajax({
            type : 'POST',
            url : '_json_plan_control.asp',
            data : {Opr : 'setDrop', mode : planDrop,  rtag_id : <%=parRtagId%> },
            dataType : 'json',
        }).done(function (data){
            if(data.result) {
                console.log("notDone:", data);
                vixAlert("The action failed due to some internal error<br>Error: " + data.emsgSummary + "<br>Details:" + data.emsgDetails);

            }
        }).fail(function (data,textStatus,errorThrown){
            vixAlert("The action failed due to some internal error<br>Error: " + errorThrown);
        });
    }
<%End If%>
</script>
<%End Sub
'----------------------------------------------
%>
<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">
      <link rel="stylesheet" href="images/navigation.css?ver=<%=VixVerNum%>" type="text/css">
      <script language="JavaScript" src="images/common.js?ver=<%=VixVerNum%>"></script>
      <!--#include file="_jquery_includes.asp"-->
      <!-- TIPS -->
      <script type="text/javascript" src="scripts/json2.js?ver=<%=VixVerNum%>"></script>
      <script language="JavaScript" src="images/tipster.js?ver=<%=VixVerNum%>"></script>
      <script language="JavaScript" src="images/_help_tips.js?ver=<%=VixVerNum%>"></script>
      <!-- DROPDOWN MENUS -->
      <!--#include file="_menu_def.asp"-->
      <script language="JavaScript1.2" src="images/popup_menu.js?ver=<%=VixVerNum%>"></script>
      <%Call InsertJavaScript %>
   </head>
   <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
      <!-- HEADER -->
      <!--#include file="_header.asp"-->
      <!-- BODY ---->
      <table class="full_table">
         <tr>
            <td width="146px" class="bg_panel" valign="top">
                <%Call BuildMenuPane%>
                <%Call PlanControlPane%>
            </td>
            <td width="100%" rowspan="2" align="center" valign="top" bgcolor="#EEEFEF">
                <%Call ShowDaemonStatus%>
                <%Call ShowBuildPlan%>
            </td>
         </tr>
         <tr>
            <td class="bg_panel_btm" height="350">
                <img src="images/img_gears.png" vspace="20" hspace="30"></td>
         </tr>
      </table>
      <!-- FOOTER -->
      <!--#include file="_footer.asp"-->
   </body>
</html>