Recently Chad Sakac wrote an article on using some PowerShell scripts to quickly deploy VDI replicas. As always, it’s a very good article but I wanted to expound a bit on what he has written and provide more instruction on setup and use. I have had the opportunity to use and demo these scripts lately and wanted to pass along some things that I have learned. The scripts, PowerVDI, were originally written by Dan Baskette, his blog is here.
If you want to see how these scripts function without actually doing it yourself….or to see how they work before starting this I have provided a demonstration video. In this video I walk you through creating 10 virtual workstations and then add 4 more. The video is available here:
The purpose of the PowerVDI scripts is to allow you to quickly and easily deploy new virtual workstations with VDI and an EMC Celerra. They interface with Virtual Center, VDM Server, and the Celerra CLI. Instead of just cloning an existing image these scripts utilize the Read/Write snapshot capability of the Celerra. This lets you deploy a large number of workstations without dedicated a large amount of storage. A deployment of 50 virtual workstations takes little more storage than a single workstation….well, until users start adding applications and data!
If you don’t have a Celerra to play with these scripts work just fine with the Celerra Simulator. Information on downloading the Simulator and getting it set up are available from Chad here.
The scripts automate the following steps:
Currently the scripts do not customize the replica VMs. The gold image should be sysprep’d and configured to join the domain themselves. In the future we should see scripts that take the customization further, similar to what you can do with a Customization Spec to a new VM today.
The required pieces for the environment are:
You will need the following information for configuration:
Pretty simple, eh? Now for the software pieces. You’ll need to download and install these pieces of software:
Installation and Configuration
Download and install all of the pieces listed above. If you don’t use the default directories make sure you edit the .bat file included with the PowerVDI scripts so they run correctly. Once everything is installed open a PowerShell window and type:
This will allow the scripts to run. The next step is to configure putty. Run puttygen.exe and have it generate a private key by randomly moving your mouse. I suggest you don’t do this step via the Remote Desktop client! The update interval is so low that it takes a loooong time to do that remotely. Learn from my mistake… Once the key is finished generating save it to a file named c:program filesputtyprivkey.ppk. That name is VERY important. Next, you should see your key shown. It looks similar to this:
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAvFT6Y1a7R/ TJOxFb2dtzZpURoHQAlnFONQnm7EC3ztMltF 4PZQVXXpZcbN3MSeCsYl677yFplmPGGsE41r 6FLDL6sskOa+eVpxNxwbhyzcvlewrBjRiwJjZwg A9U1vHGokNpUqppbLrUr8hgJ5TXsCFhNMAe7Ww RN5x1CH79K6U= rsa-key-20080730
Copy that text in to your clipboard. Next, open putty.exe and SSH in to your Celerra as the user you plan to use when running the scripts, usually nasadmin. From that user’s home directory you need to create a directory named .ssh (notice the dot).
Next change to the .ssh directory and paste the key in to a new file named authorized_keys. I normally use vi but I know not everyone is a fan. Type “vi authorized_keys”, hit “a”, paste the key (right-click in putty to paste), then hit the ESC key, at the prompt at the bottom type “!wq”. That will write the file and exit. Finally, we need to set the permissions on this new file and the .ssh directory. From the .ssh directory type “chmod 600 authorized_keys”. Change back to your home directory (cd ..) and type “chmod 700 .ssh”. The purpose of this is to allow connections to the Celerra using Putty without having to use a password, instead it uses your generated keys to provide authentication.
One more step and you’re done in Linux. You need to add some PATH variables to the .bashrc file. From the user’s home directory type “vi .bashrc”. Move the cursor down to a blank line and hit “a” and then paste this to the file:
PATH=$PATH:/nas/bin:/nas/admin/bin export NAS_DB=/nas
Finally, hit ESC to exit text entry and then type “!wq” to write the file and exit. You can now log out of the Celerra. You’re done with configuration!
Now you can run the powervdi3.bat file to execute the script. You’ll be prompted for the information mentioned above. If you encounter a problem during execution check the log file created by the script. It will provide the command issued to the Celerra and any response. When the script is run it creates several configuration files holding the information you provided, snapshot names, and VMs created. If you run the script a second time it won’t need to prompt you for the same information. During subsequent executions if you provide the name of an existing VDI Pool it will add new VMs to that pool. If you provide the name of a new pool it will create an additional pool.
If you want to reset your environment and undo anything you did you can use the democlean.bat. Note that this script will throw some errors..and that is normal. Just provide it with the name of the VDI Pool you want to remove. This is useful too if you should have a problem during creation. The democlean.bat will still clean up snapshots are partial machine creations. It uses the information it logged in the configuration files.
Good luck! Feel free to ask questions if you run in to a problem.