ceph.ceph_admin.host module

Cephadm orchestration host operations.

class ceph.ceph_admin.host.Host(cluster, **config)

Bases: MaintenanceMixin, Orch

Interface for executing ceph host <options> operations.

SERVICE_NAME = 'host'
add(config)

Add host to cluster

Parameters

config (Dict) – host addition configuration

Example:

config:
    service: host
    command: add
    base_cmd_args:                          # arguments to ceph orch
        concise: true
        block: true
    args:
        node: "node2"                         # node-name or object
        attach_ip_address: bool               # true or false
        labels: [mon, osd] or apply-all-labels

add_label: host added with labels(roles assigned are considered)
attach_address: host added with ip address(host ip address used)

labels are considered if list of strings are provided or all roles associated
with node will be considered if string "apply-all-labels"
add_hosts(config)

Add host(s) to cluster.

  • Attach host to cluster

  • if nodes are empty, all nodes in cluster are considered

  • add_label: host added with labels(roles assigned are considered)

  • attach_address: host added with ip address(host ip address used)

  • by default add_label and attach_address are set to True

Parameters

config (Dict) – hosts configuration

Example:

config:
    base_cmd_args:
        concise: true
        block: true
    args:
        nodes: ["node1", "node2", ...]
        labels: [mon, osd] or apply-all-labels
        attach_ip_address: boolean
fetch_host_names()

Returns host-names attached to a cluster

Returns

list of host names (List)

fetch_labels_by_hostname(node_name)

Fetch labels attach to a node by hostname

Returns

list of labels

Return type

labels (List)

get_addr_by_name(node_name)

Returns ip address of attached node using hostname

Parameters

node_name (Str) – node name

Returns

IP address of host name

Return type

ip_address (Str)

get_addrs()

Returns IP addresses of hosts attached to a cluster

Returns

list of IP addresses (List)

get_host(hostname: str)

Fetches the host with given hostname is deployed in the cluster.

Parameters

hostname (str) – hostname of the host to be verified

Returns

host with the given hostname

get_host_status(hostname) str

Fetches the status of the host with given hostname as present in ceph orch host ls output

Parameters

hostname – hostname of the host whose status needs to be fetched

Returns

status of the host as given in ceph orch host ls output

label_add(config)

Add/Attach label to nodes

  • Attach labels to existing nodes

  • if nodes are empty, all cluster nodes are considered

  • roles defined to each node used as labels( eg., [mon, mgr])

Parameters

config (Dict) – label add configuration

Example:

config:
    service: host
    command: label_add
    base_cmd_args:
        verbose: true
    args:
        node: node1
        labels:
            - mon
            - osd
label_remove(config)

Removes label from nodes

  • remove labels from existing nodes

  • if nodes are empty, all cluster nodes are considered

Parameters

config (Dict) – label remove configuration

Example:

config:
    service: host
    command: label_remove
    base_cmd_args:
        verbose: true
    args:
        node: node1
        labels:
            - mon
            - osd
list()

List the cluster hosts

Returns

json output of hosts list (List)

remove(config)

Remove host from cluster

Parameters

config (Dict) – Remove host configuration

Example:

config:
    service: host
    command: remove
    base_cmd_args:
      verbose: true                        # arguments to ceph orch
    args:
      node: "node2"                         # node-name or object
remove_hosts(config)

Remove host(s) from cluster

  • Removal of hosts from cluster with provided nodes

  • if nodes are empty, all cluster nodes are considered

  • Otherwise all node will be considered, except Installer node

Parameters

config (Dict) – Remove hosts configuration

Example:

config:
    args:
        nodes: ["node1", "node2", ...]
set_address(config)

Set IP address to node

  • Attach address to existing nodes

Parameters

config (Dict) – set address configuration

Example:

config:
    service: host
    command: set_address
    base_cmd_args:
        verbose: true
    args:
        node: node1
exception ceph.ceph_admin.host.HostOpFailure

Bases: Exception