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:
parent
a130f19a19
commit
8faa3bb53d
|
@ -35,7 +35,7 @@ from cli_lib.common import call_api
|
||||||
#
|
#
|
||||||
def vm_info(config, vm):
|
def vm_info(config, vm):
|
||||||
"""
|
"""
|
||||||
Get information about VM
|
Get information about (single) VM
|
||||||
|
|
||||||
API endpoint: GET /api/v1/vm/{vm}
|
API endpoint: GET /api/v1/vm/{vm}
|
||||||
API arguments:
|
API arguments:
|
||||||
|
@ -44,6 +44,11 @@ def vm_info(config, vm):
|
||||||
response = call_api(config, 'get', '/vm/{vm}'.format(vm=vm))
|
response = call_api(config, 'get', '/vm/{vm}'.format(vm=vm))
|
||||||
|
|
||||||
if response.status_code == 200:
|
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()
|
return True, response.json()
|
||||||
else:
|
else:
|
||||||
return False, response.json()['message']
|
return False, response.json()['message']
|
||||||
|
|
Loading…
Reference in New Issue