Rev 1281 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'=====================================================' Name: pkg_archive' Description: This library contains methods required' for dpkg_archive manipulation.'=====================================================Option ExplicitClass PkgArchive'================ Properties Declaration =============Private pRemote_HostPrivate pArchive_Path'==================== Properties =====================Public Property Let Remote_Host( SSrhost )pRemote_Host = SSrhostEnd PropertyPublic Property Let Archive_Path( SSarch_path )pArchive_Path = UnixPath(SSarch_path)End Property'====================== Methods ======================'-----------------------------------------------------------------------------------------------------------------Private Sub Get_Archive_Telnet_Login_Details ( outUser, outPassword )outUser = "releasem"outPassword = "releasem"End Sub'-----------------------------------------------------------------------------------------------------------------Private Sub Get_Archive_Map_Drive_Login_Details ( outUser, outPassword )outUser = "vix\releasem"outPassword = "releasem"End Sub'-----------------------------------------------------------------------------------------------------------------Function UnixPath( SSpath )If SSpath <> "" Then UnixPath = Replace( SSpath, "\", "/" )End Function'-----------------------------------------------------------------------------------------------------------------Sub Ensure_Read_Write ( SSpkg_name, SSpkg_version )Dim outMachine, outUser, outPassword, rvDim login_details, command, sysShell, oExec, outStrOut, outStrErrWScript.Echo "Allowing Read and Write on folder "& SSpkg_name & "/" & SSpkg_versionCall Get_Archive_Telnet_Login_Details ( outUser, outPassword )' Make the package writable' Invoke script on package server to perform the hard work' It must be done under UNIX as it can't be done under windows'command = _"sudo ~/sbin/make_writable "& pArchive_Path &" '"& SSpkg_name &"' '"& SSpkg_version &"';"WScript.Echo command' --- SSH client with login details ---login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPassword'WScript.Echo login_details &" """& command &""""Set sysShell = WScript.CreateObject("WScript.Shell")rv = sysShell.Run ("cmd.exe /c "& login_details &" """& command &"""", 0, True)Set sysShell = NothingIf ( rv <> 0 ) thenCall Raise_Event ( enumEVENT_ERROR, "Ensure_Read_Write", "Command Failure: " & rv, "Command :" & login_details &" """& command &"""",enum_RELEASE_NOTES_FAILED )End IfEnd Sub'-----------------------------------------------------------------------------------------------------------------Sub All_Read_Only ( SSpkg_name, SSpkg_version )Dim outMachine, outUser, outPassword, rvDim login_details, command, sysShell, oExec, outStrOut, outStrErrCall Get_Archive_Telnet_Login_Details ( outUser, outPassword )' Make package ReadOnlycommand = _"sudo ~/sbin/make_readonly "& pArchive_Path &" '"& SSpkg_name &"' '"& SSpkg_version &"';"WScript.Echo command' --- SSH client with login details ---login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPassword'WScript.Echo login_details &" """& command &""""Set sysShell = WScript.CreateObject("WScript.Shell")rv = sysShell.Run ("cmd.exe /c "& login_details &" """& command &"""", 0, True)Set sysShell = NothingIf ( rv <> 0 ) thenCall Raise_Event ( enumEVENT_ERROR, "All_Read_Only", "Command Failure: " & rv, "Command :" & login_details &" """& command &"""",enum_RELEASE_NOTES_FAILED )End IfEnd Sub'-----------------------------------------------------------------------------------------------------------------Sub Create_Doc_Folder ( SSpkg_name, SSpkg_version, docFolder )Dim outMachine, outDpkg_root, outUser, outPassword, rvDim login_details, command, sysShell, oExec, outStrOut, outStrErrCall Get_Archive_Telnet_Login_Details ( outUser, outPassword )' --- Commands to run ---command = _"sudo ~/sbin/make_docFolder "& pArchive_Path &" '"& SSpkg_name &"' '"& SSpkg_version &"' '" & docFolder &"';"WScript.Echo command' --- SSH client with login details ---login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPassword'WScript.Echo login_details &" """& command &""""Set sysShell = WScript.CreateObject("WScript.Shell")rv = sysShell.Run ("cmd.exe /c "& login_details &" """& command &"""", 0, True)Set sysShell = NothingIf ( rv <> 0 ) thenCall Raise_Event ( enumEVENT_ERROR, "Create_Doc_Folder", "Command Failure: " & rv, "Command :" & login_details &" """& command &"""",enum_RELEASE_NOTES_FAILED )End IfEnd Sub'-----------------------------------------------------------------------------------------------------------------Sub Map_Network_Drive ( SSunc, outMappedDrive )Dim outUser, outPasswordDim ValidDrivesARR, validDrive, UsedDrivesDim i, WshNetwork, oDrives, oFilesys, drvWScript.Echo "Mapping drive..."Call Get_Archive_Map_Drive_Login_Details ( outUser, outPassword )ValidDrivesARR = Array("E:","F:","G:","H:","I:","J:","K:","L:","M:","N:","O:","P:","Q:","R:","S:","T:","U:","V:","W:","X:","Y:","Z:")Set WshNetwork = WScript.CreateObject("WScript.Network")Set oDrives = WshNetwork.EnumNetworkDrives' Check for existing mapoutMappedDrive = ""For i = 0 to oDrives.Count - 1 Step 2' Reuse network map if existsIf UCase(oDrives.Item(i+1)) = UCase(SSunc) ThenoutMappedDrive = oDrives.Item(i)Exit ForEnd IfNextIf outMappedDrive = "" Then' Drive need to be mapped, hence map one.' Get all drive used drive letters.' NOTE: It will not display a drive if mapped but not connected.Set oFilesys = CreateObject("Scripting.FileSystemObject")Set oDrives = oFilesys.DrivesFor Each drv in oDrivesUsedDrives = UsedDrives &"|"& drv.DriveLetter &":|"NextFor Each validDrive In ValidDrivesARRIf NOT InStr( UCase(UsedDrives), "|"& UCase(validDrive) &"|") > 0 Then' used this unused driveOn Error Resume NextWshNetwork.MapNetworkDrive validDrive, SSunc, FALSE, outUser, outPasswordCall ErrorCheck ( "[sub:Map_Network_Drive]", _"used drives: "& UsedDrives & VBNewLine &_"valid letters to pick from: "& Join( ValidDrivesARR, ",") & VBNewLine &_"attempting to map: "& validDrive & VBNewLine &_"UNC: "& SSunc & VBNewLine &_"username: "& outUser )outMappedDrive = validDriveExit ForEnd IfNextEnd IfIf outMappedDrive = "" ThenCall Raise_Event ( enumEVENT_ERROR, "[sub:Map_Network_Drive]", _"used drives: "& UsedDrives & VBNewLine &_"valid drives to pick from: "& Join( ValidDrivesARR, ",") , _"Network drive is not mapped!", enum_RELEASE_NOTES_FAILED )End IfWScript.Echo "Using network drive: "& outMappedDriveSet oDrives = NothingSet WshNetwork = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------Sub Make_Release_Changed (apkg_name, apkg_version, artag_id, apkg_id, apv_id, aproj_id, amode_id, await)Dim outUser, outPassword, rvDim login_details, command, sysShell, oExec, outStrOut, outStrErrWScript.Echo "Running release changed script for "& apkg_name & " " & apkg_versionCall Get_Archive_Telnet_Login_Details ( outUser, outPassword )command = _"sudo ~/sbin/make_release_changed" &_" archive=" & pArchive_Path &_" pkg_name='""" & apkg_name & """'" &_" pkg_version='"""& apkg_version &"""'" &_" rtag_id="& artag_id &_" pkg_id=" & apkg_id &_" pv_id="& apv_id &_" proj_id="& aproj_id &_" mode_id="& amode_id &_";"WScript.Echo command' --- SSH client with login details ---login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPassword'WScript.Echo login_details &" """& command &""""Set sysShell = WScript.CreateObject("WScript.Shell")rv = sysShell.Run ("cmd.exe /c "& login_details &" """& command &"""", 0, True)Set sysShell = NothingIf ( rv <> 0 ) thenCall Raise_Event ( enumEVENT_ERROR, "Make_Release_Changed", "Command Failure: " & rv, "Command :" & login_details &" """& command &"""",enum_RELEASE_NOTES_FAILED )End IfEnd Sub'-----------------------------------------------------------------------------------------------------------------Function Test_Pkg_Archive_Access ()Dim outUser, outPassword, rv, fvDim login_details, command, sysShell, oExec, outStrOut, outStrErrWScript.Echo "Test_Pkg_Archive_Access"fv = 0Call Get_Archive_Telnet_Login_Details ( outUser, outPassword )command = _"sudo ~/sbin/make_test_access;"WScript.Echo command' --- SSH client with login details ---login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPasswordWScript.Echo login_details &" """& command &""""Set sysShell = WScript.CreateObject("WScript.Shell")rv = sysShell.Run ("cmd.exe /c "& login_details &" """& command &"""", 0, True)Set sysShell = NothingWScript.Echo "Results: " & rvIf ( rv <> 55 ) thenCall Raise_Event ( enumEVENT_ERROR, "Test_Pkg_Archive_Access", "Command Failure: " & rv, "Command :" & login_details &" """& command &"""",enum_RELEASE_NOTES_FAILED )fv = 1End IfTest_Pkg_Archive_Access = fvEnd FunctionEnd Class