Why Renaming Datastore Not Working With Command Line and How to Fix it

I just got into a very interesting problem recently – the vim-cmd does not work as expected when used for renaming a datastore in vSphere.

What is the problem exactly?

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

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

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

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:

/var/log/vpxa.log:2013-15-10T16:13:28.916Z [51326B90 verbose 'vpxavpxaDatastore' opID=SWI-3a603987] [VpxaDatastore] Renaming datastore doublecloudDS -> datastore1

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.

This entry was posted in Virtualization and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    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.