6/04/2020

SAP Advanced ExecuteInstallationProcedure examples

Advanced ExecuteInstallationProcedure examples


Asynchronous remote Installation

Calling sapinst, long operation runtime is expected, therefore it is a good idea, to execute the operation asynchronously.
The SAP Host Agent support an asynchronous mode for almost all operations. The argument -timeout (or setup in the interface the SAPHostControlOperationOptions.mTimeout) is used to control this behavior.
/* Example for UNIX */
/usr/sap/hostctrl/exe/saphostctrl
    -host DestinationHost
    -user sapadm abcd1234
    -function ExecuteInstallationProcedure
    -inifile hostagent.mf
    -home /tmp
    -prodid 4711
    -mountsrc SourceHost:/opt/exports
    -mounttgt /tmp/sapinst
    -cleanup auto
    -result flat
    -timeout 0
 
 
/* Output after Execution: */
Webmethod returned successfully
Operation ID: 00199905BD8F1DEE9DA22B7747488D29
The operation was now started with the argument -timeout 0 and the method returns immediately (wait for 0 seconds).
The Operation ID contains the unique ID identifying the executed operation.
 To get the results of the operation, you can call the method GetOperationResults as reported below.
./saphostctrl
    -user sapadm abcd1234
    -function GetOperationResults
    -id 00199905BD8F1DEE9DA22B7747488D29
 
 
/* Output after Execution: */
Error: Command execution failed. (fault code: 127)
Operation ID: 00199905BD8F1DEE9DA22B7747488D29
  
  
----- Response data ----
description=Mount installation source
exitcode=0
description=Create execution directory
exitcode=0
description=Adapt ownership
exitcode=0
description=Create inifile
exitcode=0
description=Adapt ownership
exitcode=0
description=Ensure write permission
exitcode=0
Result=HOME : /tmp/sapinst2009_07_20_11_40_28
description=Execute installation
**** Executing sapinst in /tmp/sapinst2009_07_20_11_40_28 ****
SAPINST_EXECUTE_PRODUCT_ID=4711 SAPINST_START_GUI=false SAPINST_START_GUISERVER=false SAPINST_SKIP_DIALOGS=true
using Product ID SAPINST_EXECUTE_PRODUCT_ID=4711
Ini File : inifile.xml
--------------------------------
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
Step 10
--------------------------------
Finish
Last Step Failed
exitcode=255
GetOperationResults returns the results of the operation executed before.
Every call to GetOperationResults can also be executed asynchronously. In this case the argument -timeout 0 (or the number of seconds to wait) has to be provided.

Asynchronous remote Installation with retry and -function ReadLogFile

This example shows the commands for windows you have to execute step by step when you install asynchronously on a remote host:
/* first command; start Installation on host MyHost.MyDomain asynchronously
   This command will return an Opertation ID which will be needed later on */
saphostctrl.exe
    -host MyHost.MyDomain                       // host, where the installation should be run
    -user sapadm abcd1234                       // sapadm credentials of MyHost.MyDomain
    -function ExecuteInstallationProcedure
    -prodid NW_DiagnosticsAgent:NW731.IND.PD
    -paramfile C:\smdinstallparameters
    -home C:\temp                               // directory where sapinst is to be executed
    -mountsrc \\host\swpm_windows               // mountpoint where to find sapinst
    -mounttgt U:                                // target where to mount mountsrc
    -mountusr sapadm                            // user credentials if needed for mount operation
    -mountpwd abcd1234
    -timeout 0                                  // execute asynchonously
 
 
/* second command; read the logfile which is written by sapinst;
   displays the current state of the sapinst run */
sapcontrol.exe
    -host MyHost.MyDomain
    -user sapadm abcd1234
    -nr 99
    -function ReadLogFile C:\temp\sapinst2014_06_02_11_11_30\sapinst.log
 
/* third command; This example shows the case when sapinst failed for some reason,
   the cause of the failure is fixed and the sapinst run is retried.
   This command might not be necessary if sapinst is running fine */ 
saphostctrl.exe
    -host MyHost.MyDomain
    -user sapadm abcd1234
    -function ExecuteInstallationProcedure
    -prodid NW_DiagnosticsAgent:NW731.IND.PD
    -paramfile C:\smdinstallparameters
    -home C:\temp\sapinst2014_06_02_11_11_30
    -mountsrc \\host\swpm_windows
    -mounttgt U:
    -mountusr sapadm
    -mountpwd abcd1234
    -retry
    -cleanup auto
 
/* fourth command; Get the results of ExecuteInstallationProcedure */ 
saphostctrl.exe
    -host MyHost.MyDomain
    -user sapadm abcd1234
    -function GetOperationResults
    -id AAAABBBB      // Operation ID returned by the first command
    -timeout 0

No comments:

Post a Comment

Popular Posts