def getvm_info(vm, depth=1):
 maxdepth = 10
 if hasattr(vm, 'childEntity'):
  if (depth > maxdepth):
   return
  vmlist = vm.childEntity
  for c in vmlist:
   getvm_info(c, (depth + 1))
  return
 if hasattr(vm, 'CloneVApp_Task'):
  vmlist = vm.vm
  for c in vmlist:
   getvm_info(c)
  return
 try:
  uuid = vm.config.instanceUuid
  uuid = uuid.replace('-', '')
  INV_VM.append(uuid)
 except Exception as e:
  print ('Caught exception : ' + str(e))
  return (-1)

def getvm_info ( vm , depth = 1 ) : maxdepth = 10 if hasattr ( vm , 'childEntity' ) : if ( depth > maxdepth ) : return vmlist = vm . childEntity for c in vmlist : getvm_info ( c , ( depth + 1 ) ) return if hasattr ( vm , 'CloneVApp_Task' ) : vmlist = vm . vm for c in vmlist : getvm_info ( c ) return try : uuid = vm . config . instanceUuid uuid = uuid . replace ( '-' , '' ) INV_VM . append ( uuid ) except Exception as e : print ( 'Caught exception : ' + str ( e ) ) return ( - 1 )
print information for a particular virtual machine or recurse into a folder with depth protection from the getallvms .