Skip to content

Commit f6238a0

Browse files
authored
CP-52334 MVD - add -d option to mock driver-tool (#6595)
The API supports a driver deselect call for which Xapi calls the underlying driver-tool. The mock driver is missing the corresponding -d option, which this patch adds. This fixes an internal error that Xapi raises otherwise. An alternative would be to ignore the error from the driver-tool.
2 parents 577186e + 832eda5 commit f6238a0

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

ocaml/xapi/xapi_host_driver_tool.ml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ module Mock = struct
243243
set -o errexit
244244
set -o pipefail
245245

246+
function deselect {
247+
cat <<EOF
248+
{
249+
"driver": "$1",
250+
"exit": 0
251+
}
252+
EOF
253+
}
254+
246255
function selection {
247256
cat <<EOF
248257
{
@@ -253,6 +262,7 @@ function selection {
253262
EOF
254263
}
255264

265+
256266
function list() {
257267
cat <<EOF
258268

@@ -606,9 +616,10 @@ l_flag=false
606616
s_flag=false
607617
n_value=""
608618
v_value=""
619+
d_value=""
609620

610621
# Use getopt to parse command-line options
611-
while getopts "lsn:v:" opt; do
622+
while getopts "lsn:v:d:" opt; do
612623
case "$opt" in
613624
l)
614625
l_flag=true
@@ -622,6 +633,9 @@ while getopts "lsn:v:" opt; do
622633
v)
623634
v_value="$OPTARG"
624635
;;
636+
d)
637+
d_value="$OPTARG"
638+
;;
625639
\?) # Invalid option
626640
echo "Invalid option: -$OPTARG" >&2 #>&2 redirects error message to stderr
627641
exit 1
@@ -656,6 +670,11 @@ if $s_flag; then
656670
selection "$n_value" "$v_value"
657671
exit 0
658672
fi
673+
674+
if [ -n "$d_value" ]; then
675+
deselect "$d_value"
676+
exit 0
677+
fi
659678
|}
660679

661680
let install () =

0 commit comments

Comments
 (0)