Have not we all got the XenDesktop Setup Wizard? But yeah, sure!
it quite impressive how quickly so many VMs for use, may generate as XenDesktop VDAS. But what is provisioned with terminal servers? XenApp to offer the provision as provisioned VM for many reasons: easy patch management, flexible scaling, exact same server (we call it for years) and washable server - no profile, no ActiveX plugin, not a corrupt print job survive Now reboot. The old saying "reboot tut gut" never had more truth.
Sorry requires the use of XenDesktop Setup Wizards a DDC - I know of systems integrators, to replace the rapid creation of many XA VMs a DDC or bring a VM just to run the XD Setup Wizard to. It is the creation of virtual desktop VMs fooled only automates the following steps to let it run:
- creating multiple copies of a template VM on the XenServer
- submit the generated MAC addresses as a target device in the PVS DB
- Numbered right to generate and create AD accounts
I offer these steps as a batch file in this blog entry available maybe even save someone's day :-) Finally we can hereby not only a XenApp generate spontaneously but a bunch of Web servers for a load test, an army of XenDesktop provisioned VDAS for 5 or just a lot of identical VMs for whatever purpose .
prerequisite for the use of "xacreator.bat" is running on a system that has both XenCenter, and the PVS Console are installed. The paths to xe.exe and mcli.exe at the beginning of the batch file must be adjusted if necessary.
is sure to IP, username and password to access XenServer adapted to be - I would just point out discreetly that plain text passwords in a batch file represent a risk. Do you know? Sure.
must also be notified of the name of a template, a PVS and PVS Site Collection.
must also be notified of the name of a template, a PVS and PVS Site Collection.
So, here is the script, as always, copy & paste suitable for batch file (fits through any firewall in each clipboard and can be sent via email - every time, unfortunately, beyond just the pretty layout):
@ echo off rem # # # contact
daniel.wipperfuerth @ adn.de for info / improvements.
echo ######
echo ### script to create provisioned XenApp servers as VMs in
echo ### XenServer and target devices in PVS and computer accounts
echo ### in AD as well.
echo ######
echo.
setlocal
rem ### declaring windows specific variables
rem ### you should customize these
set pass=Password1
set host=192.168.88.21
set user=root
set xecmd="c:\program files (x86)\citrix\xencenter\xe.exe"
set xeparms=-s %host% -u %user% -pw %pass%
set mclicmd="C:\Program Files\Citrix\Provisioning Services\mcli.exe"
rem ### check if programs are available
if not exist %xecmd% goto :noxecmd
if not exist %mclicmd% goto :nomclicmd
rem ### ask some stuff
:gettemplatename
echo Tell me the name of your XA PVS template
echo and please respect that it has to be cAsE sENsitIVE
echo and no spaces are allowed inside
set /P xapvstempname=Enter XA PVS template name:
if "%xapvstempname%"=="" (goto :noxapvstempname)
:gettemplateuuid
for /F "usebackq" %%n in (`%xecmd% %xeparms% template-list name-label^=%xapvstempname% --minimal`) do set xapvstempuuid=%%n
if "%xapvstempuuid%"=="" (goto :noxapvstempuuid)
echo I received %xapvstempuuid% as XA PVS Template UUID.
:getxaprefixname
echo.
set /P xaprefix=Tell me a prefix for the new XAs:
if "%xaprefix%"=="" (goto :noxaprefix)
:gethowmany
set /P howmany=How many XAs do you want to create:
if "%howmany%"=="" (goto :nohowmany)
:getpadding
set /P padding=How many zeros shall we use for padding? (01=1, 0001=4):
if "%padding%"=="" (goto :nopadding)
:getpvssite
echo.
echo Tell me the name of the PVS Site that you want
echo the new XAs to be added to. This name MUST NOT
echo contain spaces.
set /P pvssite=Which PVS site should we add the XAs to? :
for /F "usebackq skip=4 tokens=2" %%n in (`%mclicmd% get site /p sitename^=%pvssite% /f siteid`) do set pvssiteuuid=%%n
if "%pvssiteuuid%"=="" (goto :nopvssiteuuid)
echo I received %pvssiteuuid% as PVS site UUID.
:getpvscollection
echo.
echo Tell me the name of the PVS collection that the
echo new XAs will be added to. This name MUST NOT
echo contain spaces.
set /P pvscollection=Which PVS collection should we add the XAs to? :
for /F "usebackq skip=4 tokens=2" %%n in (`%mclicmd% get collection /p siteid^=%pvssiteuuid% collectionname^=%pvscollection% /f collectionid`) do set pvscollectionuuid=%%n
if "%pvscollectionuuid%"=="" (goto :nopvscollectionuuid)
echo I received %pvscollectionuuid% as PVS collection UUID.
rem ### Point of no return
echo.
echo Everything seems fine so far, i am going to create
echo %howmany% copies of the XenServer VM template %xapvstempname%
echo and add them with their new MAC addresses to PVS collection
echo %pvscollection% in site %pvssite% including active directory
echo computer accounts.
echo.
echo THIS IS YOUR LAST CHANCE TO QUIT.
choice /c qc /m "Quit or Continue"
if not errorlevel 2 goto :end
rem ### do some stuff
FOR /L %%m IN (1,1,%howmany%) DO (
set s=%%m
call :padding
)
goto :end
:padding
call set padded=%%s:~%padding%,1%%
if "%padded%"=="" set s=0%S%& goto :padding
call :xacreator %s%
goto :EoF
rem ### this is the main routine
:xacreator
echo ________________________________
echo Starting cycle %1 of %howmany%
echo ________________________________
for /F "usebackq" %%n in (`%xecmd% %xeparms% vm-install new-name-label^=%xaprefix%%1 template^=%xapvstempuuid%`) do set newxauuid=%%n
echo i created the vm %xaprefix%%1 with uuid %newxauuid%
for /F "usebackq" %%n in (`%xecmd% %xeparms% vif-list vm-uuid^=%newxauuid% params^=MAC --minimal`) do set newmac=%%n
echo the new mac is %newmac%
set mclimac=%newmac::=-%
%mclicmd% add device /r devicename=%xaprefix%%1 devicemac=%mclimac% collectionid=%pvscollectionuuid% siteid=%pvssiteuuid% copytemplate=1
%mclicmd% run adddevicetodomain -p devicename=%xaprefix%%1
goto :EoF
goto :end
rem ### here are the catchpoints if information is missing
:noxapvstempname
echo No XA PVS Template name entered, sorry.
choice /c ra /m "Retry or Abort"
if not errorlevel 2 goto :gettemplatename
goto :end
:noxapvstempuuid
echo No XA PVS Template UUID received, sorry.
choice /c ra /m "Retry or Abort"
if not errorlevel 2 goto :gettemplatename
goto :end
:noxaprefix
echo No XA prefix entered, sorry.
choice /c ra /m "Retry or Abort"
if not errorlevel 2 goto :getxaprefixname
goto :end
:nohowmany
echo No number of machines to create entered, sorry.
choice /c ra /m "Retry or Abort"
if not errorlevel 2 goto :gethowmany
goto :end
:nopadding
echo No number of zeros for padding entered, sorry.
choice /c ra /m "Retry or Abort"
if not errorlevel 2 goto :getpadding
goto :end
:nopvssiteuuid
echo No uuid for the PVS site you entered received, sorry.
choice /c ra /m "Retry or Abort"
if not errorlevel 2 goto :getpvssite
goto :end
:nopvscollectionuuid
echo No uuid for the PVS collection you entered received, sorry.
choice /c ra /m "Retry or Abort"
if not errorlevel 2 goto :getpvscollection
goto :end
:noxecmd
echo I cannot find your xe.exe - please specify location in this batch file.
echo Verify if XenCenter is installed on this machine...
goto :end
: nomclicmd
echo I can not find your mcli.exe - please specify location in this batch file.
echo Verify if PVS Console is installed on this machine ...
goto: end
rem # # # This is the end, my friend.
: end
echo.
echo Done. Press any key to exit.
pause
0 comments:
Post a Comment