cm_client.HostTemplatesResourceApi

All URIs are relative to /api/v57

Method HTTP request Description
apply_host_template POST /clusters/{clusterName}/hostTemplates/{hostTemplateName}/commands/applyHostTemplate Applies a host template to a collection of hosts.
create_host_templates POST /clusters/{clusterName}/hostTemplates Creates new host templates.
delete_host_template DELETE /clusters/{clusterName}/hostTemplates/{hostTemplateName} Deletes a host template.
read_host_template GET /clusters/{clusterName}/hostTemplates/{hostTemplateName} Retrieves information about a host template.
read_host_templates GET /clusters/{clusterName}/hostTemplates Lists all host templates in a cluster.
reapply_host_template_on_hosts POST /clusters/{clusterName}/hostTemplates/{hostTemplateName}/commands/reapplyHostTemplateOnHosts Reapplies a host template on all the hosts associated with the host template.
update_host_template PUT /clusters/{clusterName}/hostTemplates/{hostTemplateName} Updates an existing host template.

apply_host_template

ApiCommand apply_host_template(cluster_name, host_template_name, body=body, run_config_rules=run_config_rules, start_roles=start_roles)

Applies a host template to a collection of hosts.

Applies a host template to a collection of hosts. This will create a role for each role config group on each of the hosts.

The provided hosts must not have any existing roles on them and if the cluster is not using parcels, the hosts must have a CDH version matching that of the cluster version.

Available since API v3.

Example

from __future__ import print_function
import time
import cm_client
from cm_client.rest import ApiException
from pprint import pprint
# Configure HTTP basic authorization: basic
configuration = cm_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = cm_client.HostTemplatesResourceApi(cm_client.ApiClient(configuration))
cluster_name = 'cluster_name_example' # str | 
host_template_name = 'host_template_name_example' # str | Host template to apply.
body = cm_client.ApiHostRefList() # ApiHostRefList | List of hosts to apply the host template to. (optional)
run_config_rules = false # bool | Whether to run the rules engine to automatically configure roles present on the hosts (optional) (default to false)
start_roles = true # bool | Whether to start the newly created roles or not. (optional)

try:
    # Applies a host template to a collection of hosts.
    api_response = api_instance.apply_host_template(cluster_name, host_template_name, body=body, run_config_rules=run_config_rules, start_roles=start_roles)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostTemplatesResourceApi->apply_host_template: %s\n" % e)

Parameters

Name Type Description Notes
cluster_name str
host_template_name str Host template to apply.
body ApiHostRefList List of hosts to apply the host template to. [optional]
run_config_rules bool Whether to run the rules engine to automatically configure roles present on the hosts [optional] [default to false]
start_roles bool Whether to start the newly created roles or not. [optional]

Return type

ApiCommand

Authorization

basic

HTTP request headers

[Back to top] [Back to API list] [Back to Model list] [Back to README]

create_host_templates

ApiHostTemplateList create_host_templates(cluster_name, body=body)

Creates new host templates.

Creates new host templates.

Host template names must be unique across clusters.

Available since API v3.

Example

from __future__ import print_function
import time
import cm_client
from cm_client.rest import ApiException
from pprint import pprint
# Configure HTTP basic authorization: basic
configuration = cm_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = cm_client.HostTemplatesResourceApi(cm_client.ApiClient(configuration))
cluster_name = 'cluster_name_example' # str | 
body = cm_client.ApiHostTemplateList() # ApiHostTemplateList | The list of host templates to create. (optional)

try:
    # Creates new host templates.
    api_response = api_instance.create_host_templates(cluster_name, body=body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostTemplatesResourceApi->create_host_templates: %s\n" % e)

Parameters

Name Type Description Notes
cluster_name str
body ApiHostTemplateList The list of host templates to create. [optional]

Return type

ApiHostTemplateList

Authorization

basic

HTTP request headers

[Back to top] [Back to API list] [Back to Model list] [Back to README]

delete_host_template

ApiHostTemplate delete_host_template(cluster_name, host_template_name)

Deletes a host template.

Deletes a host template.

Available since API v3.

Example

from __future__ import print_function
import time
import cm_client
from cm_client.rest import ApiException
from pprint import pprint
# Configure HTTP basic authorization: basic
configuration = cm_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = cm_client.HostTemplatesResourceApi(cm_client.ApiClient(configuration))
cluster_name = 'cluster_name_example' # str | 
host_template_name = 'host_template_name_example' # str | Host template to delete.

try:
    # Deletes a host template.
    api_response = api_instance.delete_host_template(cluster_name, host_template_name)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostTemplatesResourceApi->delete_host_template: %s\n" % e)

Parameters

Name Type Description Notes
cluster_name str
host_template_name str Host template to delete.

Return type

ApiHostTemplate

Authorization

basic

HTTP request headers

[Back to top] [Back to API list] [Back to Model list] [Back to README]

read_host_template

ApiHostTemplate read_host_template(cluster_name, host_template_name)

Retrieves information about a host template.

Retrieves information about a host template.

Available since API v3.

Example

from __future__ import print_function
import time
import cm_client
from cm_client.rest import ApiException
from pprint import pprint
# Configure HTTP basic authorization: basic
configuration = cm_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = cm_client.HostTemplatesResourceApi(cm_client.ApiClient(configuration))
cluster_name = 'cluster_name_example' # str | 
host_template_name = 'host_template_name_example' # str | 

try:
    # Retrieves information about a host template.
    api_response = api_instance.read_host_template(cluster_name, host_template_name)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostTemplatesResourceApi->read_host_template: %s\n" % e)

Parameters

Name Type Description Notes
cluster_name str
host_template_name str

Return type

ApiHostTemplate

Authorization

basic

HTTP request headers

[Back to top] [Back to API list] [Back to Model list] [Back to README]

read_host_templates

ApiHostTemplateList read_host_templates(cluster_name)

Lists all host templates in a cluster.

Lists all host templates in a cluster.

Available since API v3.

Example

from __future__ import print_function
import time
import cm_client
from cm_client.rest import ApiException
from pprint import pprint
# Configure HTTP basic authorization: basic
configuration = cm_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = cm_client.HostTemplatesResourceApi(cm_client.ApiClient(configuration))
cluster_name = 'cluster_name_example' # str | 

try:
    # Lists all host templates in a cluster.
    api_response = api_instance.read_host_templates(cluster_name)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostTemplatesResourceApi->read_host_templates: %s\n" % e)

Parameters

Name Type Description Notes
cluster_name str

Return type

ApiHostTemplateList

Authorization

basic

HTTP request headers

[Back to top] [Back to API list] [Back to Model list] [Back to README]

reapply_host_template_on_hosts

ApiCommand reapply_host_template_on_hosts(cluster_name, host_template_name, delete_roles=delete_roles, start_roles=start_roles)

Reapplies a host template on all the hosts associated with the host template.

Reapplies a host template on all the hosts associated with the host template. This will run apply host template command on the all the hosts using the host template .

Set deleteRoles to true to delete the roles on the associated hosts if RCG is missing from host template. Check host tags with name as _cldr_cm_host_template_name to find out hosts using with the host template.

Available since API v46.

Example

from __future__ import print_function
import time
import cm_client
from cm_client.rest import ApiException
from pprint import pprint
# Configure HTTP basic authorization: basic
configuration = cm_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = cm_client.HostTemplatesResourceApi(cm_client.ApiClient(configuration))
cluster_name = 'cluster_name_example' # str | 
host_template_name = 'host_template_name_example' # str | Host template to apply.
delete_roles = true # bool | Whether to delete roles on host if RCG is deleted from host template . (optional)
start_roles = true # bool | Whether to start the newly created roles or not. (optional)

try:
    # Reapplies a host template on all the hosts associated with the host template.
    api_response = api_instance.reapply_host_template_on_hosts(cluster_name, host_template_name, delete_roles=delete_roles, start_roles=start_roles)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostTemplatesResourceApi->reapply_host_template_on_hosts: %s\n" % e)

Parameters

Name Type Description Notes
cluster_name str
host_template_name str Host template to apply.
delete_roles bool Whether to delete roles on host if RCG is deleted from host template . [optional]
start_roles bool Whether to start the newly created roles or not. [optional]

Return type

ApiCommand

Authorization

basic

HTTP request headers

[Back to top] [Back to API list] [Back to Model list] [Back to README]

update_host_template

ApiHostTemplate update_host_template(cluster_name, host_template_name, body=body)

Updates an existing host template.

Updates an existing host template.

Can be used to update the role config groups in a host template or rename it.

Available since API v3.

Example

from __future__ import print_function
import time
import cm_client
from cm_client.rest import ApiException
from pprint import pprint
# Configure HTTP basic authorization: basic
configuration = cm_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = cm_client.HostTemplatesResourceApi(cm_client.ApiClient(configuration))
cluster_name = 'cluster_name_example' # str | 
host_template_name = 'host_template_name_example' # str | Host template with updated fields.
body = cm_client.ApiHostTemplate() # ApiHostTemplate |  (optional)

try:
    # Updates an existing host template.
    api_response = api_instance.update_host_template(cluster_name, host_template_name, body=body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostTemplatesResourceApi->update_host_template: %s\n" % e)

Parameters

Name Type Description Notes
cluster_name str
host_template_name str Host template with updated fields.
body ApiHostTemplate [optional]

Return type

ApiHostTemplate

Authorization

basic

HTTP request headers

[Back to top] [Back to API list] [Back to Model list] [Back to README]