Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
165 brianf 1
<%
2
'=====================================================
3
'                release_changed.asp
4
'=====================================================
5
%>
6
<%
7
' Release Change Mode
5097 dpurdie 8
Const enumRELEASE_CHANGE_MODE_PKG_ADDED = 1     'Package added to release
9
Const enumRELEASE_CHANGE_MODE_PKG_REMOVED = 2   'Package removed from release
10
Const enumRELEASE_CHANGE_MODE_PKG_RELEASED = 3  'Package released
165 brianf 11
 
12
 
13
Class ReleaseChanged
14
 
15
private m_pkg_name
16
private m_pkg_version
17
private m_pkg_id
18
private m_proj_id
19
 
5097 dpurdie 20
' Archive server name and credentials
21
'   Perhaps the credentials should come from the environment
22
private m_archive_server
23
private m_archive_user
24
private m_archive_password
25
 
26
Public last_resultCode
27
 
165 brianf 28
'-----------------------------------------------------------------------------------------------------------------
5097 dpurdie 29
'   Retrieve information about the target server
30
'
31
Private Sub Get_Server_Info()
32
    m_archive_user = "releasem"    
33
    m_archive_password = "releasem"
34
 
35
    Dim sqry: sqry = "SELECT * FROM BUILD_SERVICE_CONFIG WHERE SERVICE='ARCHIVE SERVER'"
36
    Dim rsTemp
37
    Set rsTemp = OraDatabase.DbCreateDynaset( sqry , cint(0) )
38
    m_archive_server = rsTemp("config")
39
    rsTemp.Close()
40
    Set rsTemp = Nothing
41
End Sub
42
 
43
'-----------------------------------------------------------------------------------------------------------------
165 brianf 44
' Retrieves package infomation for the specified package version
45
' This information is required for the make_release_changed script
46
Public Sub Get_Package_Info (artag_id,apv_id)
167 brianf 47
   Dim ssql, rsTemp
165 brianf 48
 
49
   ' Get package information   
50
   ssql = _
51
   " SELECT pv.pkg_id,pk.pkg_name,pv.pkg_version,rt.proj_id"&_
52
   " FROM package_versions pv, packages pk, release_tags rt"&_
53
   " WHERE" &_
54
   "     pv.pv_id = " & apv_id &_
55
   " AND pv.pkg_id = pk.pkg_id" &_
56
   " AND rt.rtag_id = " & artag_id
57
 
58
   Set rsTemp = OraDatabase.CreateDynaset( ssql, cint(0))
59
 
60
   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
61
      m_pkg_name = rsTemp("pkg_name")
62
      m_pkg_version = rsTemp("pkg_version")
63
      m_pkg_id = rsTemp("pkg_id")
64
      m_proj_id = rsTemp("proj_id")
65
   Else
66
      Err.Raise 8, "Error getting package information.  PV_ID, " & APV_ID & " not found in."
67
      Call RaiseMsg ( enum_MSG_ERROR, Err.description )
68
   End If
69
   rsTemp.Close
70
   Set rsTemp = Nothing
71
End Sub
72
 
73
'-----------------------------------------------------------------------------------------------------------------
74
' Run script job, ReleaseChanged, of script, on_Make_Official.wsf for the specified list of package versions.
75
' apv_id_list is a comma separated list of pv_id's
76
Sub Run_ReleaseChanged_List(artag_id,apv_id_list,amode_id)
77
  Dim pv_id, idArr
78
 
79
  idArr = Split(apv_id_list,",")
80
  For Each pv_id in idArr
167 brianf 81
    If IsReleased(artag_id,pv_id) Then
82
      Call Run_ReleaseChanged(artag_id,pv_id,amode_id,true)
83
    End If
165 brianf 84
  Next
85
End Sub
86
 
87
'-----------------------------------------------------------------------------------------------------------------
88
' Run script job, ReleaseChanged, of script, on_Make_Official.wsf for the specified package version.
89
' This job calls the unix script, make_release_changed
90
Sub Run_ReleaseChanged(artag_id,apv_id,amode_id,aget_info)
91
  Dim sysShell: Set sysShell = Server.CreateObject("WScript.Shell")
92
 
93
  if aget_info then
94
    Call Get_Package_Info (artag_id,apv_id)
95
  end if
96
 
4624 dpurdie 97
  ' Note: Call Run such that we wait for the result code
98
  '       If we don't do this then we may flood the server with requests and then it jams up.
99
  '
100
  Call sysSHell.Run("cmd.exe /c cscript.exe //B //NoLogo " & rootPath & SCRIPTS_FOLDER &"\on_Make_Official.wsf //job:ReleaseChanged" & " /pkg_name:""" & m_pkg_name & """" & " /pkg_version:""" & m_pkg_version & """" & " /rtag_id:" & artag_id & " /pkg_id:" & m_pkg_id & " /pv_id:" & apv_id & " /proj_id:" & m_proj_id & " /mode_id:" & amode_id, 0, True)
165 brianf 101
  Set sysShell = Nothing
102
End Sub
103
 
5097 dpurdie 104
'-----------------------------------------------------------------------------------------------------------------
105
' Uses ssh to communicate with the archive server and run the unix script, make_release_changed
106
'   Current Issue: Does not have nice error reporting mechanism
107
'
108
Sub Run_ReleaseChanged_New_and_not_yet_used(artag_id,apv_id,amode_id,aget_info)
109
    Dim sudoCmd, plinkPath, plinkCmd, wCmdLine
110
 
111
  last_resultCode = -1
112
  Call Get_Server_Info
113
  if aget_info then
114
    Call Get_Package_Info (artag_id,apv_id)
115
  end if
116
 
117
  '
118
  ' Build up the command line to the target script
119
  '
120
    sudoCmd = "~/sbin/make_release_changed" &_
121
         " archive=dpkg_archive" &_
122
         " pkg_name='\""" & m_pkg_name & "\""'" &_
123
         " pkg_version='\"""& m_pkg_version &"\""'" &_
124
         " rtag_id="& artag_id &_
125
         " pkg_id=" & m_pkg_id &_
126
         " pv_id="& apv_id &_
127
         " proj_id="& m_proj_id &_
128
         " mode_id="& amode_id
129
 
130
    ' Build up the ssh command
131
    plinkPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "Release_Manager\scripts\bin\plink.exe"
132
    plinkCmd =  "-ssh -batch " & m_archive_user & "@" & m_archive_server & " -pw " & m_archive_password & " ""sudo " & sudoCmd & ";"""
133
    wCmdLine =  plinkPath & " " & plinkCmd
134
 
135
    ' Note: Call Run such that we wait for the result code
136
    '       If we don't do this then we may flood the server with requests and then it jams up.
137
    '
138
    Dim objWSH
139
    Set objWSH = Server.CreateObject("WScript.Shell")
140
    last_resultCode = objWSH.Run (wCmdLine, 0, TRUE)
141
    Set objWSH = Nothing
142
 
143
End Sub
144
 
167 brianf 145
'-----------------------------------------------------------------------------------------------------------------------------
146
' Get the package are in which the package version resides (ie wip, planned, released)
147
Function Get_Pkg_Area (artagId, apvId)
148
   OraDatabase.Parameters.Add "RTAG_ID",        artagId,                 ORAPARM_INPUT, ORATYPE_NUMBER
149
   OraDatabase.Parameters.Add "PV_ID",          apvId,                   ORAPARM_INPUT, ORATYPE_NUMBER
150
   OraDatabase.Parameters.Add "PKG_AREA",       -1,                      ORAPARM_OUTPUT,ORATYPE_NUMBER
151
 
152
   OraDatabase.ExecuteSQL _
153
   "BEGIN "&_
154
   " :PKG_AREA := PK_ENVIRONMENT.GET_PACKAGE_AREA ( :PV_ID, :RTAG_ID ); "&_
155
   "END; "
156
   Get_Pkg_Area = OraDatabase.Parameters("PKG_AREA").Value
157
 
158
   OraDatabase.Parameters.Remove "RTAG_ID"
159
   OraDatabase.Parameters.Remove "PV_ID"
160
   OraDatabase.Parameters.Remove "PKG_AREA"
161
End Function
162
 
163
'-----------------------------------------------------------------------------------------------------------------------------
164
' Returns TRUE if the specified package is released
165
Function IsReleased (artagId, apvId)
166
  IsReleased = (CInt(Get_Pkg_Area(artagId, apvId)) = CInt(enum_PKG_AREA_RELEASED))
167
End Function
168
 
165 brianf 169
End Class
170
%>