From 8faa3bb53d290676c3094096e9d35305e94acc7c Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 9 Apr 2020 10:26:49 -0400 Subject: [PATCH] Handle info fuzzy matches better If we are calling info, we want one VM. Don't silently discard other options or try (and fail later) to parse multiple, just say no VM found. --- client-cli/cli_lib/vm.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client-cli/cli_lib/vm.py b/client-cli/cli_lib/vm.py index 16a18a26..598c8581 100644 --- a/client-cli/cli_lib/vm.py +++ b/client-cli/cli_lib/vm.py @@ -35,7 +35,7 @@ from cli_lib.common import call_api # def vm_info(config, vm): """ - Get information about VM + Get information about (single) VM API endpoint: GET /api/v1/vm/{vm} API arguments: @@ -44,6 +44,11 @@ def vm_info(config, vm): response = call_api(config, 'get', '/vm/{vm}'.format(vm=vm)) if response.status_code == 200: + if len(response.json()) > 1: + # No exact match; return not found + return False, "VM not found." + else: + return True, response.json()[0] return True, response.json() else: return False, response.json()['message']