The following command, for example, should change the name of a datastore from datastore1 (which is the default datastore name) to doublecloudDS.

# vim-cmd hostsvc/datastore/rename datastore1 doubecloudDS

# vim-cmd hostsvc/datastore/rename datastore1 doubecloudDS

After the command is executed, there is no error message reported. But the datastore name remains the same as shown in either the vSphere Client or using the following command:

# vim-cmd hostsvc/datastore/listsummary

# vim-cmd hostsvc/datastore/listsummary

After a few tries with the command, for example, change order of the source and destination datastore, adding [] to wrap aournd the datastore names, all these resulted errors. So the command itself is most likely correct.

What possibly went wrong?

The ESXi is not running as a standalone server but is managed by a vCenter. It turns out that right after the vim-cmd renamed a datastore, the vCenter reverses back, immediately. There is an entry in the /var/log/vpxa.log file:

So the problem is really the vCenter. This is not necessarily a bad thing as vCenter wants to make sure it’s in control. I kind of think the ideal case would be that the vCenter reads back the changes from ESXi. That would of course needs more work.

What can be the fix?

The easier approach is to ALWAYS rename your datastore via vCenter, either from vSphere GUI (standalone client or Web client) or APIs like vijava APIs. vCenter will send the change to ESXi and make sure the data is consistent.

If you still wants to use the vim-cmd, you have to detach the ESXi from its managing vCenter and add it back again. It may sounds too much. Will disconnecting and connecting back work? Not really. The new name remains as long as you don’t connect the ESXi back to the vCenter. Once you do connect it back, vCenter will reverse back the name. I think the vCenter uses an internal ID for the datastore. So it knows the datastore regardless it new name.

NEED HELP?

My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.