ceph.ceph_admin.helper module

Contains helper functions that can used across the module.

class ceph.ceph_admin.helper.GenerateServiceSpec(node, cluster, specs)

Bases: object

Creates the spec yaml file for deploying services and daemons using cephadm.

COMMON_SERVICES = ['mon', 'mgr', 'alertmanager', 'crash', 'grafana', 'node-exporter', 'prometheus']
create_snmp_conf_file()

Create snmp conf file based on spec config and return file name

Returns

temp_filename (Str)

create_spec_file()

Create spec file based on spec config and return file name

Returns

temp_filename (Str)

generate_generic_spec(spec)

Return spec content for common services which is mentioned in COMMON_SERVICES:

- mon
- mgr
- alertmanager
- crash
- grafana
- node-exporter
- prometheus
Parameters

spec (Dict) – common service spec config

Returns

service_spec

Example:

spec:
  - service_type: mon
    unmanaged: boolean    # true or false
    placement:
      count: 2
      label: "mon"
      host_pattern: "*"   # either hosts or host_pattern
      nodes:
        - node2
        - node3
generate_host_spec(spec)

Return hosts spec content based on host config

Parameters

spec (Dict) – hosts specification

Returns

hosts_spec (Str)

Example:

spec:
  - service_type: host
    address: true
    labels: apply-all-labels
    nodes:
        - node2
        - node3
generate_ingress_spec(spec)

Return spec content for ha proxy ingress service

Parameters

spec (Dict) – ha proxy ingress service spec config

Returns

service_spec (Str)

Example:

spec:
  - service_type: ingress
    service_id: rgw.my-rgw
    unmanaged: boolean    # true or false
    placement:
      host_pattern: "*"   # either hosts or host_pattern
      nodes:
        - node2
        - node3
      label: rgw
    spec:
      backend_service: rgw.ceph-scale-test-y7nmci-node2
      virtual_ip: 10.0.208.0/22
      frontend_port: 8000
      monitor_port: 1967
Note

make sure rgw service is already created.

generate_mds_spec(spec)

Return spec content for mds service

Parameters

spec (Dict) – mds service spec config

Returns

service_spec (Str)

Example:

spec:
  - service_type: mds
    service_id: cephfs
    unmanaged: boolean    # true or false
    placement:
      host_pattern: "*"   # either hosts or host_pattern
      nodes:
        - node2
        - node3
      label: mds
Note

make sure volume is already created.

generate_nfs_spec(spec)

Return spec content for nfs service

Parameters

spec (Dict) – mds service spec config

Returns

service_spec (Str)

Example:

spec:
  - service_type: nfs
    service_id: nfs-name
    unmanaged: boolean    # true or false
    placement:
      host_pattern: "*"   # either hosts or host_pattern
      nodes:
        - node2
        - node3
      label: nfs
    spec:
      pool: pool-name
      namespace: namespace-name
Note

make sure pool is already created.

generate_osd_spec(spec)

Return spec content for osd service

Parameters

spec (Dict) – osd service spec config

Returns

service_spec (Str)

Example:

spec:
  - service_type: osd
    unmanaged: boolean    # true or false
    placement:
      host_pattern: "*"   # either hosts or host_pattern
      nodes:
        - node2
        - node3
    data_devices:
        all: boolean      # true or false
    encrypted: boolean    # true or false
generate_rgw_spec(spec)

Return spec content for rgw service

Parameters

spec (Dict) – rgw service spec config

Returns

service_spec (Str)

Example:

spec:
  - service_type: rgw
    service_id: my-rgw
    unmanaged: boolean    # true or false
    placement:
      host_pattern: "*"   # either hosts or host_pattern
      nodes:
        - node2
        - node3
      label: rgw
    spec:
      rgw_frontend_port: 8080
      rgw_realm: east
      rgw_zone: india
      rgw_frontend_ssl_certificate: create-cert | <contents of crt>

contents of rgw_spec.yaml file

    service_type: rgw
    service_id: rgw.india
    placement:
      hosts:
        - node5
    spec:
      ssl: true
      rgw_frontend_ssl_certificate: |
        -----BEGIN PRIVATE KEY------
        ...
Note

make sure realm, zone group and zone is already created.

generate_snmp_dest_conf(spec)

Return conf content for snmp-gateway service

Parameters

spec (Dict) – snmp-gateway service config

Returns

destination_conf (Str)

Example:

spec:
    - service_type: snmp-gateway
      service_name: snmp-gateway
      placement:
        count: 1
      spec:
        credentials:
          snmp_v3_auth_username: <user_name>
          snmp_v3_auth_password: <password>
        port: 9464
        snmp_destination: node
        snmp_version: V3
generate_snmp_spec(spec)

Return spec content for snmp-destination

Parameters

spec (Dict) – snmp-destination service spec config

Returns

service_spec (Str)

Example:

specs:
  • service_type: snmp-destination spec:

    credentials:

    snmp_v3_auth_username: myadmin snmp_v3_auth_password: mypassword

static get_addr(node)

Returns IP Address of node

Parameters

node (CephNode) – node object

Returns

IP Address (Str)

static get_hostname(node)

Returns Host Name of node

Parameters

node (CephNode) – node object

Returns

hostname (Str)

get_hostnames(node_names)

Return list of hostnames

Parameters

node_names (List) – node names

Returns

list of hostanmes (List)

static get_labels(node)

Returns role list of node

Parameters

node (CephNode) – node object

Returns

node role list (List)

exception ceph.ceph_admin.helper.UnknownSpecFound

Bases: Exception

ceph.ceph_admin.helper.create_ceph_config_file(node, config)

Create config file based on config options and return file name

Returns

temp_filename (Str)

ceph.ceph_admin.helper.file_or_path_exists(node, file_or_path)

Method to check abs path exists.

Parameters
  • node – node object where file should be exists

  • file_or_path – ceph file or directory path

Returns

boolean

ceph.ceph_admin.helper.get_cluster_state(cls, commands=None)

fetch cluster state using commands provided along with the default set of commands:

- ceph status
- ceph orch ls -f json-pretty
- ceph orch ps -f json-pretty
- ceph health detail -f yaml
Parameters
  • cls (CephAdmin) – ceph.ceph_admin instance with shell access

  • commands (List) – list of commands

ceph.ceph_admin.helper.get_host_daemon_map(cls)

Method to get the daemons deployed in each of the hosts :param cls: cephadm instance object

Returns

Dictionary with host names as keys and names of the daemons deployed as value list

ceph.ceph_admin.helper.get_host_osd_map(cls)

Method to get the OSDs deployed in each of the hosts :param cls: cephadm instance object

Returns

Dictionary with host names as keys and osds deployed as value list

ceph.ceph_admin.helper.get_hosts_deployed(cls)

Method to get all the hosts deployed in the cluster :param cls: cephadm instance object

Returns

List of the names of hosts deployed in the cluster

ceph.ceph_admin.helper.monitoring_file_existence(node, file_or_path, file_exist=True, timeout=180)

Method to monitor a file existence.

Parameters
  • node – node object where file should be exists

  • file_or_path – ceph file or directory path

  • file_exist – checks file existence (default =True)

  • timeout (Int) – In seconds, the maximum allowed time (default=180)

Returns

boolean

ceph.ceph_admin.helper.validate_log_file_after_enable(cls)

Verify generation of log files in default log directory when logging not enabled.

Parameters

cls – cephadm instance object

Returns

boolean