| 119 |
ghuddy |
1 |
'=====================================================
|
|
|
2 |
' Name: pkg_archive
|
|
|
3 |
' Description: This library contains methods required
|
|
|
4 |
' for dpkg_archive and deploy_archive
|
|
|
5 |
' manipulation.
|
|
|
6 |
'=====================================================
|
|
|
7 |
|
|
|
8 |
Option Explicit
|
|
|
9 |
|
|
|
10 |
Class PkgArchive
|
|
|
11 |
'================ Properties Declaration =============
|
|
|
12 |
Private pRemote_Host
|
|
|
13 |
Private pArchive_Path
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
'==================== Properties =====================
|
|
|
17 |
Public Property Let Remote_Host( SSrhost )
|
|
|
18 |
pRemote_Host = SSrhost
|
|
|
19 |
End Property
|
|
|
20 |
|
|
|
21 |
Public Property Let Archive_Path( SSarch_path )
|
|
|
22 |
pArchive_Path = UnixPath(SSarch_path)
|
|
|
23 |
End Property
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
'====================== Methods ======================
|
|
|
27 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
28 |
Private Sub Get_Archive_Telnet_Login_Details ( outUser, outPassword )
|
|
|
29 |
outUser = "releasem"
|
|
|
30 |
outPassword = "releasem"
|
|
|
31 |
End Sub
|
|
|
32 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
33 |
Private Sub Get_Archive_Map_Drive_Login_Details ( outUser, outPassword )
|
| 187 |
brianf |
34 |
outUser = "vix\releasem"
|
| 119 |
ghuddy |
35 |
outPassword = "releasem"
|
|
|
36 |
End Sub
|
|
|
37 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
38 |
Function UnixPath( SSpath )
|
|
|
39 |
If SSpath <> "" Then UnixPath = Replace( SSpath, "\", "/" )
|
|
|
40 |
End Function
|
|
|
41 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
42 |
Sub Ensure_Read_Write ( SSpkg_name, SSpkg_version )
|
|
|
43 |
Dim outMachine, outUser, outPassword
|
|
|
44 |
Dim login_details, command, sysShell, oExec, outStrOut, outStrErr
|
|
|
45 |
WScript.Echo "Allowing Read and Write on folder "& SSpkg_version
|
|
|
46 |
|
|
|
47 |
Call Get_Archive_Telnet_Login_Details ( outUser, outPassword )
|
|
|
48 |
|
|
|
49 |
' Set all folders to +RWX and all files to +RW
|
|
|
50 |
' --- Commands to run ---
|
|
|
51 |
'command = _
|
|
|
52 |
'"cd "& pArchive_Path &" && "&_
|
|
|
53 |
'"chmod a+rwx "& SSpkg_name &"; "&_
|
|
|
54 |
'"cd "& SSpkg_name &" && "&_
|
|
|
55 |
'"find '"& SSpkg_version &"' -type d -exec chmod a+rwx {} \; ; "&_
|
|
|
56 |
'"chmod -R a+rw "& SSpkg_version &"; "
|
|
|
57 |
|
|
|
58 |
command = _
|
|
|
59 |
"sudo ~/sbin/make_writable "& pArchive_Path &" '"& SSpkg_name &"' '"& SSpkg_version &"';"
|
|
|
60 |
|
|
|
61 |
WScript.Echo command
|
|
|
62 |
|
|
|
63 |
' --- SSH client with login details ---
|
|
|
64 |
'login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPassword
|
|
|
65 |
login_details = AppPath & WINRSH_EXE &" -q -h "& pRemote_Host &" -l "& outUser &" -p "& outPassword
|
|
|
66 |
|
|
|
67 |
'WScript.Echo login_details &" """& command &""""
|
|
|
68 |
|
|
|
69 |
Set sysShell = WScript.CreateObject("WScript.Shell")
|
|
|
70 |
sysShell.Run "cmd.exe /c "& login_details &" """& command &"""", 0, True
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
'Set oExec = sysShell.Exec( login_details &" "& command )
|
|
|
75 |
'Set oExec = sysShell.Exec( login_details &" """& command &"""" )
|
|
|
76 |
|
|
|
77 |
'outStrOut = oExec.StdOut.ReadAll
|
|
|
78 |
'outStrErr = oExec.StdErr.ReadAll
|
|
|
79 |
|
|
|
80 |
'If outStrErr <> "" Then
|
|
|
81 |
' Call Raise_Event ( enumEVENT_ERROR, "[sub:Ensure_Read_Write]", _
|
|
|
82 |
' "user: "& outUser & VBNewLine &_
|
|
|
83 |
' "command: "& command , _
|
|
|
84 |
' outStrErr, enum_RELEASE_NOTES_FAILED )
|
|
|
85 |
'End If
|
|
|
86 |
'Set oExec = Nothing
|
|
|
87 |
Set sysShell = Nothing
|
|
|
88 |
|
|
|
89 |
End Sub
|
|
|
90 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
91 |
Sub All_Read_Only ( SSpkg_name, SSpkg_version )
|
|
|
92 |
Dim outMachine, outUser, outPassword
|
|
|
93 |
Dim login_details, command, sysShell, oExec, outStrOut, outStrErr
|
|
|
94 |
|
|
|
95 |
Call Get_Archive_Telnet_Login_Details ( outUser, outPassword )
|
|
|
96 |
|
|
|
97 |
' Set all folders from version folder, to -W and all files to -W
|
|
|
98 |
' --- Commands to run ---
|
|
|
99 |
'command = _
|
|
|
100 |
'"cd "& pArchive_Path &"/"& SSpkg_name &" && "&_
|
|
|
101 |
'"find '"& SSpkg_version &"' -type d -exec chmod a-w {} \; ; "&_
|
|
|
102 |
'"chmod -R a-w "& SSpkg_version &"; "&_
|
|
|
103 |
'"chown -R root:other "& SSpkg_version &"; "
|
|
|
104 |
|
|
|
105 |
command = _
|
|
|
106 |
"sudo ~/sbin/make_readonly "& pArchive_Path &" '"& SSpkg_name &"' '"& SSpkg_version &"';"
|
|
|
107 |
|
|
|
108 |
WScript.Echo command
|
|
|
109 |
|
|
|
110 |
' --- SSH client with login details ---
|
|
|
111 |
'login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPassword
|
|
|
112 |
login_details = AppPath & WINRSH_EXE &" -q -h "& pRemote_Host &" -l "& outUser &" -p "& outPassword
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
Set sysShell = WScript.CreateObject("WScript.Shell")
|
|
|
117 |
sysShell.Run "cmd.exe /c "& login_details &" """& command &"""", 0, True
|
|
|
118 |
|
|
|
119 |
'Set oExec = sysShell.Exec( login_details &" "& command )
|
|
|
120 |
|
|
|
121 |
'outStrOut = oExec.StdOut.ReadAll
|
|
|
122 |
'outStrErr = oExec.StdErr.ReadAll
|
|
|
123 |
|
|
|
124 |
'If outStrErr <> "" Then
|
|
|
125 |
' Call Raise_Event ( enumEVENT_ERROR, "[sub:All_Read_Only]", _
|
|
|
126 |
' "user: "& outUser & VBNewLine &_
|
|
|
127 |
' "command: "& command , _
|
|
|
128 |
' outStrErr, enum_RELEASE_NOTES_FAILED )
|
|
|
129 |
'End If
|
|
|
130 |
|
|
|
131 |
'Set oExec = Nothing
|
|
|
132 |
Set sysShell = Nothing
|
|
|
133 |
|
|
|
134 |
End Sub
|
|
|
135 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
136 |
Sub Create_Doc_Folder ( SSpkg_name, SSpkg_version, docFolder )
|
|
|
137 |
Dim outMachine, outDpkg_root, outUser, outPassword
|
|
|
138 |
Dim login_details, command, sysShell, oExec, outStrOut, outStrErr
|
|
|
139 |
|
|
|
140 |
Call Get_Archive_Telnet_Login_Details ( outUser, outPassword )
|
|
|
141 |
|
|
|
142 |
' --- Commands to run ---
|
|
|
143 |
' Creates doc folder if required with rwx permissions for all
|
|
|
144 |
command = _
|
|
|
145 |
"cd "& pArchive_Path &"/"& SSpkg_name &"/"& SSpkg_version &" && "&_
|
|
|
146 |
"mkdir -p -m a+rwx "& docFolder &"; "
|
|
|
147 |
|
|
|
148 |
WScript.Echo command
|
|
|
149 |
|
|
|
150 |
' --- SSH client with login details ---
|
|
|
151 |
'login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPassword
|
|
|
152 |
login_details = AppPath & WINRSH_EXE &" -q -h "& pRemote_Host &" -l "& outUser &" -p "& outPassword
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
Set sysShell = WScript.CreateObject("WScript.Shell")
|
|
|
156 |
sysShell.Run "cmd.exe /c "& login_details &" """& command &"""", 0, True
|
|
|
157 |
|
|
|
158 |
'Set oExec = sysShell.Exec( login_details &" """& command &"""" )
|
|
|
159 |
'WScript.Echo "HERE:"& oExec
|
|
|
160 |
'outStrOut = oExec.StdOut.ReadAll
|
|
|
161 |
'outStrErr = oExec.StdErr.ReadAll
|
|
|
162 |
|
|
|
163 |
'If outStrErr <> "" Then
|
|
|
164 |
' Call Raise_Event ( enumEVENT_ERROR, "[sub:Create_Doc_Folder]", _
|
|
|
165 |
' "user: "& outUser & VBNewLine &_
|
|
|
166 |
' "command: "& command , _
|
|
|
167 |
' outStrErr, enum_RELEASE_NOTES_FAILED )
|
|
|
168 |
'End If
|
|
|
169 |
|
|
|
170 |
'Set oExec = Nothing
|
|
|
171 |
Set sysShell = Nothing
|
|
|
172 |
End Sub
|
|
|
173 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
174 |
Sub Map_Network_Drive ( SSunc, outMappedDrive )
|
|
|
175 |
Dim outUser, outPassword
|
|
|
176 |
Dim ValidDrivesARR, validDrive, UsedDrives
|
|
|
177 |
Dim i, WshNetwork, oDrives, oFilesys, drv
|
|
|
178 |
WScript.Echo "Mapping drive..."
|
|
|
179 |
|
|
|
180 |
Call Get_Archive_Map_Drive_Login_Details ( outUser, outPassword )
|
|
|
181 |
|
|
|
182 |
ValidDrivesARR = Array("E:","F:","G:","H:","I:","J:","K:","L:","M:","N:","O:","P:","Q:","R:","S:","T:","U:","V:","W:","X:","Y:","Z:")
|
|
|
183 |
Set WshNetwork = WScript.CreateObject("WScript.Network")
|
|
|
184 |
Set oDrives = WshNetwork.EnumNetworkDrives
|
|
|
185 |
|
|
|
186 |
' Check for existing map
|
|
|
187 |
outMappedDrive = ""
|
|
|
188 |
For i = 0 to oDrives.Count - 1 Step 2
|
|
|
189 |
' Reuse network map if exists
|
|
|
190 |
If UCase(oDrives.Item(i+1)) = UCase(SSunc) Then
|
|
|
191 |
outMappedDrive = oDrives.Item(i)
|
|
|
192 |
Exit For
|
|
|
193 |
End If
|
|
|
194 |
Next
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
If outMappedDrive = "" Then
|
|
|
198 |
' Drive need to be mapped, hence map one.
|
|
|
199 |
|
|
|
200 |
' Get all drive used drive letters.
|
|
|
201 |
' NOTE: It will not display a drive if mapped but not connected.
|
|
|
202 |
Set oFilesys = CreateObject("Scripting.FileSystemObject")
|
|
|
203 |
Set oDrives = oFilesys.Drives
|
|
|
204 |
For Each drv in oDrives
|
|
|
205 |
UsedDrives = UsedDrives &"|"& drv.DriveLetter &":|"
|
|
|
206 |
Next
|
|
|
207 |
|
|
|
208 |
For Each validDrive In ValidDrivesARR
|
|
|
209 |
If NOT InStr( UCase(UsedDrives), "|"& UCase(validDrive) &"|") > 0 Then
|
|
|
210 |
' used this unused drive
|
|
|
211 |
On Error Resume Next
|
|
|
212 |
|
|
|
213 |
WshNetwork.MapNetworkDrive validDrive, SSunc, FALSE, outUser, outPassword
|
|
|
214 |
|
|
|
215 |
Call ErrorCheck ( "[sub:Map_Network_Drive]", _
|
|
|
216 |
"used drives: "& UsedDrives & VBNewLine &_
|
|
|
217 |
"valid letters to pick from: "& Join( ValidDrivesARR, ",") & VBNewLine &_
|
|
|
218 |
"attempting to map: "& validDrive & VBNewLine &_
|
|
|
219 |
"UNC: "& SSunc & VBNewLine &_
|
|
|
220 |
"username: "& outUser )
|
|
|
221 |
|
|
|
222 |
outMappedDrive = validDrive
|
|
|
223 |
Exit For
|
|
|
224 |
End If
|
|
|
225 |
Next
|
|
|
226 |
|
|
|
227 |
End If
|
|
|
228 |
|
|
|
229 |
If outMappedDrive = "" Then
|
|
|
230 |
Call Raise_Event ( enumEVENT_ERROR, "[sub:Map_Network_Drive]", _
|
|
|
231 |
"used drives: "& UsedDrives & VBNewLine &_
|
|
|
232 |
"valid drives to pick from: "& Join( ValidDrivesARR, ",") , _
|
|
|
233 |
"Network drive is not mapped!", enum_RELEASE_NOTES_FAILED )
|
|
|
234 |
End If
|
|
|
235 |
|
|
|
236 |
WScript.Echo "Using network drive: "& outMappedDrive
|
|
|
237 |
|
|
|
238 |
Set oDrives = Nothing
|
|
|
239 |
Set WshNetwork = Nothing
|
|
|
240 |
End Sub
|
| 161 |
iaugusti |
241 |
|
| 119 |
ghuddy |
242 |
'-----------------------------------------------------------------------------------------------------------------
|
| 165 |
brianf |
243 |
Sub Make_Release_Changed (apkg_name, apkg_version, artag_id, apkg_id, apv_id, aproj_id, amode_id, await)
|
| 161 |
iaugusti |
244 |
Dim outUser, outPassword
|
|
|
245 |
Dim login_details, command, sysShell, oExec, outStrOut, outStrErr
|
|
|
246 |
WScript.Echo "Running release changed script for "& apkg_name & " " & apkg_version
|
|
|
247 |
|
|
|
248 |
Call Get_Archive_Telnet_Login_Details ( outUser, outPassword )
|
|
|
249 |
|
|
|
250 |
command = _
|
|
|
251 |
"sudo ~/sbin/make_release_changed" &_
|
|
|
252 |
" archive=" & pArchive_Path &_
|
|
|
253 |
" pkg_name='""" & apkg_name & """'" &_
|
|
|
254 |
" pkg_version='"""& apkg_version &"""'" &_
|
|
|
255 |
" rtag_id="& artag_id &_
|
|
|
256 |
" pkg_id=" & apkg_id &_
|
|
|
257 |
" pv_id="& apv_id &_
|
|
|
258 |
" proj_id="& aproj_id &_
|
| 165 |
brianf |
259 |
" mode_id="& amode_id &_
|
| 161 |
iaugusti |
260 |
";"
|
|
|
261 |
|
|
|
262 |
WScript.Echo command
|
|
|
263 |
|
|
|
264 |
' --- SSH client with login details ---
|
|
|
265 |
login_details = AppPath & WINRSH_EXE &" -q -h "& pRemote_Host &" -l "& outUser &" -p "& outPassword
|
|
|
266 |
|
|
|
267 |
Set sysShell = WScript.CreateObject("WScript.Shell")
|
| 165 |
brianf |
268 |
sysShell.Run "cmd.exe /c "& login_details &" """& command &"""", 0, await
|
| 161 |
iaugusti |
269 |
|
|
|
270 |
Set sysShell = Nothing
|
|
|
271 |
|
|
|
272 |
End Sub
|
| 119 |
ghuddy |
273 |
|
|
|
274 |
End Class
|
|
|
275 |
|