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.
This commit is contained in:
Joshua Boniface 2020-04-09 10:26:49 -04:00
parent a130f19a19
commit 8faa3bb53d
1 changed files with 6 additions and 1 deletions

View File

@ -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']