ceph.utils module

ceph.utils.check_ceph_healthly(ceph_mon, num_osds, num_mons, build, mon_container=None, timeout=300)

Function to check ceph is in healthy state

Parameters
  • ceph_mon – monitor node

  • num_osds – number of osds in cluster

  • num_mons – number of mons in cluster

  • build – rhcs build version

  • mon_container – monitor container name if monitor is placed in the container

  • timeout – 300 seconds(default) max time to check

Note

if cluster is not healthy within timeout period return 1

Returns

return 0 when ceph is in healthy state, else 1

ceph.utils.cleanup_ceph_nodes(osp_cred, pattern=None, timeout=300)
ceph.utils.cleanup_ibmc_ceph_nodes(ibm_cred, pattern)

Clean up the DNS records, instance and volumes that matches the given pattern.

Parameters
  • file (ibm_cred global configuration) –

  • name (pattern pattern to match instance) –

ceph.utils.config_ntp(ceph_node, cloud_type='openstack')

Configure NTP/Chronyc service based on the OS platform

Parameters
  • ceph_node – Ceph Node

  • cloud_type – IaaS provider

ceph.utils.create_baremetal_ceph_nodes(cluster_conf)

Creates the nodes with cluster details provided

Parameters

cluster_conf (dict) – Information regarding the participating cluster

Returns

List of CephNode

ceph.utils.create_ceph_conf(fsid, mon_hosts, pg_num='128', pgp_num='128', size='2', auth='cephx', pnetwork='172.16.0.0/12', jsize='1024')
ceph.utils.create_ceph_nodes(cluster_conf, inventory, osp_cred, run_id, instances_name=None, enable_eus=False)
ceph.utils.create_ibmc_ceph_nodes(cluster_conf, inventory, ibm_creds, run_id, instances_name=None)

creates instances in IBM cloud

Parameters
  • cluster (cluster_conf configuration of) –

  • file (ibm_creds global configuration) –

  • file

  • run (run_id unique id for the) –

  • instance (instances_name Name of the) –

ceph.utils.fetch_build(version, custom_build)

Fetch build details based on the custom build :param version: rhceph version :param custom_build:

Returns

ceph image and compose

custom_build:

latest_build: latest ceph image to be considered last_previous_build: last but one ceph image(n-1)

todo: Fix when upgrade scenario needs image from source path

ceph.utils.fetch_image_builds(version)

Fetch ceph container image builds

  1. Search Share path for ceph image under DEFAULT_OSBS_SERVER

  2. look for particular RHCS version json files.

  3. Sort builds based on timestamp and return builds.

todo: Fix when upgrade scenario needs image from source path

ceph.utils.generate_repo_file(base_url, repos)
ceph.utils.get_ceph_versions(ceph_nodes, containerized=False)

Log and return the ceph or ceph-ansible versions for each node in the cluster.

Parameters
  • ceph_nodes – nodes in the cluster

  • containerized – is the cluster containerized or not

Returns

A dict of the name / version pair for each node or container in the cluster

ceph.utils.get_disk_info(node)

Get node disk(s) info

Parameters

node – remote node object

Returns

remote disk details

Return type

disks

ceph.utils.get_iso_file_url(base_url)
ceph.utils.get_node_by_id(cluster, node_name)

Fetch node using provided node substring:

As per the naming convention used at VM creation, where each node.shortname
is framed with hyphen("-") separated string as below, please refer
ceph.utils.create_ceph_nodes definition
    "ceph-<name>-node1-<roles>"

    name: RHOS-D username or provided --instances-name
    roles: roles attached to node in inventory file

In this method we use hyphen("-") appended to node_name string to try fetch exact node.
for example,
    "node1" ----> "node1-"

Note: But however if node_name doesn't follow naming convention as mentioned in
inventory, the first searched node will be returned.
for example,
    "node" ----> it might return any node which matched first, like node11.

return None, If this cluster has no nodes with this substring.
Parameters
  • cluster – ceph object

  • node_name – node1 # try to use node<Id>

Returns

node instance (CephVMNode)

ceph.utils.get_nodes_by_ids(cluster, node_names)

Fetch nodes using provided substring of nodes

Returns node list which matched node ID(eg., ‘node1’) else all nodes object list if node_names is empty.

Parameters
  • cluster – ceph object

  • node_names – node name list (eg., [‘node1’])

Returns

list of nodes

Return type

node_list

ceph.utils.get_openstack_driver(yaml)
ceph.utils.get_public_network(nodes)

Get the configured public network subnet from nodes in the cluster.

Parameters

nodes – cluster nodes

Returns

(str) public network subnet(s)

ceph.utils.get_root_permissions(node, path)

Transfer ownership of root to current user for the path given. Recursive. :param node: :type node: ceph.ceph.CephNode :param path: file path

ceph.utils.hard_reboot(gyaml, name=None)
ceph.utils.keep_alive(ceph_nodes)
ceph.utils.node_power_failure(gyaml, sleep_time=300, name=None)
ceph.utils.search_ethernet_interface(ceph_node, ceph_node_list)

Search interface on the given node node which allows every node in the cluster accesible by it’s shortname.

Parameters
  • ceph_node (ceph.ceph.CephNode) – node where check is performed

  • ceph_node_list (list) – node list to check

ceph.utils.set_container_info(ceph_cluster, config, use_cdn, containerized)

Set container information in ansible configuration :param ceph_cluster: ceph cluster object :param use_cdn: boolean to check CDN :param config: test config :param containerized: boolean indicates containerized build.

Returns

ansi_config

ceph.utils.setup_deb_cdn_repo(node, build=None)
ceph.utils.setup_deb_repos(node, ubuntu_repo)
ceph.utils.setup_repos(ceph, base_url, installer_url=None)
ceph.utils.setup_vm_node(node, ceph_nodes, **params)

Create the VM node using OpenStack API calls.

The retry decorator will trigger a rerun when a soft error is encountered. The VM node is removed in exception scope before throwing raising the exception again.

ceph.utils.setup_vm_node_baremetal(node, ceph_nodes, **params)

Create the VM node using details provided.

ceph.utils.setup_vm_node_ibm(node, ceph_nodes, **params)

Create the VM node using IBM API calls.

The retry decorator will trigger a rerun when a soft error is encountered. The VM node is removed in exception scope before throwing raising the exception again.

ceph.utils.translate_to_ip(clusters, cluster_name: str, string: str) str

Return the string after replacing node_ip: <node> pattern with IP address of <node>.

In this method, the pattern {node_ip:<cluster>#<node>} would be replaced with the value of node.ipaddress.

Parameters
  • clusters – Ceph cluster instance

  • cluster_name – Name of the cluster under test.

  • string – String that needs to be searched

Returns

String with node IDs replaced with IP addresses

ceph.utils.update_ca_cert(node, cert_url, out_file, timeout=120, check_ec=True)
Update CA cert in the nodes.

by default options picked for RHEL platforms

Parameters
  • node – node object

  • cert_url – path to download certificate

  • out_file – output file name

  • timeout – timeout in seconds

  • check_ec – bool by default true, checks the error code

ceph.utils.volume_cleanup(volume, osp_cred)