Hi there,
I use fileaccess.pl from vcli (viperl) 4.0 to browse a datastore, it works fine with ESX 4.0, however I encountered an error with ESXi 4.0 (with the save version number), the server returns "404 Not Found", the datastore is a local disk and the name is what I see from the vSphere Client.
fileaccess.pl --operation browse --filetype datastore \
--server example.org --username administrator --password password \
--datacentername 'DataCenter' --datastorename 'datastore1 \
--remotepath ""
Does anybody know what is wrong? Thanks in advance.
-
Can you hit the following urls:
https://10.241.32.48/mob
and
https://10.241.32.48/
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Could you provide a screenshot of your datastore + the output from when you run fileaccess.pl?
I'm able to run the exact same command on both ESX and ESXi 4.0 without any issues for a local VMFS volume.
classic ESX version:
[vi-admin@scofield general]$ ./viversion.pl --server himalaya.primp-industries.com This is HostAgent 4.0 This is VMware ESX 4.0.0 build-164009 running on x86 ESX Server microkernel The product Line ID is a unique identifier for a product line. This is VMware ESX Server product. Short form of the product name is VMware ESX having version 4.0.0 System is running on x86 ESX Server microkernel
ESXi version:
[vi-admin@scofield general]$ ./viversion.pl --server esxi4-1.primp-industries.com This is HostAgent 4.0 This is VMware ESXi 4.0.0 build-171294 running on x86 ESX Server microkernel The product Line ID is a unique identifier for a product line. product line id is embeddedEsx Short form of the product name is VMware ESXi having version 4.0.0 System is running on x86 ESX Server microkernel
classic ESX:
[vi-admin@scofield general] ./fileaccess.pl --server himalaya.primp-industries.com --operation browse --datastorename himalaya-local-SAS.Savvio --filetype datastore --remotepath "" ############################################### Location https://himalaya.primp-industries.com:443/folder/?dcPath=ha-datacenter&dsName=himalaya-local-SAS.Sav... Parent Datacenter Certiorari/ Clifford/ Fugue/ Fullerene/ Iaorana/ Norman-CL1/ Oxygen/ .... ############################################### Enter the Name of the folder (enter -1 to exit) -1
ESXi:
[vi-admin@scofield general]$ ./fileaccess.pl --server esxi4-1.primp-industries.com --operation browse --datastorename esxi4-1-local-storage-1 --filetype datastore --remotepath "" ############################################### Location https://esxi4-1.primp-industries.com:443/folder/?dcPath=ha-datacenter&dsName=esxi4-1-local-storage-1 Parent Datacenter ImportantDesktop_1/ VA-Tomcat/ WILLIAM_BACKUPS/ ghetto-esxi-linked-clones.sh goldmaster/ list stupid vm with spaces/ test/ vMA/ ############################################### Enter the Name of the folder (enter -1 to exit) -1
I did notice that you're using --datacentername, if you're connecting directly to ESX or ESXi host, this param is not necessary. It's more useful when you're connecting to a vCenter, in either case it doesn't hurt to have it but you need to make sure the value is correct. For ESX or ESXi connection, the datacenter name is always defaulted to "ha-datacenter"
Here's more details around the use case for fileaccess.pl - http://www.vmware.com/support/developer/viperltoolkit/viperl40/doc/fileaccess.html
If you're looking to just browse the datastore, I would recommend dsbrowse.pl - http://www.vmware.com/support/developer/viperltoolkit/viperl40/doc/dsbrowse.html as it provides more information, unless you need the specific features of fileaccess.pl
You also have the option of using vifs.pl which is part of the vCLI to perform filesystem operations against your ESX or ESXi host volumes.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Thanks for your detailed instruction. I tried connect to the ESXi directly, it succeeded. I am sure the datacentername is exactly what I see in vCenter Client (will provide a screenshot once I back to office tomorrow).
Connect to ESXi *
$ /usr/lib/vmware-vcli/apps/general/fileaccess.pl --operation browse \
--filetype datastore --datastorename 'CX4_Lun47_R5' --remotepath '' \
--server 10.241.32.116 --username root --password password
###############################################
Location https://10.241.32.116/folder/?dcPath=ha-datacenter&dsName=CX4_Lun47_R5
Parent Datacenter
testVM-r1s1-001/
testVM-r1s1-002/
upload-test/
wordlist.txt
###############################################
Enter the Name of the folder (enter -1 to exit) -1
Connect to vCenter *
$ /usr/lib/vmware-vcli/apps/general/fileaccess.pl --operation browse \
--filetype datastore --datastorename 'CX4_Lun47_R5' --remotepath '' \
--server 10.241.32.48 --username administrator --password password \
--datacentername 'CET_Test'
Error : 404 Not Found
Enter the Name of the folder (enter -1 to exit) -1
Is that a way to see verbose log on vCenter Server side?
Thank you so much.
-
So your question slightly differs from what you originally asked in the start of the thread, technically it should not matter if it's a local datastore or NFS,iSCSI/FC datastore.
In any case, I was able to successfully query for the exact same datastore whether I'm connecting directly to an ESXi host or to vCenter host managing the ESXi host.
Connecting to ESXi host:
[vi-admin@scofield general]$ ./fileaccess.pl --server esxi4-2.primp-industries.com --operation browse --filetype datastore --remotepath "" --datacentername ha-datacenter --datastorename esxi4-2-local-storage-1 ############################################### Location https://esxi4-2.primp-industries.com:443/folder/?dcPath=ha-datacenter&dsName=esxi4-2-local-storage-1 Parent Datacenter test-vm/ test-vm2/ test-vm5/ vmlist ############################################### Enter the Name of the folder (enter -1 to exit)
Connecting to vCenter managing ESXi host:
[vi-admin@scofield general]$ ./fileaccess.pl --server reflex.primp-industries.com --operation browse --filetype datastore --remotepath "" --datacentername Primp-QA --datastorename esxi4-2-local-storage-1 ############################################### Location https://reflex.primp-industries.com:443/folder/?dcPath=Primp-QA&dsName=esxi4-2-local-storage-1 Parent Datacenter test-vm/ test-vm2/ test-vm5/ vmlist ############################################### Enter the Name of the folder (enter -1 to exit) -1
Just make sure the datacenter name is spelled correctly and I also noticed that your remotepath is just single ", it should be "".
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Right the focus of the question changed. That's your hint let me found that the 404 error only happen when connect to the vCenter Server. Is there any approach to see (debug) log on vCenter Server side?
Screenshots attached. The datacenter name is correct, no spaces around the name.
Thank you.
I'm not sure why you're not able to get the output when connecting to vCenter.
As you can see from your output and mines, if it's successful you'll get a URL that's generated as part of the overall output.
Can you try to paste these into your browser and login with the same credentials and see if you're able to get to the URL:
ESXi URL:
https://10.241.32.116/folder/?dcPath=ha-datacenter&dsName=CX4_Lun47_R5
vCenter URL:
https://10.241.32.48:443/folder/?dcPath=CET_Test&dsName=CX4_Lun47_R5
You should be able to login to both and get a listing of the datastore with the VM folders
You can enable further debugging and get the SOAP messages that's being sent between vCenter and the clients, take a look at this VMware KB to enable "trivia" logging - http://kb.vmware.com/kb/1001584 Make sure you do this only for the duration of your test and you can look through the logs, it's very extensive when you enable "trivia". You might find out why you're getting back 404 error, most likely for whatever reason, it's unable to reach the vCenter URL, under the hood of "fileaccess.pl", it's just using simple http put/gets
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Thanks William. I tried access with a browser, as expected - succeeded with ESXi, failed with vCenter. With curl I saw the HTTP code. I will try to enable "trivia" logging - that's very helpful.
$ curl -Isk --user root:password 'https://10.241.32.116/folder/?dcPath=ha-datacenter&dsName=CX4_Lun47_R5'
HTTP/1.1 200 OK
Date: Thu, 13 May 2010 02:45:55 GMT
Set-Cookie: vmware_soap_session="52ab2f86-509d-286f-af2e-dbc2af1f3178"; Path=/;
Content-Type: text/html
Content-Length: 1504
$ curl -Isk --user administrator:password 'https://10.241.32.48/folder/?dcPath=CET_Test&dsName=CX4_Lun47_R5'
HTTP/1.1 404 Not Found
Date: Thu, 13 May 2010 02:47:11 GMT
Set-Cookie: vmware_soap_session="59AD879B-9842-4F68-8A23-9BCAACE26978"; Path=/;
Connection: close
Content-Type: text; charset=plain
Content-Length: 0
Can you hit the following urls:
https://10.241.32.48/mob
and
https://10.241.32.48/
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
All right I found the root cause - I should use --datacentername "Virtual_Test/CET_Test", there's a parent folder for the datacenter.
I accessed https://10.241.32.48/folder directly and saw the correct name in the list.
Thank you so much William, your answers are very useful, I learned a lot.
$ sh -x vmscript
+ /usr/lib/vmware-vcli/apps/general/fileaccess.pl --operation browse --filetype datastore --datastorename CX4_Lun47_R5 --remotepath '' --server 10.241.32.116 --username root --password password
###############################################
Location https://10.241.32.116/folder/?dcPath=ha-datacenter&dsName=CX4_Lun47_R5
Parent Datacenter
testVM-r1s1-001/
testVM-r1s1-002/
upload-test/
wordlist.txt
###############################################
Enter the Name of the folder (enter -1 to exit) -1
+ /usr/lib/vmware-vcli/apps/general/fileaccess.pl --operation browse --filetype datastore --datastorename CX4_Lun47_R5 --remotepath '' --server 10.241.32.48 --username administrator --password password --datacentername Virtual_Test/CET_Test
###############################################
Location https://10.241.32.48/folder/?dcPath=Virtual_Test/CET_Test&dsName=CX4_Lun47_R5
Parent Datacenter
testVM-r1s1-001/
testVM-r1s1-002/
upload-test/
wordlist.txt
###############################################
Enter the Name of the folder (enter -1 to exit) -1