Monday, June 9, 2008

Unattended setup of Virtual Center

I recently had to setup a VDI training environment which needed 6 virtual center servers.  I don't like repetitive tasks so I tried to script it a little. I would like to refer to http://www.vinternals.com/2008/01/virtualcenter-25-silent-install.html  because that kind of gave me the start I needed.

I tried to put as much variables in there as possible.

First I set some variables like where the Media is, the DBserver, ... then the script detects the hostname, I have 6 servers called VCTEAM1 ...6 and I take out the number to link the server to the right database in the back-end.  I assume the license file is called VCIlicense.lic and is in the VC_Media folder.  Then we start the installation; the installation itself doesn't initialize the database so we need to start vpxd.exe with the -b parameter to do so... and then next the install sequence for the VIclient is started, and it's done.  And most important here is the script :

#Install VC unattended
SET VC_Media=C:\VC250
SET Team=%computername:~7%
SET DBServer=SQL2005DB

#Create DSN connection
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\vpx%Team% /v Driver /t REG_SZ /d C:\WINDOWS\system32\sqlncli.dll
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\vpx%Team% /v Description /t REG_SZ /d vpx%Team%
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\vpx%Team% /v Server /t REG_SZ /d %DBServer%
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\vpx%Team% /v LastUser /t REG_SZ /d Team%Team%
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources" /v vpx%Team% /t REG_SZ /d "SQL Native Client"

#Install Virtual Center + Lic Server
start "Installing VC" /wait "%VC_media%\vpx\VMware-vcserver.exe" /s /w /v"/qr WARNING_LEVEL=0 VMLS_LICENSEPATH="%VC_Media%\VCIlicense.lic" VC_EDITION=vc DB_SERVER_TYPE=Custom DB_DSN=\"vpx%Team%\" DB_USERNAME="Team%Team%" DB_PASSWORD="vmware%Team%" INSTALL_VCI=\"\" REBOOT=SUPPRESS"

#Initiate the Database Tables
start "Creating DB tables" /wait "C:\Program Files\VMware\Infrastructure\VirtualCenter Server\vpxd.exe" -b
net start vpxd

#Install VI Client
start "Installing VI Client" /wait "%VC_Media%\vpx\VMware-viclient.exe" /s /w /v"/qn /L*v "%TEMP%\vmvcc.log" WARNING_LEVEL=0"

Maybe one more point, in this script there is assumed that the connection goes to a SQL2005 database because the generated DSN is using the SQL Native Client DLL.