VMware Cloud Community
jshamberger
Contributor
Contributor

vifs can't delete files when ESX is in maintenance mode

I ran into this change in behavior from the vSphere 4.x CLI.  You can use vifs to upload a file to an ESX's datastore while the ESX is in maintenance mode, but if you try to remove it the operation fails until you exit maintenance mode:

vi-admin@localhost:/tmp> # Started in maintenance mode on the ESXi host

vi-admin@localhost:/tmp> vifs --server 10.127.130.230 --put /tmp/foo.txt "[datastore1] /foo.txt"
Enter username: root
Enter password:
Uploaded file /tmp/foo.txt to /foo.txt successfully.
vi-admin@localhost:/tmp> vifs --server 10.127.130.230 --rm "[datastore1] /foo.txt"
Enter username: root
Enter password:
Remove '/foo.txt'? (y/n) : y
Unable to delete [datastore1] /foo.txt:
The operation is not allowed in the current state.

vi-admin@localhost:/tmp> # Took the ESXi host out of maintenance mode
vi-admin@localhost:/tmp> vifs --server 10.127.130.230 --rm "[datastore1] /foo.txt"
Enter username: root
Enter password:
Remove '/foo.txt'? (y/n) : y
Deleted file '[datastore1] /foo.txt' successfully.
vi-admin@localhost:/tmp>

I didn't find this change in behavior called out in the documentation, so it may be an unintended regression.  Has anyone else run into this problem and found a workaround other than taking the ESXi host out of maintenance mode?

0 Kudos
3 Replies
Virtualinfra
Commander
Commander

I have tried removing files on the esxi host when it is in maintenance mode, when connected via putty..

But not tried with VMA.. lets me try that to.

Thanks & Regards Dharshan S VCP 4.0,VTSP 5.0, VCP 5.0
0 Kudos
lamw
Community Manager
Community Manager

The change in behavior is not related to the vCLI, but the actual underlying API for the version of ESX(i) you're running. It looks like with ESX(i) 4.x, you were allowed to delete a file while the host was in maint mode, this holds true whether you use vCLI 4.x or vCLI 5.0 on an ESX(i) 4.x host (verified this). If you're on an ESX(i) 5.0 host, you'll find that an error is thrown which can also be seen by watching the vSphere Client directly connecting to host. I can see why this was added as even file manipulation could cause some problems depending on the state of the ESX(i) host (e.g. it's being patched and you don't want users to be uploading/removing files).

There were also some quirkyness with earlier versions of vifs in vCLI 4.x, it's been much improved in vCLI 5.0 (e.g. you may get nothing when trying to just perform a listds, you would need to specify the datacenter object as well, which is unecessary when directly connecting to a host)

0 Kudos
jshamberger
Contributor
Contributor

I can see why this was added as even file manipulation could cause some problems depending on the state of the ESX(i) host (e.g. it's being patched and you don't want users to be uploading/removing files).

True, but file manipulation could also cause problems when the ESXi host is not in maintenance mode.  I suppose I'll just have to work around this by putting the host in an out of maintenance mode to meet the requirements of the different operations I'm scripting together (I'm uploading a VIB to install, which requires maintenance mode).

0 Kudos