Subversion Repositories DevTools

Rev

Rev 3610 | Details | Compare with Previous | Last modification | View Log | RSS feed

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