def vmware_path(datastore, datacenter, path):
 path = ('/folder/%s' % path.lstrip('/'))
 datacenter = datacenter.replace('&', '%26')
 if (not path.startswith('/')):
  path = ('/' + path)
 params = dict(dsName=datastore)
 if datacenter:
  params['dcPath'] = datacenter
 params = urllib.urlencode(params)
 return ('%s?%s' % (path, params))

def vmware_path ( datastore , datacenter , path ) : path = ( '/folder/%s' % path . lstrip ( '/' ) ) datacenter = datacenter . replace ( '&' , '%26' ) if ( not path . startswith ( '/' ) ) : path = ( '/' + path ) params = dict ( dsName = datastore ) if datacenter : params [ 'dcPath' ] = datacenter params = urllib . urlencode ( params ) return ( '%s?%s' % ( path , params ) )
constructs a url path that vsphere accepts reliably .