Skip to content

How to check if a file on a datastore exists? #1061

Answered by karaatanassov
Hi-Angel asked this question in Q&A
Discussion options

You must be logged in to vote

No. This API searches the folder path. In the example we are aksing - does the folder "[vsanDatastore] 39cce864-d1d5-b67b-a2b8-88aedd01f1d5" contain an entry "my.iso".

You can go with more complex paths. For example my content library stores .iso images in VSAN datastore. The path is

[vsanDatastore] 176ed963-71d2-0480-5517-88aedd050057/19550ad3-c308-45d9-8cb9-64cb2fbd89d1/ubuntu-22.04-live-server-amd64_66c714be-12c7-4681-a70b-1d6b70bf822d.iso 

so then to call the API I need to split it in file name and folder path like so

searchSpec = vim.host.DatastoreBrowser.SearchSpec()
searchSpec.matchPattern = ["ubuntu-22.04-live-server-amd64_66c714be-12c7-4681-a70b-1d6b70bf822d.iso"]
task = browser…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@Hi-Angel
Comment options

@Hi-Angel
Comment options

@Hi-Angel
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Hi-Angel
Comment options

Answer selected by Hi-Angel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants