Thursday, 7 January 2010
VMware Server 2.0.2 and it's use of datastores
If you're like me (!), and prefer scripts to GUIs, then you might find this to be of some use.
#!/bin/bash
#!/bin/bash
I've recently written some scripts for my VMware Server environment to register, start, stop and list VMs. I'm using VMware Server on Ubuntu 9.10 64-bit, and use it to run products such as Lotus Connections, WebSphere Portal etc.
Here're the scripts: -
registerVM.sh
#!/bin/bash
vmrun -t server -h https://orac:8333/sdk -user root -password passw0rd register "[standard] $1/$1.vmx"
vmrun -t server -h https://orac:8333/sdk -user root -password passw0rd register "[standard] $1/$1.vmx"
startVM.sh
#!/bin/bash
vmrun -t server -h https://orac:8333/sdk -user root -password passw0rd start "[vmwares] $1/$1.vmx"
vmrun -t server -h https://orac:8333/sdk -user root -password passw0rd start "[vmwares] $1/$1.vmx"
stopVM.sh
#!/bin/bash
vmrun -t server -h https://orac:8333/sdk -user root -password passw0rd start "[vmwares] $1/$1.vmx"
vmrun -t server -h https://orac:8333/sdk -user root -password passw0rd start "[vmwares] $1/$1.vmx"
listVM.sh
and, for Lotus Connections especially, there's this one: -
startAll.sh
./startVM.sh Domino
./startVM.sh DB2
./startVM.sh WASND
./startVM.sh Connections
./startVM.sh DB2
./startVM.sh WASND
./startVM.sh Connections
Now, most of these scripts have one thing in common; they all refer to "[vmwares]" which is an alias that points to the physical directory (in my case, this is a mount point called /vmwares that points to a 1 TB SATA2 internal drive ).
The path is set by the vmwareConfig.pl script *BUT* the alias is not; it's set to a default of standard by a configuration file; /etc/vmware/hostd/datastores.xml.
This meant that my scripts were failing - in the case of registerVM.sh, I was seeing: -
Error: The virtual machine cannot be found
Therefore, in my case, I've amended this file to reflect the alias as vmwares rather than standard as follows: -
<ConfigRoot>
<LocalDatastores>
<_length>1</_length>
<_type>hostd.host.LocalDataStoreEntry[]</_type>
<e id="0">
<_type>hostd.host.LocalDataStoreEntry</_type>
<id>1</id>
<name>vmwares</name>
<path>/vmwares</path>
</e>
<NasVolumes>
<_length>0</_length>
<_type>host.host.NasDataStoreEntry[]</_type>
</NasVolumes>
</ConfigRoot>
In other words, I've changed: -
<name>standard</name>
to: -
<name>vmwares</name>
PS It's worth noting that, depending upon your environment, you may also have a NEW_datastores.xml as well as the original datastores.xml file. Be aware that the NEW file takes precedence over the original version; therefore, ensure that you modify the right version.
The simplest trick is to change the file and then restart VMware Server via the command: -
service vmware stop
service vmware start
or: -
service vmware restart
Check the amended configuration file to ensure that the new alias has been picked up.
Subscribe to Posts [Atom]