Rev 5506 | Rev 6698 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%'=====================================================' release_changed.asp'=====================================================%><%' Release Change ModeConst enumRELEASE_CHANGE_MODE_PKG_ADDED = 1 'Package added to releaseConst enumRELEASE_CHANGE_MODE_PKG_REMOVED = 2 'Package removed from releaseConst enumRELEASE_CHANGE_MODE_PKG_RELEASED = 3 'Package releasedClass ReleaseChangedprivate m_pkg_nameprivate m_pkg_versionprivate m_pkg_idprivate m_proj_idPrivate m_dlockedPrivate m_data_collectedPublic last_resultCodePublic last_errorMsg'-----------------------------------------------------------------------------------------------------------------' Init class variablesPrivate Sub Class_Initialize()m_data_collected = falselast_resultCode = -1last_errorMsg = ""End Sub'-----------------------------------------------------------------------------------------------------------------' Retrieves package infomation for the specified package version' This information is required for the make_release_changed scriptPublic Sub Get_Package_Info (artag_id,apv_id)Dim ssql, rsTempOn Error Resume Nextm_data_collected = false' Get package informationssql = _" SELECT pv.pkg_id,pk.pkg_name,pv.pkg_version,rt.proj_id,pv.dlocked"&_" FROM package_versions pv, packages pk, release_tags rt"&_" WHERE" &_" pv.pv_id = " & apv_id &_" AND pv.pkg_id = pk.pkg_id" &_" AND rt.rtag_id = " & artag_idSet rsTemp = OraDatabase.CreateDynaset( ssql, cint(0))If Err.Number <> 0 Thenlast_resultCode = Err.Numberlast_errorMsg = Err.Description & ":" & ssqlExit SubEnd IfIf ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Thenm_pkg_name = rsTemp("pkg_name")m_pkg_version = rsTemp("pkg_version")m_pkg_id = rsTemp("pkg_id")m_proj_id = rsTemp("proj_id")m_dlocked = rsTemp("dlocked")m_data_collected = trueElselast_resultCode = 8last_errorMsg = "Error getting package information. PV_ID:" & APV_ID & " not found in. RTAG_ID:" & artag_idErr.Raise 8, "release_changed.asp", last_errorMsg'Call RaiseMsg ( enum_MSG_ERROR, Err.description )End IfrsTemp.CloseSet rsTemp = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------' Perform the Run_ReleaseChanged function on a list of packages'' Args: artag_id - Release Identifier' apv_id_list - Package Identifiers. A comma separated list of pv_id's' amode_id - Mode of indication. One of enumRELEASE_CHANGE_MODE_*'Sub Run_ReleaseChanged_List(artag_id,apv_id_list,amode_id)Dim pv_id, idArridArr = Split(apv_id_list,",")For Each pv_id in idArrIf IsReleased(artag_id,pv_id) ThenCall Run_ReleaseChanged(artag_id,pv_id,amode_id,true)End IfNextEnd Sub'-----------------------------------------------------------------------------------------------------------------' Run a job on the package server to indicate that a package has been' released. The primary purpose of this is to trigger a BLAT package transfer'' Perhaps it could be done via the RM Database' ie: Have a table of blat requests. Then we have no need to perform this slow' operation.'' Uses ssh to communicate with the archive server and run the unix script, make_release_changed'' Args: artag_id - Release Identifier' apv_id - Package Identifier' amode_id - Mode of indication. One of enumRELEASE_CHANGE_MODE_*' aget_info - Boolean: true if we need to populate the global variables with pkg info'Sub Run_ReleaseChanged(artag_id,apv_id,amode_id,aget_info)Dim pArchive_Path, sudoCmd, rvpArchive_Path = "dpkg_archive"last_resultCode = -1if aget_info thenCall Get_Package_Info (artag_id,apv_id)If Err.Number <> 0 ThenReport_Event enumEVENT_ERROR, "make_release_changed", last_errorMsg, "Get_Package_Info:" & Err.DescriptionExit SubEnd Ifend if' Ensure that we have some dataIf not m_data_collected ThenReport_Event enumEVENT_ERROR, "make_release_changed", "", "Package Info not present"Exit SubEnd If' Don't run the release chnaged notification if the package has not been released' Trying to prevent WIP packages being sent via blatIf m_dlocked <> "Y" ThenExit SubEnd If' Build up the command line to the target script' Note: DoubleQuotes quotes will be escaped \"' Double space will be process as <ret> for error reporting' Chr(92) == \' Chr(34) == "' Chr(39) = 'sudoCmd = "~/sbin/make_release_changed" &_" archive=" & pArchive_Path &_" pkg_name='" & Chr(34) & m_pkg_name & Chr(34) & "'" &_" pkg_version='" & Chr(34) & m_pkg_version & Chr(34) & "'" &_" rtag_id="& artag_id &_" pkg_id=" & m_pkg_id &_" pv_id="& apv_id &_" proj_id="& m_proj_id &_" mode_id="& amode_id' Execute the commandrv = ExecuteRemoteCommand(sudoCmd)'' Report Errors' 105 - Package not in archive. Not a real issueIf rv = 0 OR rv = 105 Thenlast_resultCode = 0Elselast_resultCode = 1Report_Event enumEVENT_ERROR, "make_release_changed", Replace(sudoCmd," ", VBNewLine), "Remote command on pkg server reported:" & rvEnd IfEnd Sub'-----------------------------------------------------------------------------------------------------------------------------' Get the package are in which the package version resides (ie wip, planned, released)Function Get_Pkg_Area (artagId, apvId)OraDatabase.Parameters.Add "RTAG_ID", artagId, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "PV_ID", apvId, ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "PKG_AREA", -1, ORAPARM_OUTPUT,ORATYPE_NUMBEROraDatabase.ExecuteSQL _"BEGIN "&_" :PKG_AREA := PK_ENVIRONMENT.GET_PACKAGE_AREA ( :PV_ID, :RTAG_ID ); "&_"END; "Get_Pkg_Area = OraDatabase.Parameters("PKG_AREA").ValueOraDatabase.Parameters.Remove "RTAG_ID"OraDatabase.Parameters.Remove "PV_ID"OraDatabase.Parameters.Remove "PKG_AREA"End Function'-----------------------------------------------------------------------------------------------------------------------------' Returns TRUE if the specified package is releasedFunction IsReleased (artagId, apvId)IsReleased = (CInt(Get_Pkg_Area(artagId, apvId)) = CInt(enum_PKG_AREA_RELEASED))End Function'-----------------------------------------------------------------------------------------------------------------' Test Access to the package server' Uses a dedicated script on the target'Sub TestAccess(sMsg)Dim sudoCmd, rvlast_resultCode = -1' Execute the commandrv = ExecuteRemoteCommand("~/sbin/make_test_access " & sMsg)'' Report Errors. Expecting a '55''If rv = 55 Thenlast_resultCode = 0Elselast_resultCode = 1last_errorMsg = "Result Code: " & rvEnd IfEnd Sub'-----------------------------------------------------------------------------------------------------------------' Make the Package Writable' Primary Purpose is to make a 'Patch' wriable in dpkg_archive' Uses a dedicated script on the target'Sub MakeWritable(artag_id, apv_id)Dim pArchive_Path, sudoCmd, rvpArchive_Path = "dpkg_archive"last_resultCode = -1Call Get_Package_Info (artag_id,apv_id)If Err.Number <> 0 ThenReport_Event enumEVENT_ERROR, "make_writable", last_errorMsg, "Get_Package_Info:" & Err.DescriptionExit SubEnd If' Ensure that we have some dataIf not m_data_collected ThenReport_Event enumEVENT_ERROR, "make_writable", "", "Package Info not present"Exit SubEnd If' Build up the command line to the target script' Note: DoubleQuotes quotes will be escaped \"' Double space will be process as <ret> for error reporting' Chr(92) == \' Chr(34) == "' Chr(39) = 'sudoCmd = "~/sbin/make_writable" &_" " & pArchive_Path &_" '" & m_pkg_name & "'" &_" '" & m_pkg_version & "'"' Execute the commandrv = ExecuteRemoteCommand(sudoCmd)'' Report ErrorsIf rv = 0 Thenlast_resultCode = 0Elselast_resultCode = 1Report_Event enumEVENT_ERROR, "make_writable", Replace(sudoCmd," ", VBNewLine), "Remote command on pkg server reported:" & rvEnd IfEnd Sub'-----------------------------------------------------------------------------------------------------------------' Make the Package UnWritable' Primary Purpose is to make a 'Patch' wriable in dpkg_archive' Uses a dedicated script on the target'Sub MakeReadOnly(artag_id, apv_id)Dim pArchive_Path, sudoCmd, rvpArchive_Path = "dpkg_archive"last_resultCode = -1Call Get_Package_Info (artag_id,apv_id)If Err.Number <> 0 ThenReport_Event enumEVENT_ERROR, "make_readonly", last_errorMsg, "Get_Package_Info:" & Err.DescriptionExit SubEnd If' Ensure that we have some dataIf not m_data_collected ThenReport_Event enumEVENT_ERROR, "make_readonly", "", "Package Info not present"Exit SubEnd If' Build up the command line to the target script' Note: DoubleQuotes quotes will be escaped \"' Double space will be process as <ret> for error reporting' Chr(92) == \' Chr(34) == "' Chr(39) = 'sudoCmd = "~/sbin/make_readonly" &_" " & pArchive_Path &_" '" & m_pkg_name & "'" &_" '" & m_pkg_version & "'"' Execute the commandrv = ExecuteRemoteCommand(sudoCmd)'' Report ErrorsIf rv = 0 Thenlast_resultCode = 0Elselast_resultCode = 1Report_Event enumEVENT_ERROR, "make_readonly", Replace(sudoCmd," ", VBNewLine), "Remote command on pkg server reported:" & rvEnd IfEnd Sub'-----------------------------------------------------------------------------------------------------------------' Run a remote command in an ssh session'' Performs command line processing' Note: DoubleQuotes quotes will be escaped \"' Chr(92) == \' Chr(34) == "' Chr(39) = ''Private Function ExecuteRemoteCommand(sudoCmd)Dim plinkPath, plinkCmd, wCmdLineDim pkgCredentails, uname, upasswdpkgCredentails = split(Application("PKGARCHIVE_CREDENTIALS"),":")uname = pkgCredentails(0)upasswd = pkgCredentails(1)plinkPath = Server.MapPath("scripts\bin\plink.exe")plinkCmd = "-ssh -batch " & uname & "@" & archive_server & " -pw " & upasswd & " ""sudo " & Replace(sudoCmd,Chr(34),Chr(92)&Chr(34)) & ";"""wCmdLine = plinkPath & " " & plinkCmdDim objWSH, rvSet objWSH = Server.CreateObject("WScript.Shell")ExecuteRemoteCommand = objWSH.Run (wCmdLine, 0, TRUE)Set objWSH = NothingEnd FunctionEnd Class%>