def find_vmx(dsbrowser, dsname, datacenter, fulldsname):
 args = get_args()
 search = vim.HostDatastoreBrowserSearchSpec()
 search.matchPattern = '*.vmx'
 search_ds = dsbrowser.SearchDatastoreSubFolders_Task(dsname, search)
 while (search_ds.info.state != 'success'):
  pass
 for rs in search_ds.info.result:
  dsfolder = rs.folderPath
  for f in rs.file:
   try:
    dsfile = f.path
    vmfold = dsfolder.split(']')
    vmfold = vmfold[1]
    vmfold = vmfold[1:]
    vmxurl = ('https://%s/folder/%s%s?dcPath=%s&dsName=%s' % (args.host, vmfold, dsfile, datacenter, fulldsname))
    VMX_PATH.append(vmxurl)
   except Exception as e:
    print ('Caught exception : ' + str(e))
    return (-1)

def find_vmx ( dsbrowser , dsname , datacenter , fulldsname ) : args = get_args ( ) search = vim . HostDatastoreBrowserSearchSpec ( ) search . matchPattern = '*.vmx' search_ds = dsbrowser . SearchDatastoreSubFolders_Task ( dsname , search ) while ( search_ds . info . state != 'success' ) : pass for rs in search_ds . info . result : dsfolder = rs . folderPath for f in rs . file : try : dsfile = f . path vmfold = dsfolder . split ( ']' ) vmfold = vmfold [ 1 ] vmfold = vmfold [ 1 : ] vmxurl = ( 'https://%s/folder/%s%s?dcPath=%s&dsName=%s' % ( args . host , vmfold , dsfile , datacenter , fulldsname ) ) VMX_PATH . append ( vmxurl ) except Exception as e : print ( 'Caught exception : ' + str ( e ) ) return ( - 1 )
function to search for vmx files on any datastore that is passed to it .