Package cm_api :: Package endpoints :: Module hosts :: Class ApiHost
[hide private]
[frames] | no frames]

Class ApiHost

source code

         object --+        
                  |        
types.BaseApiObject --+    
                      |    
  types.BaseApiResource --+
                          |
                         ApiHost

Instance Methods [hide private]
 
__init__(self, resource_root, hostId=None, hostname=None, ipAddress=None, rackId=None)
Initializes internal state and sets all known writable properties of the object to None.
source code
 
__str__(self)
Default implementation of __str__.
source code
 
_path(self)
Returns the path to the resource.
source code
 
_put_host(self)
Update this resource.
source code
 
get_config(self, view=None)
Retrieve the host's configuration.
source code
 
update_config(self, config)
Update the host's configuration.
source code
 
get_metrics(self, from_time=None, to_time=None, metrics=None, ifs=[], storageIds=[], view=None)
This endpoint is not supported as of v6.
source code
 
enter_maintenance_mode(self)
Put the host in maintenance mode.
source code
 
exit_maintenance_mode(self)
Take the host out of maintenance mode.
source code
 
migrate_roles(self, role_names_to_migrate, destination_host_id, clear_stale_role_data)
Migrate roles from this host to a different host.
source code
 
set_rack_id(self, rackId)
Update the rack ID of this host.
source code

Inherited from types.BaseApiObject: __setattr__, to_json_dict

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from types.BaseApiObject: from_json_dict

Inherited from types.BaseApiObject (private): _get_attributes

Static Methods [hide private]

Inherited from types.BaseApiObject: init

Class Variables [hide private]
  _ATTRIBUTES = {'hostId': None, 'hostname': None, 'ipAddress': ...

Inherited from types.BaseApiObject (private): _WHITELIST

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, resource_root, hostId=None, hostname=None, ipAddress=None, rackId=None)
(Constructor)

source code 

Initializes internal state and sets all known writable properties of the object to None. Then initializes the properties given in the provided attributes dictionary.

Parameters:
  • resource_root - API resource object.
  • attrs - optional dictionary of attributes to set. This should only contain r/w attributes.
Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

Default implementation of __str__. Uses the type name and the first attribute retrieved from the attribute map to create the string.

Overrides: object.__str__
(inherited documentation)

_path(self)

source code 

Returns the path to the resource.

e.g., for a service 'foo' in cluster 'bar', this should return '/clusters/bar/services/foo'.

Overrides: types.BaseApiResource._path
(inherited documentation)

_put_host(self)

source code 

Update this resource.

Returns:
The updated object.

get_config(self, view=None)

source code 

Retrieve the host's configuration.

The 'summary' view contains strings as the dictionary values. The full view contains ApiConfig instances as the values.

Parameters:
  • view - View to materialize ('full' or 'summary')
Returns:
Dictionary with configuration data.

update_config(self, config)

source code 

Update the host's configuration.

Parameters:
  • config - Dictionary with configuration to update.
Returns:
Dictionary with updated configuration.

get_metrics(self, from_time=None, to_time=None, metrics=None, ifs=[], storageIds=[], view=None)

source code 

This endpoint is not supported as of v6. Use the timeseries API instead. To get all metrics for a host with the timeseries API use the query:

'select * where hostId = $HOST_ID'.

To get specific metrics for a host use a comma-separated list of the metric names as follows:

'select $METRIC_NAME1, $METRIC_NAME2 where hostId = $HOST_ID'.

For more information see http://tiny.cloudera.com/tsquery_doc

Parameters:
  • from_time - A datetime; start of the period to query (optional).
  • to_time - A datetime; end of the period to query (default = now).
  • metrics - List of metrics to query (default = all).
  • ifs - network interfaces to query. Default all, use None to disable.
  • storageIds - storage IDs to query. Default all, use None to disable.
  • view - View to materialize ('full' or 'summary')
Returns:
List of metrics and their readings.

enter_maintenance_mode(self)

source code 

Put the host in maintenance mode.

Returns:
Reference to the completed command.

Since: API v2

exit_maintenance_mode(self)

source code 

Take the host out of maintenance mode.

Returns:
Reference to the completed command.

Since: API v2

migrate_roles(self, role_names_to_migrate, destination_host_id, clear_stale_role_data)

source code 

Migrate roles from this host to a different host.

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

  • HDFS High Availability must be enabled, using quorum-based storage.
  • HDFS must not be configured to use a federated nameservice.

Migrating a NameNode 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. 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.

Parameters:
  • role_names_to_migrate - list of role names to migrate.
  • destination_host_id - the id of the host to which the roles should be migrated.
  • clear_stale_role_data - true to delete existing stale role data, if any. For example, when migrating a NameNode, if the destination host has stale data in the NameNode data directories (possibly because a NameNode role was previously located there), this stale data will be deleted before migrating the role.
Returns:
Reference to the submitted command.

Since: API v10


Class Variable Details [hide private]

_ATTRIBUTES

Value:
{'hostId': None, 'hostname': None, 'ipAddress': None, 'rackId': None, \
'status': ROAttr(), 'lastHeartbeat': ROAttr(datetime.datetime), 'roleR\
efs': ROAttr(ApiRoleRef), 'healthSummary': ROAttr(), 'healthChecks': R\
OAttr(), 'hostUrl': ROAttr(), 'commissionState': ROAttr(), 'maintenanc\
eMode': ROAttr(), 'maintenanceOwners': ROAttr(), 'numCores': ROAttr(),\
 'numPhysicalCores': ROAttr(), 'totalPhysMemBytes': ROAttr(), 'entityS\
tatus': ROAttr(), 'clusterRef': ROAttr(ApiClusterRef),}