2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
13 ethernet_adpator_version=$( lspci | grep "Ethernet Controller XL710" | head -n 1 | cut -d " " -f 8 )
14 if [ -z "$ethernet_adpator_version" ]; then
15 echo " Ethernet adapator version is not set. SRIOV test case cannot run on this machine"
18 #checking for the right hardware version of NIC on the machine
19 if [ $ethernet_adpator_version == "XL710" ]; then
20 echo "NIC card specs match. SRIOV option avaiable for this version."
22 echo -e "Failed. The version supplied does not match.\nTest cannot be executed."
27 rm -f $HOME/$pod_name.yaml
28 kubectl delete pod $pod_name --ignore-not-found=true --now --wait
29 allocated_node_resource=$(kubectl describe node | grep "intel.com/intel_sriov_700" | tail -n1 |awk '{print $(NF)}')
31 echo "The allocated resource of the node is: " $allocated_node_resource
32 cat << POD > $HOME/$pod_name.yaml
38 k8s.v1.cni.cncf.io/networks: sriov-eno2
42 image: docker.io/centos/tools:latest
47 intel.com/intel_sriov_700: '1'
49 intel.com/intel_sriov_700: '1'
51 kubectl create -f $HOME/$pod_name.yaml --validate=false
52 for pod in $pod_name; do
54 while [[ $status_phase != "Running" ]]; do
55 new_phase=$(kubectl get pods $pod | awk 'NR==2{print $3}')
56 if [[ $new_phase != $status_phase ]]; then
57 echo "$(date +%H:%M:%S) - $pod : $new_phase"
58 status_phase=$new_phase
60 if [[ $new_phase == "Running" ]]; then
61 echo "Pod is up and running.."
63 if [[ $new_phase == "Err"* ]]; then
68 allocated_node_resource=$(kubectl describe node | grep "intel.com/intel_sriov_700" | tail -n1 |awk '{print $(NF)}')
70 echo " The current resource allocation after the pod creation is: " $allocated_node_resource
71 kubectl delete pod $pod_name --now