Update host templates

PUT method to dynamically update the host templates of a provider instance.

Method URL Description
PUT https://host_name:port/platform/rest/hostfactory/provider/$provider_name/templates Submits the provider's host template configuration to the HostFactory service for dynamic update. Dynamic updates allow you to update the provider's host template configuration without impacting current provisioning requests. Using this method, you can add or remove templates or update parameters of existing templates.

Prerequisite

You must be the cluster administrator or your user account must be assigned the HF_ALL_PROVIDER_MANAGE permission.

Request

PUT https://host_name:port/platform/rest/hostfactory/provider/$provider_name/templates?parameter

where provider_name identifies your cloud provider.

Table 1. Request parameter
Parameter Type Required/Optional Description
hfcsrftoken string Optional CSRF token that is obtained with successful login.
This command takes a JSON request string that must follow this template:
{
  "templates":
  [
    {
      "templateId"	: "(mandatory)(string) unique name for template",
      "maxNumber"         : "(mandatory)(numeric) max hosts that can be provisioned"
      "attributes"	:  
      {
          "type"    : "(mandatory) ["String", "type of the VM. Supported values: X86_64"]",
          "ncpus"   : "(mandatory) ["Numeric", "number of cpus per host "]",
          "nram"    : "(mandatory) ["Numeric", "min RAM required per host"]"       
      },
      attr_1		:   "(string/numeric) additional host provider specific attributes"  
      attr_2		:   "additional host provider specific attributes"  
      attr_n		:   "additional host provider specific attributes"
      ...        
     },
   ]
}

If you use curl, the command might look like the following example:

curl --header -b /tmp/cookie --cacert /opt/ibm/spectrumcomputing/wlp/usr/shared/resources/security/cacert.pem --tlsv1.2 -X PUT https://myprimaryhost.example.com:9443/platform/rest/hostfactory/provider/aws/templates?hfcsrftoken=915ee7644f431e630dac68b9ab3e40bc -d @awstemplates.json
where awstemplates.json is the new template configuration file with the following configuration:
cat awstemplates.json
{
    "templates": [
        {
            "templateId": "Template-VM-SYMA",
            "maxNumber": 1,
            "attributes": {
                "type": ["String", "X86_64"],
                "ncpus": ["Numeric", "1"],
                "nram": ["Numeric", "1024"]
            },
            "imageId": "ami-b63769a1",
            "subnetId": "subnet-d694eca0",
            "vmType": "t2.micro",
            "keyName": "Sym-Key",
            "securityGroupIds": ["sg-4ae4d432"],
            "userDataScript": "/scripts/post_install.sh"
        },
        {
            "templateId": "Template-VM-SYMB",
            "maxNumber": 2,
            "attributes": {
                "type": ["String", "X86_64"],
                "ncpus": ["Numeric", "1"],
                "nram": ["Numeric", "1024"]
            },
            "imageId": "ami-b63769a1",
            "subnetId": "subnet-d694eca0",
            "vmType": "t2.micro",
            "keyName": "Sym-Key",
            "securityGroupIds": ["sg-4ae4d432"],
            "userDataScript": "/scripts/post_install.sh"
        }
}

Templates with .bak extensions (such as provider_nameprov_templates.json.bak) are reserved for internal use. Avoid saving your templates as .bak files in the template file directory.

If the HostFactory service fails over during dynamic update and the client fails to detect being disconnected, you must manually terminate the client connection and try again.

Response

Status code Description
200 OK
500 Internal server error. Check the log files and look for hints in the API response body.