1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright (C) 2022 Intel Corporation 3# All rights reserved. 4# 5 6function sma_waitforlisten() { 7 local sma_addr=${1:-127.0.0.1} 8 local sma_port=${2:-8080} 9 10 for ((i = 0; i < 5; i++)); do 11 if nc -z $sma_addr $sma_port; then 12 return 0 13 fi 14 sleep 1s 15 done 16 return 1 17} 18 19function uuid2base64() { 20 python <<- EOF 21 import base64, uuid 22 print(base64.b64encode(uuid.UUID("$1").bytes).decode()) 23 EOF 24} 25 26get_cipher() { 27 case "$1" in 28 AES_CBC) echo 0 ;; 29 AES_XTS) echo 1 ;; 30 *) echo "$1" ;; 31 esac 32} 33 34format_key() { 35 base64 -w 0 <(echo -n "$1") 36} 37 38uuid2nguid() { 39 # The NGUID returned by the RPC is UPPERCASE 40 local uuid=${1^^} 41 echo ${uuid//-/} 42} 43 44get_qos_caps() { 45 local rootdir 46 47 rootdir="$(dirname $BASH_SOURCE)/../.." 48 49 "$rootdir/scripts/sma-client.py" <<- EOF 50 { 51 "method": "GetQosCapabilities", 52 "params": { 53 "device_type": $1 54 } 55 } 56 EOF 57} 58