Auto-generated documentation for ocs_ci.ocs.resources.pod module.
Pod related functionalities and context info
- Ocs-ci / Modules / Ocs Ci / Ocs / Resources / Pod
- Pod
- Pod().add_role
- Pod().copy_to_server
- Pod().exec_bash_cmd_on_pod
- Pod().exec_ceph_cmd
- Pod().exec_cmd_on_node
- Pod().exec_cmd_on_pod
- Pod().get_fio_results
- Pod().get_labels
- Pod().get_storage_path
- Pod().install_packages
- Pod().labels
- Pod().name
- Pod().namespace
- Pod().roles
- Pod().run_git_clone
- Pod().run_io
- Pod().workload_setup
- cal_md5sum
- check_file_existence
- delete_pods
- get_admin_key_from_ceph_tools
- get_all_pods
- get_ceph_tools_pod
- get_cephfs_provisioner_pod
- get_cephfsplugin_provisioner_pods
- get_file_path
- get_fio_rw_iops
- get_mds_pods
- get_mgr_pods
- get_mon_pods
- get_operator_pods
- get_osd_pods
- get_plugin_pods
- get_pod_count
- get_pod_logs
- get_pod_node
- get_pod_obj
- get_pods_having_label
- get_pvc_name
- get_rbd_provisioner_pod
- get_rbdfsplugin_provisioner_pods
- get_used_space_on_mount_point
- list_ceph_images
- plugin_provisioner_leader
- run_io_and_verify_mount_point
- run_io_in_bg
- upload
- validate_pods_are_respinned_and_running_state
- verify_data_integrity
- verify_node_name
- Pod
Each pod in the openshift cluster will have a corresponding pod object
class Pod(OCS):
def __init__(**kwargs):
Handles per pod related context
def add_role(role):
Adds a new role for this pod
role
str - New role to be assigned for this pod
def copy_to_server(server, authkey, localpath, remotepath, user=None):
Upload a file from pod to server
server
str - Name of the server to uploadauthkey
str - Authentication file (.pem file)localpath
str - Local file/dir in pod to uploadremotepath
str - Target path on the remote serveruser
str - User name to connect to server
def exec_bash_cmd_on_pod(command):
Execute a pure bash command on a pod via oc exec where you can use bash syntaxt like &&, ||, ;, for loop and so on.
command
str - The command to execute on the given pod
str
- stdout of the command
def exec_ceph_cmd(ceph_cmd, format='json-pretty'):
Execute a Ceph command on the Ceph tools pod
ceph_cmd
str - The Ceph command to execute on the Ceph tools podformat
str - The returning output format of the Ceph command
dict
- Ceph command output
CommandFailed
- In case the pod is not a toolbox pod
def exec_cmd_on_node(server, authkey, cmd, user=None):
Run command on a remote server from pod
server
str - Name of the server to run the commandauthkey
str - Authentication file (.pem file)cmd
str - command to run on server from poduser
str - User name to connect to server
def exec_cmd_on_pod(command, out_yaml_format=True, secrets=None, **kwargs):
Execute a command on a pod (e.g. oc rsh)
-
command
str - The command to execute on the given pod -
out_yaml_format
bool - whether to return yaml loaded python object OR to return raw output -
secrets
list - A list of secrets to be masked with asterisks This kwarg is popped in order to not interfere with subprocess.run(**kwargs)
Munch
Obj - This object represents a returned yaml file
def get_fio_results():
Get FIO execution results
dict
- Dictionary represents the FIO execution results
Exception
- In case of exception from FIO
def get_labels():
Get labels from pod
NotFoundError
- If resource not found
dict
- All the openshift labels on a given pod
def get_storage_path(storage_type='fs'):
Get the pod volume mount path or device path
str
- The mount path of the volume on the pod (e.g. /var/lib/www/html/) if storage_type is fs else device path of raw block pv
def install_packages(packages):
Install packages in a Pod
packages
list - List of packages to install
@property
def labels():
@property
def name():
@property
def namespace():
@property
def roles():
def run_git_clone():
Execute git clone on a pod to simulate a Jenkins user
def run_io(
storage_type,
size,
io_direction='rw',
rw_ratio=75,
jobs=1,
runtime=60,
depth=4,
fio_filename=None,
):
Execute FIO on a pod This operation will run in background and will store the results in 'self.thread.result()'. In order to wait for the output and not continue with the test until FIO is done, call self.thread.result() right after calling run_io. See tests/manage/test_pvc_deletion_during_io.py::test_run_io for usage of FIO
storage_type
str - 'fs' or 'block'size
str - Size in MB, e.g. '200M'io_direction
str - Determines the operation: 'ro', 'wo', 'rw' (default: 'rw')rw_ratio
int - Determines the reads and writes using a <rw_ratio>%/100-<rw_ratio>% (e.g. the default is 75 which means it is 75%/25% which equivalent to 3 reads are performed for every 1 write)jobs
int - Number of jobs to execute FIOruntime
int - Number of seconds IO should run fordepth
int - IO depthfio_filename(str)
- Name of fio file created on app pod's mount point
def workload_setup(storage_type, jobs=1):
Do setup on pod for running FIO
storage_type
str - 'fs' or 'block'jobs
int - Number of jobs to execute FIO
def cal_md5sum(pod_obj, file_name):
Calculates the md5sum of the file
pod_obj
Pod - The object of the podfile_name
str - The name of the file for which md5sum to be calculated
str
- The md5sum of the file
def check_file_existence(pod_obj, file_path):
Check if file exists inside the pod
pod_obj
Pod - The object of the podfile_path
str - The full path of the file to look for inside the pod
bool
- True if the file exist, False otherwise
def delete_pods(pod_objs):
Deletes list of the pod objects
pod_objs
list - List of the pod objects to be deleted
bool
- True if deletion is successful
def get_admin_key_from_ceph_tools():
Fetches admin key secret from ceph
admin keyring encoded with base64 as a string
def get_all_pods(namespace=None, selector=None):
Get all pods in a namespace.
namespace
str - Name of the namespace If namespace is None - get all pods selector (list) : List of the resource selector to search withExample
- ['alertmanager','prometheus']
list
- List of Pod objects
def get_ceph_tools_pod():
Get the Ceph tools pod
Pod
object - The Ceph tools pod object
def get_cephfs_provisioner_pod():
Get the cephfs provisioner pod
Pod
object - The cephfs provisioner pod object
def get_cephfsplugin_provisioner_pods(
cephfsplugin_provisioner_label=constants.CSI_CEPHFSPLUGIN_PROVISIONER_LABEL,
namespace=None,
):
Fetches info about CSI Cephfs plugin provisioner pods in the cluster
cephfsplugin_provisioner_label
str - label associated with cephfs provisioner pods(default
- defaults.CSI_CEPHFSPLUGIN_PROVISIONER_LABEL)
namespace
str - Namespace in which ceph cluster lives(default
- defaults.ROOK_CLUSTER_NAMESPACE)
list : csi-cephfsplugin-provisioner Pod objects
def get_file_path(pod_obj, file_name):
Get the full path of the file
pod_obj
Pod - The object of the podfile_name
str - The name of the file for which path to get
str
- The full path of the file
def get_fio_rw_iops(pod_obj):
Execute FIO on a pod
pod_obj
Pod - The object of the pod
def get_mds_pods(mds_label=constants.MDS_APP_LABEL, namespace=None):
Fetches info about mds pods in the cluster
mds_label
str - label associated with mds pods(default
- defaults.MDS_APP_LABEL)
namespace
str - Namespace in which ceph cluster lives(default
- defaults.ROOK_CLUSTER_NAMESPACE)
list : of mds pod objects
def get_mgr_pods(mgr_label=constants.MGR_APP_LABEL, namespace=None):
Fetches info about mgr pods in the cluster
mgr_label
str - label associated with mgr pods(default
- defaults.MGR_APP_LABEL)
namespace
str - Namespace in which ceph cluster lives(default
- defaults.ROOK_CLUSTER_NAMESPACE)
list : of mgr pod objects
def get_mon_pods(mon_label=constants.MON_APP_LABEL, namespace=None):
Fetches info about mon pods in the cluster
mon_label
str - label associated with mon pods(default
- defaults.MON_APP_LABEL)
namespace
str - Namespace in which ceph cluster lives(default
- defaults.ROOK_CLUSTER_NAMESPACE)
list : of mon pod objects
def get_operator_pods(
operator_label=constants.OPERATOR_LABEL,
namespace=None,
):
Fetches info about rook-ceph-operator pods in the cluster
operator_label
str - Label associated with rook-ceph-operator podnamespace
str - Namespace in which ceph cluster lives
list : of rook-ceph-operator pod objects
def get_osd_pods(osd_label=constants.OSD_APP_LABEL, namespace=None):
Fetches info about osd pods in the cluster
osd_label
str - label associated with osd pods(default
- defaults.OSD_APP_LABEL)
namespace
str - Namespace in which ceph cluster lives(default
- defaults.ROOK_CLUSTER_NAMESPACE)
list : of osd pod objects
def get_plugin_pods(interface, namespace=None):
Fetches info of csi-cephfsplugin pods or csi-rbdplugin pods
interface
str - Interface type. eg: CephBlockPool, CephFileSystemnamespace
str - Name of cluster namespace
list : csi-cephfsplugin pod objects or csi-rbdplugin pod objects
def get_pod_count(label, namespace=None):
def get_pod_logs(pod_name, container=None):
Get logs from a given pod
pod_name (str): Name of the pod container (str): Name of the container
str
- Output from 'oc get logs <pod_name> command
def get_pod_node(pod_obj):
Get the node that the pod is running on
pod_obj
OCS - The pod object
OCP
- The node object
def get_pod_obj(name, namespace=None):
Returns the pod obj for the given pod
name
str - Name of the resources
obj : A pod object
def get_pods_having_label(label, namespace):
Fetches pod resources with given label in given namespace
label
str - label which pods might havenamespace
str - Namespace in which to be looked up
dict
- of pod info
def get_pvc_name(pod_obj):
Function to get pvc_name from pod_obj
pod_obj
str - The pod object
pvc_name
str - The pvc_name on a given pod_obj
def get_rbd_provisioner_pod():
Get the RBD provisioner pod
Pod
object - The RBD provisioner pod object
def get_rbdfsplugin_provisioner_pods(
rbdplugin_provisioner_label=constants.CSI_RBDPLUGIN_PROVISIONER_LABEL,
namespace=None,
):
Fetches info about CSI Cephfs plugin provisioner pods in the cluster
rbdplugin_provisioner_label
str - label associated with RBD provisioner pods(default
- defaults.CSI_RBDPLUGIN_PROVISIONER_LABEL)
namespace
str - Namespace in which ceph cluster lives(default
- defaults.ROOK_CLUSTER_NAMESPACE)
list : csi-rbdplugin-provisioner Pod objects
def get_used_space_on_mount_point(pod_obj):
Get the used space on a mount point
pod_obj
POD - The pod object
int
- Percentage represent the used space on the mount point
def list_ceph_images(pool_name='rbd'):
-
pool_name
str - Name of the pool to get the ceph images -
Returns
List - List of RBD images in the pool
def plugin_provisioner_leader(interface, namespace=None):
Find csi-cephfsplugin-provisioner or csi-rbdplugin-provisioner leader pod
interface
str - Interface type. eg: CephBlockPool, CephFileSystemnamespace
str - Name of cluster namespace
Pod
- csi-cephfsplugin-provisioner or csi-rbdplugin-provisioner leader pod
def run_io_and_verify_mount_point(pod_obj, bs='10M', count='950'):
Run I/O on mount point
pod_obj
Pod - The object of the podbs
str - Read and write up to bytes at a timecount
str - Copy only N input blocks
used_percentage
str - Used percentage on mount point
def run_io_in_bg(pod_obj, expect_to_fail=False):
Run I/O in the background
pod_obj
Pod - The object of the podexpect_to_fail
bool - True for the command to be expected to fail (disruptive operations), False otherwise
Thread
- A thread of the I/O execution
def upload(pod_name, localpath, remotepath):
Upload a file to pod
pod_name
str - Name of the podlocalpath
str - Local file to uploadremotepath
str - Target path on the pod
def validate_pods_are_respinned_and_running_state(pod_objs_list):
Verifies the list of the pods are respinned and in running state
pod_objs_list
list - List of the pods obj
bool : True if the pods are respinned and running, False otherwise
def verify_data_integrity(pod_obj, file_name, original_md5sum):
Verifies existence and md5sum of file created from first pod
pod_obj
Pod - The object of the podfile_name
str - The name of the file for which md5sum to be calculatedoriginal_md5sum
str - The original md5sum of the file
bool
- True if the file exists and md5sum matches
AssertionError
- If file doesn't exist or md5sum mismatch
def verify_node_name(pod_obj, node_name):
Verifies that the pod is running on a particular node
pod_obj
Pod - The pod objectnode_name
str - The name of node to check
bool
- True if the pod is running on a particular node, False otherwise