Subversion Repositories DevTools

Rev

Rev 5097 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5097 Rev 5168
Line 14... Line 14...
14
 
14
 
15
private m_pkg_name
15
private m_pkg_name
16
private m_pkg_version
16
private m_pkg_version
17
private m_pkg_id
17
private m_pkg_id
18
private m_proj_id
18
private m_proj_id
19
 
-
 
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
19
Private m_data_collected
24
private m_archive_password
-
 
25
 
20
 
26
Public last_resultCode
21
Public last_resultCode
-
 
22
Public last_errorMsg
27
 
23
 
28
'-----------------------------------------------------------------------------------------------------------------
24
'-----------------------------------------------------------------------------------------------------------------
29
'   Retrieve information about the target server
25
' Init class variables
30
'
-
 
31
Private Sub Get_Server_Info()
26
Private Sub Class_Initialize()
32
    m_archive_user = "releasem"    
-
 
33
    m_archive_password = "releasem"
27
    m_data_collected = false
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()
28
    last_resultCode = -1
40
    Set rsTemp = Nothing
29
    last_errorMsg = ""
41
End Sub
30
End Sub
42
 
31
 
43
'-----------------------------------------------------------------------------------------------------------------
32
'-----------------------------------------------------------------------------------------------------------------
44
' Retrieves package infomation for the specified package version
33
' Retrieves package infomation for the specified package version
45
' This information is required for the make_release_changed script
34
' This information is required for the make_release_changed script
46
Public Sub Get_Package_Info (artag_id,apv_id)
35
Public Sub Get_Package_Info (artag_id,apv_id)
47
   Dim ssql, rsTemp
36
   Dim ssql, rsTemp
-
 
37
   On Error Resume Next
-
 
38
   m_data_collected = false
48
  
39
  
49
   ' Get package information   
40
   ' Get package information   
50
   ssql = _
41
   ssql = _
51
   " SELECT pv.pkg_id,pk.pkg_name,pv.pkg_version,rt.proj_id"&_
42
   " SELECT pv.pkg_id,pk.pkg_name,pv.pkg_version,rt.proj_id"&_
52
   " FROM package_versions pv, packages pk, release_tags rt"&_
43
   " FROM package_versions pv, packages pk, release_tags rt"&_
Line 54... Line 45...
54
   "     pv.pv_id = " & apv_id &_
45
   "     pv.pv_id = " & apv_id &_
55
   " AND pv.pkg_id = pk.pkg_id" &_
46
   " AND pv.pkg_id = pk.pkg_id" &_
56
   " AND rt.rtag_id = " & artag_id
47
   " AND rt.rtag_id = " & artag_id
57
 
48
 
58
   Set rsTemp = OraDatabase.CreateDynaset( ssql, cint(0))
49
   Set rsTemp = OraDatabase.CreateDynaset( ssql, cint(0))
-
 
50
   If Err.Number <> 0 Then
-
 
51
      last_resultCode = Err.Number
-
 
52
      last_errorMsg = Err.Description
-
 
53
      Exit Sub
-
 
54
   End If
59
 
55
 
60
   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
56
   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
61
      m_pkg_name = rsTemp("pkg_name")
57
      m_pkg_name = rsTemp("pkg_name")
62
      m_pkg_version = rsTemp("pkg_version")
58
      m_pkg_version = rsTemp("pkg_version")
63
      m_pkg_id = rsTemp("pkg_id")
59
      m_pkg_id = rsTemp("pkg_id")
64
      m_proj_id = rsTemp("proj_id")
60
      m_proj_id = rsTemp("proj_id")
-
 
61
      m_data_collected = true
65
   Else
62
   Else
-
 
63
      last_resultCode = 8
66
      Err.Raise 8, "Error getting package information.  PV_ID, " & APV_ID & " not found in."
64
      last_errorMsg = "Error getting package information.  PV_ID:" & APV_ID & " not found in. RTAG_ID:" & artag_id
-
 
65
      Err.Raise 8, "release_changed.asp", last_errorMsg
67
      Call RaiseMsg ( enum_MSG_ERROR, Err.description )
66
      'Call RaiseMsg ( enum_MSG_ERROR, Err.description )
68
   End If
67
   End If
69
   rsTemp.Close
68
   rsTemp.Close
70
   Set rsTemp = Nothing
69
   Set rsTemp = Nothing
71
End Sub
70
End Sub
72
 
71
 
Line 83... Line 82...
83
    End If
82
    End If
84
  Next
83
  Next
85
End Sub
84
End Sub
86
 
85
 
87
'-----------------------------------------------------------------------------------------------------------------
86
'-----------------------------------------------------------------------------------------------------------------
-
 
87
'   Run a job on the package server to indicate that a package has been
88
' Run script job, ReleaseChanged, of script, on_Make_Official.wsf for the specified package version.
88
'   released. The primary purpose of this is to trigger a BLAT package transfer
-
 
89
'
-
 
90
'   Perhaps it could be done via the RM Database
-
 
91
'   ie: Have a table of blat requests. Then we have no need to perform this slow
-
 
92
'       operation.
-
 
93
'
89
' This job calls the unix script, make_release_changed
94
'   Uses ssh to communicate with the archive server and run the unix script, make_release_changed
-
 
95
'
-
 
96
'   Args:   artag_id    - Release Identifier
-
 
97
'           apv_id      - Package Identifier
-
 
98
'           amode_id    - Mode of indication. One of enumRELEASE_CHANGE_MODE_*
-
 
99
'           aget_info   - Boolean: true if we need to populate the glabls with pkg info
-
 
100
'
90
Sub Run_ReleaseChanged(artag_id,apv_id,amode_id,aget_info)
101
Sub Run_ReleaseChanged(artag_id,apv_id,amode_id,aget_info)
91
  Dim sysShell: Set sysShell = Server.CreateObject("WScript.Shell")
102
    Dim pArchive_Path, sudoCmd, plinkPath, plinkCmd, wCmdLine
92
 
103
 
93
  if aget_info then
-
 
94
    Call Get_Package_Info (artag_id,apv_id)
-
 
95
  end if
-
 
96
 
-
 
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)
104
    pArchive_Path = "dpkg_archive"
101
  Set sysShell = Nothing
105
    last_resultCode = -1
102
End Sub
-
 
103
 
106
 
-
 
107
    if aget_info then
104
'-----------------------------------------------------------------------------------------------------------------
108
        Call Get_Package_Info (artag_id,apv_id)
-
 
109
        If Err.Number <> 0 Then
105
' Uses ssh to communicate with the archive server and run the unix script, make_release_changed
110
            Report_Event enumEVENT_ERROR, "make_release_changed", "", "Get_Package_Info:" & Err.Description
106
'   Current Issue: Does not have nice error reporting mechanism
111
            Exit Sub
-
 
112
        End If
-
 
113
    end if
107
'
114
 
108
Sub Run_ReleaseChanged_New_and_not_yet_used(artag_id,apv_id,amode_id,aget_info)
115
    ' Ensure that we have some data
109
    Dim sudoCmd, plinkPath, plinkCmd, wCmdLine
116
    If not m_data_collected Then
-
 
117
        Report_Event enumEVENT_ERROR, "make_release_changed", "", "Package Info not present"
-
 
118
        Exit Sub
-
 
119
    End If
110
 
120
 
111
  last_resultCode = -1
121
    ' Build up the command line to the target script
112
  Call Get_Server_Info
122
    ' Note: DoubleQuotes quotes will be escaped \"
113
  if aget_info then
-
 
114
    Call Get_Package_Info (artag_id,apv_id)
123
    '       Double space will be process as <ret> for error reporting
115
  end if
124
    ' Chr(92) == \
116
 
-
 
117
  '
-
 
118
  ' Build up the command line to the target script
125
    ' Chr(34) == "
119
  '
126
    ' Chr(39) = '
120
    sudoCmd = "~/sbin/make_release_changed" &_
127
    sudoCmd = "~/sbin/make_release_changed" &_
121
         " archive=dpkg_archive" &_
128
         "  archive=" & pArchive_Path &_
122
         " pkg_name='\""" & m_pkg_name & "\""'" &_
129
         "  pkg_name='" & Chr(34) & m_pkg_name & Chr(34) & "'" &_
123
         " pkg_version='\"""& m_pkg_version &"\""'" &_
130
         "  pkg_version='" & Chr(34) & m_pkg_version & Chr(34) & "'" &_
124
         " rtag_id="& artag_id &_
131
         "  rtag_id="& artag_id &_
125
         " pkg_id=" & m_pkg_id &_
132
         "  pkg_id=" & m_pkg_id &_
126
         " pv_id="& apv_id &_
133
         "  pv_id="& apv_id &_
127
         " proj_id="& m_proj_id &_
134
         "  proj_id="& m_proj_id &_
128
         " mode_id="& amode_id
135
         "  mode_id="& amode_id
-
 
136
 
-
 
137
    Dim pkgCredentails, uname, upasswd
-
 
138
    pkgCredentails = split(PKGARCHIVE_CREDENTIALS,":")
-
 
139
    uname = pkgCredentails(0)
-
 
140
    upasswd = pkgCredentails(1)
129
 
141
 
130
    ' Build up the ssh command
-
 
131
    plinkPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "Release_Manager\scripts\bin\plink.exe"
142
    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 & ";"""
143
    plinkCmd =  "-ssh -batch " & uname & "@" & archive_server & " -pw " & upasswd & " ""sudo " & Replace(sudoCmd,Chr(34),Chr(92)&Chr(34)) & ";"""
133
    wCmdLine =  plinkPath & " " & plinkCmd
144
    wCmdLine =  plinkPath & " " & plinkCmd
134
   
145
 
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
146
    Dim objWSH, rv
139
    Set objWSH = Server.CreateObject("WScript.Shell")
147
    Set objWSH = Server.CreateObject("WScript.Shell")
140
    last_resultCode = objWSH.Run (wCmdLine, 0, TRUE)
148
    rv = objWSH.Run (wCmdLine, 0, TRUE)
141
    Set objWSH = Nothing
149
    Set objWSH = Nothing
142
 
150
 
-
 
151
    '
-
 
152
    '   Report Errors
-
 
153
    If rv = 0 Then
-
 
154
        last_resultCode = 0
-
 
155
    Else
-
 
156
        last_resultCode = 1
-
 
157
        Report_Event enumEVENT_ERROR, "make_release_changed", Replace(sudoCmd,"  ", VBNewLine), "Remote command on pkg server reported:"  & rv
-
 
158
    End If
-
 
159
 
143
End Sub
160
End Sub
144
 
161
 
145
'-----------------------------------------------------------------------------------------------------------------------------
162
'-----------------------------------------------------------------------------------------------------------------------------
146
' Get the package are in which the package version resides (ie wip, planned, released)
163
' Get the package are in which the package version resides (ie wip, planned, released)
147
Function Get_Pkg_Area (artagId, apvId)
164
Function Get_Pkg_Area (artagId, apvId)