cm_client.HostsResourceApi

All URIs are relative to https://localhost/api/v40

Method HTTP request Description
create_hosts POST /hosts .
delete_all_hosts DELETE /hosts Delete all hosts in the system.
delete_host DELETE /hosts/{hostId} Delete a host from the system.
enter_maintenance_mode POST /hosts/{hostId}/commands/enterMaintenanceMode Put the host into maintenance mode.
exit_maintenance_mode POST /hosts/{hostId}/commands/exitMaintenanceMode Take the host out of maintenance mode.
generate_host_certs POST /hosts/{hostId}/commands/generateHostCerts Generates (or regenerates) a key and certificate for this host if Auto-TLS is enabled.
get_metrics GET /hosts/{hostId}/metrics Fetch metric readings for a host.
migrate_roles POST /hosts/{hostId}/commands/migrateRoles Migrate roles to a different host.
read_host GET /hosts/{hostId} Returns a specific Host in the system.
read_host_config GET /hosts/{hostId}/config Retrieves the configuration of a specific host.
read_hosts GET /hosts Returns hosts in the system filtered by optional host configuration parameters, if specified.
reset_host_id POST /hosts/{hostId}/commands/resetHostId Forces agent on specified host to switch to reporting a different host id.
update_host PUT /hosts/{hostId} .
update_host_config PUT /hosts/{hostId}/config Updates the host configuration with the given values.

create_hosts

ApiHostList create_hosts(body=body)

.

Create one or more hosts.

You must specify at least the hostname and ipAddress in the request objects. If no hostId is specified, it will be set to the hostname. It is an error to try and create host with the same hostId as another host.

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.HostsResourceApi(cm_client.ApiClient(configuration))
body = cm_client.ApiHostList() # ApiHostList | The list of hosts to create (optional)

try:
    # .
    api_response = api_instance.create_hosts(body=body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->create_hosts: %s\n" % e)

Parameters

Name Type Description Notes
body ApiHostList The list of hosts to create [optional]

Return type

ApiHostList

Authorization

basic

HTTP request headers

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

delete_all_hosts

ApiHostList delete_all_hosts()

Delete all hosts in the system.

Delete all hosts in the system

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.HostsResourceApi(cm_client.ApiClient(configuration))

try:
    # Delete all hosts in the system.
    api_response = api_instance.delete_all_hosts()
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->delete_all_hosts: %s\n" % e)

Parameters

This endpoint does not need any parameter.

Return type

ApiHostList

Authorization

basic

HTTP request headers

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

delete_host

ApiHost delete_host(host_id)

Delete a host from the system.

Delete a host from the system

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The ID of the host to remove

try:
    # Delete a host from the system.
    api_response = api_instance.delete_host(host_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->delete_host: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The ID of the host to remove

Return type

ApiHost

Authorization

basic

HTTP request headers

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

enter_maintenance_mode

ApiCommand enter_maintenance_mode(host_id)

Put the host into maintenance mode.

Put the host into maintenance mode. This is a synchronous command. The result is known immediately upon return.

Available since API v2.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The ID of the host

try:
    # Put the host into maintenance mode.
    api_response = api_instance.enter_maintenance_mode(host_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->enter_maintenance_mode: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The ID of the host

Return type

ApiCommand

Authorization

basic

HTTP request headers

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

exit_maintenance_mode

ApiCommand exit_maintenance_mode(host_id)

Take the host out of maintenance mode.

Take the host out of maintenance mode. This is a synchronous command. The result is known immediately upon return.

Available since API v2.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The ID of the host

try:
    # Take the host out of maintenance mode.
    api_response = api_instance.exit_maintenance_mode(host_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->exit_maintenance_mode: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The ID of the host

Return type

ApiCommand

Authorization

basic

HTTP request headers

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

generate_host_certs

ApiCommand generate_host_certs(host_id, body=body)

Generates (or regenerates) a key and certificate for this host if Auto-TLS is enabled.

Generates (or regenerates) a key and certificate for this host if Auto-TLS is enabled.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The ID of the host to generate a certificate for.
body = cm_client.ApiGenerateHostCertsArguments() # ApiGenerateHostCertsArguments |  (optional)

try:
    # Generates (or regenerates) a key and certificate for this host if Auto-TLS is enabled.
    api_response = api_instance.generate_host_certs(host_id, body=body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->generate_host_certs: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The ID of the host to generate a certificate for.
body ApiGenerateHostCertsArguments [optional]

Return type

ApiCommand

Authorization

basic

HTTP request headers

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

get_metrics

ApiMetricList get_metrics(host_id, _from=_from, ifs=ifs, metrics=metrics, query_nw=query_nw, query_storage=query_storage, storage_ids=storage_ids, to=to, view=view)

Fetch metric readings for a host.

Fetch metric readings for a host.

By default, this call will look up all metrics available for the host. If only specific metrics are desired, use the metrics parameter.

By default, the returned results correspond to a 5 minute window based on the provided end time (which defaults to the current server time). The from and to parameters can be used to control the window being queried. A maximum window of 3 hours is enforced.

When requesting a "full" view, aside from the extended properties of the returned metric data, the collection will also contain information about all metrics available for the role, even if no readings are available in the requested window.

Host metrics also include per-network interface and per-storage device metrics. Since collecting this data incurs in more overhead, query parameters can be used to choose which network interfaces and storage devices to query, or to these metrics altogether.

Storage metrics are collected at different levels; for example, per-disk and per-partition metrics are available. The "storageIds" parameter can be used to filter specific storage IDs.

In the returned data, the network interfaces and storage IDs can be identified by looking at the "context" property of the metric objects.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The host's ID.
_from = '_from_example' # str | Start of the period to query. (optional)
ifs = ['ifs_example'] # list[str] | Network interfaces to query for metrics (default = all). (optional)
metrics = ['metrics_example'] # list[str] | Filter for which metrics to query. (optional)
query_nw = true # bool | Whether to query for network interface metrics. (optional) (default to true)
query_storage = true # bool | Whether to query for storage metrics. (optional) (default to true)
storage_ids = ['storage_ids_example'] # list[str] | Storage context IDs to query for metrics (default = all). (optional)
to = 'now' # str | End of the period to query. (optional) (default to now)
view = 'summary' # str | The view of the data to materialize, either \"summary\" or \"full\". (optional) (default to summary)

try:
    # Fetch metric readings for a host.
    api_response = api_instance.get_metrics(host_id, _from=_from, ifs=ifs, metrics=metrics, query_nw=query_nw, query_storage=query_storage, storage_ids=storage_ids, to=to, view=view)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->get_metrics: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The host's ID.
_from str Start of the period to query. [optional]
ifs list[str] Network interfaces to query for metrics (default = all). [optional]
metrics list[str] Filter for which metrics to query. [optional]
query_nw bool Whether to query for network interface metrics. [optional] [default to true]
query_storage bool Whether to query for storage metrics. [optional] [default to true]
storage_ids list[str] Storage context IDs to query for metrics (default = all). [optional]
to str End of the period to query. [optional] [default to now]
view str The view of the data to materialize, either "summary" or "full". [optional] [default to summary]

Return type

ApiMetricList

Authorization

basic

HTTP request headers

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

migrate_roles

ApiCommand migrate_roles(host_id, body=body)

Migrate roles to a different host.

Migrate roles to a different host.

This command applies only to HDFS NameNode, JournalNode, and Failover Controller roles. In order to migrate these roles:

Migrating a NameNode or JournalNode role requires cluster downtime. HDFS, along with all of its dependent services, will be stopped at the beginning of the migration process, and restarted at its conclusion.

If the active NameNode is selected for migration, a manual failover will be performed before the role is migrated. The role will remain in standby mode after the migration is complete.

When migrating a NameNode role, the co-located Failover Controller role must be migrated as well if automatic failover is enabled. The Failover Controller role name must be included in the list of role names to migrate specified in the arguments to this command (it will not be included implicitly). This command does not allow a Failover Controller role to be moved by itself, although it is possible to move a JournalNode independently.

Available since API v10.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The ID of the host on which the roles to migrate currently reside
body = cm_client.ApiMigrateRolesArguments() # ApiMigrateRolesArguments | Arguments for the command. (optional)

try:
    # Migrate roles to a different host.
    api_response = api_instance.migrate_roles(host_id, body=body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->migrate_roles: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The ID of the host on which the roles to migrate currently reside
body ApiMigrateRolesArguments Arguments for the command. [optional]

Return type

ApiCommand

Authorization

basic

HTTP request headers

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

read_host

ApiHost read_host(host_id, view=view)

Returns a specific Host in the system.

Returns a specific Host in the system.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The ID of the host to read.
view = 'full' # str | The view to materialize. Defaults to 'full'. (optional) (default to full)

try:
    # Returns a specific Host in the system.
    api_response = api_instance.read_host(host_id, view=view)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->read_host: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The ID of the host to read.
view str The view to materialize. Defaults to 'full'. [optional] [default to full]

Return type

ApiHost

Authorization

basic

HTTP request headers

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

read_host_config

ApiConfigList read_host_config(host_id, view=view)

Retrieves the configuration of a specific host.

Retrieves the configuration of a specific host.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The ID of the host.
view = 'summary' # str | The view of the data to materialize, either \"summary\" or \"full\". (optional) (default to summary)

try:
    # Retrieves the configuration of a specific host.
    api_response = api_instance.read_host_config(host_id, view=view)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->read_host_config: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The ID of the host.
view str The view of the data to materialize, either "summary" or "full". [optional] [default to summary]

Return type

ApiConfigList

Authorization

basic

HTTP request headers

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

read_hosts

ApiHostList read_hosts(config_name=config_name, config_value=config_value, view=view)

Returns hosts in the system filtered by optional host configuration parameters, if specified.

Returns hosts in the system filtered by optional host configuration parameters, if specified.

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.HostsResourceApi(cm_client.ApiClient(configuration))
config_name = 'config_name_example' # str | Optional host config name to filter hosts by. Available from v40. (optional)
config_value = 'config_value_example' # str | host config value associated with config name. Available from v40. (optional)
view = 'summary' # str | The view to materialize (optional) (default to summary)

try:
    # Returns hosts in the system filtered by optional host configuration parameters, if specified.
    api_response = api_instance.read_hosts(config_name=config_name, config_value=config_value, view=view)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->read_hosts: %s\n" % e)

Parameters

Name Type Description Notes
config_name str Optional host config name to filter hosts by. Available from v40. [optional]
config_value str host config value associated with config name. Available from v40. [optional]
view str The view to materialize [optional] [default to summary]

Return type

ApiHostList

Authorization

basic

HTTP request headers

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

reset_host_id

ApiCommand reset_host_id(host_id, new_host_id=new_host_id)

Forces agent on specified host to switch to reporting a different host id.

Forces agent on specified host to switch to reporting a different host id.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The ID of the host that should be affected.
new_host_id = 'new_host_id_example' # str | New ID the the host should report. (optional)

try:
    # Forces agent on specified host to switch to reporting a different host id.
    api_response = api_instance.reset_host_id(host_id, new_host_id=new_host_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->reset_host_id: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The ID of the host that should be affected.
new_host_id str New ID the the host should report. [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

ApiHost update_host(host_id, body=body)

.

Update an existing host in the system.

Currently, only updating the rackId is supported. All other fields of the host will be ignored.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The hostId to update
body = cm_client.ApiHost() # ApiHost | The updated host object. (optional)

try:
    # .
    api_response = api_instance.update_host(host_id, body=body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->update_host: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The hostId to update
body ApiHost The updated host object. [optional]

Return type

ApiHost

Authorization

basic

HTTP request headers

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

update_host_config

ApiConfigList update_host_config(host_id, message=message, body=body)

Updates the host configuration with the given values.

Updates the host configuration with the given values.

If a value is set in the given configuration, it will be added to the host's configuration, replacing any existing entries. If a value is unset (its value is null), the existing configuration for the attribute will be erased, if any.

Attributes that are not listed in the input will maintain their current values in the configuration.

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.HostsResourceApi(cm_client.ApiClient(configuration))
host_id = 'host_id_example' # str | The ID of the host.
message = 'message_example' # str | Optional message describing the changes. (optional)
body = cm_client.ApiConfigList() # ApiConfigList | Configuration changes. (optional)

try:
    # Updates the host configuration with the given values.
    api_response = api_instance.update_host_config(host_id, message=message, body=body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling HostsResourceApi->update_host_config: %s\n" % e)

Parameters

Name Type Description Notes
host_id str The ID of the host.
message str Optional message describing the changes. [optional]
body ApiConfigList Configuration changes. [optional]

Return type

ApiConfigList

Authorization

basic

HTTP request headers

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