Custom macros
Macros give you the ability to add variable data (configuration settings) to an unattend file or post-installation script. Lenovo XClarity Administrator allows you to define your own custom settings by creating a custom configuration-settings file, using JSON format.
The value for each custom configuration setting varies based on user input that is specified during OS deployment.
When you import custom configuration settings in XClarity Administrator, XClarity Administrator validates the JSON schema. If the validation passes, XClarity Administrator generates custom macros for each setting.
To inject custom macros in to an unattend file or post-installation script, use the unique name of the object, separate nested objects using a period, and then surround the macro name with a hash symbol (#), for example, #server_settings.server0.locale#.
Do not include the top-most object name.
When an object is created from a template, the name is appended with a unique number, starting with 0 (for example, server0 and server1).
You can see the name for each macro from the Deploy OS Images dialog on the Custom Settings tabs by hovering over the Help icon () next to each custom setting.
Configuration settings
Are common to all target servers or unique to a specific target server.
Have static (non-configurable) values or with dynamic (configurable) values that are entered when you deploy the OS-image profile.
Have a variable number of elements based on a template. For example, you can define a configuration setting that let's you specify 0 – 3 NTP servers during deployment.
- Common settings
During OS deployment, the UI elements on the Common Settings tabs on the Deploy OS Image dialog are rendered based on the objects that are represented in the content object. The objects describe the settings and values that the all target servers need for OS deployment.
To represent settings that are common to all servers, the JSON file must contain a parent object with a nested object that contains the "common":true name/value pair.
The following example uses the same configurable (dynamic) NTP servers for all servers.{
"category": "dynamic",
"content": [{
"category": "dynamic",
"common": true,
"description": "NTP Servers",
"label": "NTP Servers",
"maxElements": 3,
"minElements": 0,
"name": "common-ntpservers",
"optional": true,
"template": [{
"autoCreateInstance": true,
"category": "dynamic",
"common": true,
"description": "A NTP Server",
"label": "NTP Server",
"name": "ntpserver",
"optional": true,
"regex": "[\\w\\.]{1,64}$",
"type": "string"
}],
"type": "array"
},
...,
}The following example uses the same non-configurable (static) post-installation script log directory.{
"category": "dynamic",
"content": [{
"category": "static",
"common": true,
"description": "Directory location for post-installation script logging.",
"name": "logpath",
"optional": false,
"type": "string",
"value": "/tmp/mylogger.log"
},
...,
}- Server-specific settings
During OS deployment, the UI elements on the Server-Specific Settings tab on the Deploy OS Image dialog are rendered based on the objects that are represented in the template’s content objects. The objects describe the settings and values that a specific target server needs for OS deployment.
After the server-specific values are gathered in the UI, a content object is created in the JSON for each target server based on the template object. Each content object contain a unique name and targetServer field, and any values that were inputted for that server.
To represent the server-specific settings, the JSON file must contain a parent object with the following content:
The "category":"dynamic" name/value pair.
A nested object that contains the "common":false name/value pair. Only one "common": false object is supported in the content of the parent object.
A template object with an embedded content object. This template array can contain only one object.
For example, if you want to define a unique OS locale for each target server{
"category": "dynamic",
"content": [{
"category": "dynamic",
"common": false,
"name": "server-settings",
"optional": false,
"template": [{
"category": "dynamic",
"common": false,
"content": [{
"category": "dynamic",
"choices": ["en_US", "pt_BR", "ja_JP"],
"common": false,
"label": "OS Locale",
"name": "locale",
"optional": false,
"type": "string",
"value": "en_US"
}],
"name": "server",
"optional": false,
"type": "assoc_array"
}],
"type": "assoc_array"
},
...,
}
JSON specification
The following table describes the fields that are allowed in the JSON specification.
Parameter | Required / Optional | Type | Description | ||
---|---|---|---|---|---|
autoCreateInstance | Optional | Boolean | Indicates whether an instance of the template object is created automatically in JSON file at deployment time. This can be one of the following values.
Note This field can be placed only in the template object. | ||
category | Required | String | Indicates how the value of each setting is populated. This can be one of the following values:
Nested objects inherit the value of this field from its parent object. If category is set to static in the parent object, then it must be set to static in all nested objects as well. If category is set to dynamic in the parent object, it can be either static or dynamic in the nested objects. | ||
choices | Optional | Array of values that match the type property | Array of static values (such as strings or integers) for the configuration setting from which the user can select during OS deployment (for example, ["enabled","disabled"]). | ||
common | Optional | Boolean | Indicates whether this configuration schema applies to all target servers.
Nested objects inherit the value of this field from its parent object. If common is set to true in the parent object, then it must be set to true in all nested objects as well. If common is set to false in the parent object, then it must be set to false in all nested objects. | ||
content | Optional | Array of objects | Pattern that represents nested objects in the schema. After user-inputted data is gathered during OS deployment, this field is used to represent the final values for a given template in the instance of the configuration-settings file that is created for the deployment. | ||
default | Optional | Varies depending on the type | The default value. | ||
description | Optional | String | Description of the object | ||
label | Optional | String | Label for the setting in the user interface that is displayed during OS deployment | ||
max | Optional | Integer | Maximum value, when type is set to integer. The default value is unlimited. | ||
maxElements | Optional | Integer | Maximum number of entries in the array for this object. | ||
min | Optional | Integer | Minimum value, when type is set to integer. The default value is 0. | ||
minElements | Optional | Integer | Minimum number of entries in the array for this object. | ||
name | Required | String | Unique name of the object. This name can contain only the following characters: alphanumeric characters (a-z, A-Z, and 0-9), underscore (_), and dash (-). You can reference the name as a custom macro in the unattend file. When referencing a nested name object, separate each object using a period (for example, mydeploy.node.locale). | ||
optional | Required | Boolean | Indicates whether the object is optional. This can be one of the following values.
| ||
regex | Optional | String | Regular expression for validating the value (for example, "[\\w\\.]{1,64}$") | ||
script | Optional | Array of strings | List of scripts, separated by a comma, that have dependencies on the data in this object (for example, ["/opt/lenovo/saphana/bin/saphana-create-saphana.sh", "create_hana.sh"]). Note The scripts must be available to the OS-image profile as an installation script or custom software. | ||
targetServer | Optional | String | UUID of the server that is the target for the OS deployment. If common is true, this field can be empty or null, and the target server is specified during OS deployment. | ||
template | Optional | Array of objects | Pattern that represents reusable objects. During OS deployment, this template can represent multiple instances of the object. The minElements and maxElements fields can be used to limit the number of instances. The following example uses a template to represent an array of 1 - 3 NTP servers.
After user-inputted values are gathered during OS deployment, an instance of the configuration-settings file is created with specific content for each device on which the OS is to be deployed.
Note
| ||
type | Required | String | Data type for the object. This can be one of the following values.
| ||
value | Optional | String | A single static value for the configuration setting. Note
|
{
"category": "dynamic",
"content": [{
"category": "dynamic",
"common": false,
"name": "server-settings",
"optional": false,
"template": [{
"autoCreateInstance": true,
"category": "dynamic",
"common": false,
"content": [{
"category": "dynamic",
"choices": ["en_US", "pt_BR", "ja_JP"],
"common": false,
"description": "This parameter defines the OS language locale to use with this deployment.
English, Brazilian Portuguese, and Japanese are supported.",
"label": "OS Locale",
"name": "locale",
"optional": false,
"type": "string",
"value": "en_US"
},
{
"category": "dynamic",
"choices": ["english-us", "pt_BR", "ja_JP"],
"common": false,
"description": "This parameter defines the keyboard locale to use with this deployment.
English, Brazilian Portuguese, and Japanese are supported.",
"label": "Keyboard Locale",
"name": "keyboardLocale",
"optional": false,
"type": "string",
"value": "english-us"
}],
"name": "server",
"optional": false,
"type": "assoc_array"
}],
"type": "assoc_array"
},
{
"category": "dynamic",
"common": true,
"description": "NTP Servers",
"label": "NTP Servers",
"maxElements": 3,
"minElements": 0,
"name": "common-ntpservers",
"optional": true,
"template": [{
"category": "dynamic",
"common": true,
"description": "A NTP Server",
"label": "NTP Server",
"name": "ntpserver",
"optional": true,
"regex": "[\\w\\.]{1,64}$",
"type": "string"
}],
"type": "array"
},
{
"category": "static",
"common": true,
"description": "Directory for post-installation script logging.",
"name": "logpath",
"optional": false,
"type": "string",
"value": "/tmp/mylogger.log"
}],
"description": "Custom configuration file for deployment of custom locale, NTP server,
and directory for post-installation script logs.",
"label": "My Custom Deployment",
"name": "myCustomDeploy",
"optional": false,
"type": "array"
}
{
"category": "dynamic",
"content": [{
"category": "dynamic",
"common": false,
"name": "server-settings",
"optional": false,
"content": [{
"category": "dynamic",
"common": false,
"content": [{
"category": "dynamic",
"choices": ["en_US", "pt_BR", "ja_JP"],
"common": false,
"description": "This parameter defines the OS language locale to use with this deployment.
English, Brazilian Portuguese, and Japanese are supported.",
"label": "OS Locale",
"name": "locale",
"optional": false,
"type": "string",
"value": "en_US"
},
{
"category": "dynamic",
"choices": ["english-us", "pt_BR", "ja_JP"],
"common": false,
"description": "This parameter defines the keyboard locale to use with this deployment.
English, Brazilian Portuguese, and Japanese are supported.",
"label": "Keyboard Locale",
"name": "keyboardLocale",
"optional": false,
"type": "string",
"value": "english-us"
}],
"name": "server0",
"optional": false,
"type": "assoc_array",
"targetServer": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"category": "dynamic",
"common": false,
"content": [{
"category": "dynamic",
"choices": ["en_US", "pt_BR", "ja_JP"],
"common": false,
"description": "This parameter defines the OS language locale to use with this deployment.
English, Brazilian Portuguese, and Japanese are supported.",
"label": "OS Locale",
"name": "locale",
"optional": false,
"type": "string",
"value": "en_US"
},
{
"category": "dynamic",
"choices": ["english-us", "pt_BR", "ja_JP"],
"common": false,
"description": "This parameter defines the keyboard locale to use with this deployment.
English, Brazilian Portuguese, and Japanese are supported.",
"label": "Keyboard Locale",
"name": "keyboardLocale",
"optional": false,
"type": "string",
"value": "english-us"
}],
"name": "server1",
"optional": false,
"type": "assoc_array",
"targetServer": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
}],
"template": [{
"category": "dynamic",
"common": false,
"content": [{
"category": "dynamic",
"choices": ["en_US", "pt_BR", "ja_JP"],
"common": false,
"description": "This parameter defines the OS language locale to use with this deployment.
English, Brazilian Portuguese, and Japanese are supported.",
"label": "OS Locale",
"name": "locale",
"optional": false,
"type": "string",
"value": "en_US"
},
{
"category": "dynamic",
"choices": ["english-us", "pt_BR", "ja_JP"],
"common": false,
"description": "This parameter defines the keyboard locale to use with this deployment.
English, Brazilian Portuguese, and Japanese are supported.",
"label": "Keyboard Locale",
"name": "keyboardLocale",
"optional": false,
"type": "string",
"value": "english-us"
}],
"name": "server",
"optional": false,
"type": "assoc_array"
}],
"type": "assoc_array"
},
{
"category": "dynamic",
"common": true,
"description": "NTP Servers",
"label": "NTP Servers",
"maxElements": 3,
"minElements": 0,
"name": "common-ntpservers",
"optional": true,
"content": [{
"category": "dynamic",
"common": true,
"description": "A NTP Server",
"label": "NTP Server",
"name": "ntpserver0,
"optional": true,
"regex": "[\\w\\.]{1,64}$",
"type": "string",
"value": "192.0.2.1"
},
{
"category": "dynamic",
"common": true,
"description": "A NTP Server",
"label": "NTP Server",
"name": "ntpserver1",
"optional": true,
"regex": "[\\w\\.]{1,64}$",
"type": "string",
"value": "192.0.2.2"
}],
"template": [{
"category": "dynamic",
"common": true,
"description": "A NTP Server",
"label": "NTP Server",
"name": "ntpserver",
"optional": true,
"regex": "[\\w\\.]{1,64}$",
"type": "string"
}],
"type": "array"
},
{
"category": "static",
"common": true,
"description": "Directory for post-installation script logs.",
"name": "logpath",
"optional": false,
"type": "string",
"value": "/tmp/mylogger.log"
}],
"description": "Custom configuration file for deployment of custom locale, NTP server,
and directory for post-installation script logs.",
"label": "My Custom Deployment",
"name": "myCustomDeploy",
"optional": false,
"type": "array"
}