Adding custom status reporting to installation scripts

The recommended predefined macros in the unattend file report final operating-system deployment status and report status when downloading and running post-installation scripts. You can include additional status reporting in the post-installation scripts.

Linux

For Linux, you can use the following curl command to report status.
curl -X PUT -globoff #predefined.otherSettings.statusSettings.urlStatus#
-H "Content-Type: application/json" -d '{"deployStatus":{"id":"<status_ID>"}}' 
-cert #predefined.otherSettings.statusSettings.certLocation#/cert.pem 
-key #predefined.otherSettings.statusSettings.certLocation#/key.pem 
-cacert #predefined.otherSettings.statusSettings.certLocation#/ca-bundle.crt

Where <status_ID> can be one of the following values.

Note that the curl command uses predefined macros for the HTTPS URL that Lenovo XClarity Administrator uses for reporting status (predefined.otherSettings.statusSettings.urlStatus) and for the folder that contains the certificates that are needed to access the urlStatus web service from the host OS on first boot (predefined.otherSettings.statusSettings.certLocation).The following example reports that an error occurred in the post-installation script.

The following example reports that an error occurred in the post-installation script.
curl -X PUT -globoff #predefined.otherSettings.statusSettings.urlStatus#
-H "Content-Type: application/json" -d '{"deployStatus":{"id":"48"}}' 
-cert #predefined.otherSettings.statusSettings.certLocation#/cert.pem 
-key #predefined.otherSettings.statusSettings.certLocation#/key.pem 
-cacert #predefined.otherSettings.statusSettings.certLocation#/ca-bundle.crt

Windows

For Wiindows, you can import the LXCA.psm1 script and then call the following commands to report status.

Where <message_text> is the message that you want to return to XClarity Administrator for each status condition.

Note that these commands use predefined macros for the IP address of the XClarity Administrator instance (#predefined.otherSettings.lxcaIp#) and for the UUID of the host server to which the operating system is to be deployed (#predefined.hostPlatforms.uuid#).

The following example is a PowerShell installation script that installs Java and reports an error if the installation fails

import-module C:\windows\system32\WindowsPowerShell\v1.0\Modules\LXCA\LXCA.psm1

initializeRestClient 

testLXCAConnection –masterIP "#predefined.otherSettings.lxcaIp#"

Write-Output "Reporting status to Lenovo XClarity Administator..."
   reportWorkloadDeploymentMessage -masterIP "#predefined.otherSettings.lxcaIp#" 
   -UUID "#predefined.hostPlatforms.uuid#" -Message "Installing Java"

Write-Output "Install Java...."
   Invoke-Command -ScriptBlock {#predefined.otherSettings.deployDataAndSoftwareLocation#\jre-8u151-windows-x64.exe
   [INSTALLCFG=#predefined.otherSettings.deployDataAndSoftwareLocation#\java_configfile.cfg] /s}

if ($LastExitCode -ne 0) {
   reportWorkloadDeploymentFailed -masterIP "#predefined.otherSettings.lxcaIp#" 
      -UUID "#predefined.hostPlatforms.uuid#" -ErrorMessage "Java could not be installed"
}

Write-Output "Completed install of Java for Administrator user."