MCPcopy Create free account
hub / github.com/apache/cloudstack / validateList

Function validateList

tools/marvin/marvin/lib/utils.py:457–488  ·  view source on GitHub ↗

@name: validateList @Description: 1. A utility function to validate whether the input passed is a list 2. The list is empty or not 3. If it is list and not empty, return PASS and first element 4. If not reason for FAIL @Inpu

(inp)

Source from the content-addressed store, hash-verified

455 return 'snapshot exists' in result
456
457def validateList(inp):
458 """
459 @name: validateList
460 @Description: 1. A utility function to validate
461 whether the input passed is a list
462 2. The list is empty or not
463 3. If it is list and not empty, return PASS and first element
464 4. If not reason for FAIL
465 @Input: Input to be validated
466 @output: List, containing [ Result,FirstElement,Reason ]
467 Ist Argument('Result') : FAIL : If it is not a list
468 If it is list but empty
469 PASS : If it is list and not empty
470 IInd Argument('FirstElement'): If it is list and not empty,
471 then first element
472 in it, default to None
473 IIIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
474 default to None.
475 INVALID_INPUT
476 EMPTY_LIST
477 """
478 ret = [FAIL, None, None]
479 if inp is None:
480 ret[2] = INVALID_INPUT
481 return ret
482 if not isinstance(inp, list):
483 ret[2] = INVALID_INPUT
484 return ret
485 if len(inp) == 0:
486 ret[2] = EMPTY_LIST
487 return ret
488 return [PASS, inp[0], None]
489
490def verifyElementInList(inp, toverify, responsevar=None, pos=0):
491 '''

Callers 15

__createApiClientMethod · 0.90
__createUserApiClientMethod · 0.90
getStateMethod · 0.90
validateStateMethod · 0.90
createMethod · 0.90
_check_resource_stateMethod · 0.90
getStateMethod · 0.90
getStateMethod · 0.90
get_regionFunction · 0.90
get_domainFunction · 0.90
find_storage_pool_typeFunction · 0.90
get_zoneFunction · 0.90

Calls

no outgoing calls