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
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.
44. Workload deployment succeeded
45. Workload deployment is running with warning
46. Workload deployment failed
47. Workload deployment message
48. Custom post-install script error
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.
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.
initializeRestClient
Initializes the REST client. Use the following syntax to run this command. This command is required before running the reporting commands.
initializeRestClient
testLXCAConnection
Verifies that the XClarity Administrator can connect to the host server. Use the following syntax to run this command. This command is optional but recommended in the installation script before running the reporting commands..
testLXCAConnection –masterIP "#predefined.otherSettings.lxcaIp#"
reportWorkloadDeploymentSucceeded
Reports a successful-completion message to be logged in the XClarity Administrator jobs log. Use the following syntax to run this command.
TipIf the#predefined.unattendSettings.reportWorkloadNotComplete# macro is included in a custom unatted file or post-installation script, include the reportWorkloadDeploymentSucceeded command in the post-installation script to signal a successful-completion. Otherwise, XClarity Administrator automatically reports a complete status after all post-installation scripts are run. reportWorkloadDeploymentSucceeded -masterIP "#predefined.otherSettings.lxcaIp#"
-UUID "#predefined.hostPlatforms.uuid#"reportWorkloadDeploymentRunningWithWarning
Reports a warning message to be logged in the XClarity Administrator jobs log. Use the following syntax to run this command.
reportWorkloadDeploymentRunningWithWarning -masterIP "#predefined.otherSettings.lxcaIp#"
-UUID "#predefined.hostPlatforms.uuid#" –WarningMessage "<message_text>"reportWorkloadDeploymentFailed
Reports a failure message to be logged in the XClarity Administrator jobs log. Use the following syntax to run this command.
reportWorkloadDeploymentFailed -masterIP "#predefined.otherSettings.lxcaIp#"
-UUID "#predefined.hostPlatforms.uuid#" -ErrorMessage "<message_text>"reportCustomPostInstallScriptError
Reports a post-installation script error message to be logged in the XClarity Administrator jobs log. Use the following syntax to run this command.
reportCustomPostInstallScriptError -masterIP "#predefined.otherSettings.lxcaIp#"
-UUID "#predefined.hostPlatforms.uuid#" -Message "<message_text>"reportWorkloadDeploymentMessage
Reports a general message to be logged in the XClarity Administrator jobs log without affecting the state of the deployment. Use the following syntax to run this command.
reportWorkloadDeploymentMessage -masterIP "#predefined.otherSettings.lxcaIp#"
-UUID "#predefined.hostPlatforms.uuid#" -Message "<message_text>"
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."