Monthly Archives: November 2011

Veeam Backup and Replication v6 Now Available

Open the floodgates and let the masses through.  Today, after being alerted by the twitterverse I noticed that version 6 of Veeams' flagship product Backup and Replication was available for download. (well, for those lucky enough to fight off the traffic and get it)! This long awaited release is exciting for me for a couple of reasons. Firstly, i get to see all of those new features that have been promoted for the last few months through their featured webinars and Anton's' Whats New' document (you can find a summary of my favorites here). And secondly, we now have the support for VMwares' vSphere 5 meaning i have a slew of upgrades to perform over the next little while. (Veeam, vSphere, vCenter, View, Powercli, VMA). Needless to say it is all work that i enjoy doing so it should be a fun xmas for me! That doesn't sound too much like a stereotypical geek does it?

So, off to the races!  Head on over to the downloads section of Veeam.com and get your copy. I'm sure there will be some sort of spectacular launch message soon to follow :), not to mention blog posts of all of the community members upgrade experiences.

DR for your DR Solution – Backing up your Veeam Backup & Replication Database

Last week I published an article based around moving your Veeam Backup & Replication Database to a new server.  In that article I used a backup and restore method to move the Veeam DB somewhere else.  Well, the feedback I received from that article was mostly based around how to setup a scheduled job to backup the Veeam database, so, without further ado, here's how I would recommend doing so.

Connect to your Veeam DB server

First off, we need to initiate a connection to the SQL Server hosting your Veeam DB.  Honestly, it's probably easier just to RDP or console in to the  SQL Server hosting the database and then connect to it.  In my examples below I will be using SQL Server Management Studio to do so.  Just a note, if you are running the default installation of Veeam with SQL Server Express, you can connect to the server using 'SERVERNAME\VEEAM' as your server name and use Windows Authentication.  Otherwise, just connect to your SQL instance as you normally would.

Create the Maintenance Plan

This is a pretty easy step.  Once you are connected just create a new maintenance plan by expanding Management -> Maintenance Plans.  Right click on Maintenance Plans and select New Maintenance Plan.  You could also select to go through the wizard, but again, for this example I chose to create it from scratch.

Create the Backup Database and Maintenance Cleanup tasks

You should now be in what is called Design Mode of the maintenance plan.  In the bottom left hand corner of your screen you should see all of the Design Tasks that we are able to just click and drag over to our Design Surface in the centre.  Here is where we need to setup our first task which is to do the actual backups of our databases.  Simply select the Backup Database task and drag it over into our Design Surface.  Do the same with the Maintenance Cleanup task as well.

Configure the Backup Database Task

Ok, we are now getting into the meat of this job.  Double click the Backup Database task that we just moved over.  Here is where we will setup all of our parameters evolving around our backups.  First off we need to select our connection.  In most cases this can just be left at 'Local Server Connection', however depending on how you are setup you may need to enter in the actual hostname or IP of the server.  Leave the backup type set to Full.  Under the database(s) section is where you can select which databases you would like to backup with this job.  You can just select the Veeam DB if you want, but I chose to select 'All Databases'.  Back up to – Select your target, usually disk nowadays.  I left the expiration of the backup sets at the default, which is to not expire.  Check the create a backup for every database, and in this example I've also checked the subdirectory for each database as well.  I just find this to be a bit more polished when browsing through the backups πŸ™‚  You can use whatever you want for the backup extension, but the standard for SQL is 'bak'.  Select a location to store the backups, click 'OK' and your done.

Configure the Maintenance Cleanup Task

This step can be skipped if you want but you will have to watch your free space.  In this step we will set the job to 'clean up after itself' by deleting backups that are a certain number of days or weeks old.  Again setup your connection the same as you did in the previous step.  You will also want to select to 'Delete Backup Files'  Select 'Search folder and delete files based on an extension' and setup the folder the same as above. Select to include first-level subfolders.  Enter in our file extension the same as above (bak).   Select your desired retention policy under the 'File Age' section.  I usually chose somewhere along the lines of a couple of weeks depending on the importance as well as the free space on the backup targets.  After all this is setup click 'OK' to save your cleanup task.

Connect the two tasks together

Here's an easy one for you.  If you single click on the Backup Database Task you will see a green arrow appear underneath it.  Simply drag that arrow over to the Maintenance Cleanup Task. You could also take the vice versa action on this one.  You could have the single click the Cleanup Task and drag arrow to the Backup Task.  Either way, whichever one task runs first you should end up with the same results.

Schedule the plan

Click the schedule button in the Maintenance Plan toolbar.  In the job schedule dialog that opens select the required times and frequency that you wish to run this job and click 'OK' to save the schedule.  The schedules are very flexible and allow for virtually every scheduling combination that you can think of.

This is all the modification that we need to do so just save your maintenance plan by going to File -> Save Selected Item or by right-clicking the tab at the top and selecting 'Save'.

Check the Agent and Test.

If you now have a look under the your SQL Agent by going to SQL Server Agent -> Jobs you should see that a new agent job has been created with a name similar to that of your maintenance plan.  You can right click on this job and select properties.  You should see your schedule as well as the SSIS call to run your maintenance plan.  If you would like to test your backup job now, simply right click your job and select 'Start Job At Step'.  This should popup a dialog showing you the status of the job.  Once completed you should see some backups in the target backup locations you inputted earlier.

So there you have it!  DR for your DR Solution.

Access to VM Console without the vSphere Client

How can I grant access to the console of a VM to an end user without requiring them to install the vSphere client? How do I grant one of our vendors or partners access to the console of a VM without allowing them to see all of our guests?. I see questions like these pop up on the VMTN forums over and over again and I always answer it the same. Generate a VMware Remote Console URL! Or I guess a Virtual Machine Shortcut would be the official wording for it. Basically a Virtual Machine Shortcut is simply a URL that you can generate through vCenter Web Access which would allow anyone(with authentication of course) to connect to the console of a VM using only a supported browser. Now I say supported browser due to the fact that a plug-in needs to be installed in order to view the VM console. Currently supported browsers include only Microsoft Internet Explorer and Mozilla Firefox.  I'm not even sure of the versions that are required as I can't seem to find any documentation around the plug-in itself.  The end user will also need to have valid permissions set up within vCenter on the targeted VM. As long as the end user meets those two requirements then actually generating the URL is pretty simple and straightforward.  And here's how…

Login to the vCenter Web Access by pointing your browser to https://ip-of-your-vcenter-server/ and select the 'Log In To Web Access' link in the top right hand corner.

From here, after you are logged in you will have to navigate on the left hand side through your datacenters and folders until you locate and select the VM you would like to grant access to.  Once the VM is selected you should see the 'Generate Virtual Machine Shortcut' option under the commands section on the summary tab.

Once the Generate shortcut link is clicked you will be presented with the actual URL and a few options.  Here is where you can do things like hide the event log of the selected virtual machine, as well as limit the view to that Virtual Machine only, and obscure the URL that it generates as well to make it harder to guess.

Simply send this URL to your end user and once they have entered this address into a browser they should be good to go and you should be happy that your work is done.  All they need to do is copy/paste that URL into either IE or Firefox and they should be presented with the console of the VM.

What I'm not sure of, and might be a good idea to have, is the ability to have these URLs expire or time-out.  I don't think you would want them just hanging around forever. πŸ™‚

Moving your Veeam Backup & Replication Database

As you are probably are aware, in the beginning there are few VMs.  People start out by virtualizing their low flyers, web servers, etc..  As time goes on there is something called VM sprawl which occurs.  Suddenly there are many many VMs being spun up for no real reason at all.  Tier 1 apps make there way into your vCenter, and things begin to grow exponentially.  The problem with this, is that sometimes you have solutions installed from the beginning which were initially setup in the 'small' environment you had in the beginning.  As is the case with my Veeam installation.  When I first installed it, I just used the SQL express option that came with it.  Now, since the environment has grown, and the stakes are higher when failures occur, I have the need to move this database from its' default SQL express to a full blown version of SQL that is managed by all of our monitoring and backup tools.  Below is just how I did that…

First off, you will need to get your hands on a copy of SQL Server Management Studio.  We will need this in order to perform the backups of the SQL express databases that Veeam has created.  You can find 2005 here and 2008 here.

After you have installed this on your Veeam server just follow the steps below to move your database.  Oh, and be sure to stop and / or disable any running jobs or jobs that may run while you are performing these actions.  It's probably best to just disable all of them until you are done.

Stop Veeam Services

We will need to stop (and I disabled) all of the Veeam Services.  Don't worry, when we get to re-installing the Veeam applications later the services will be re-enabled again.  The reason for this is that we do not want any data flowing into our database as we are backing it up and moving it.  You will need to stop the following services; Veeam Backup Enterprise Manager, Veeam Backup Service, Veeam Indexing Service, and the Veeam vPower NFS Service as shown below

 

Backup your VeeamBackup database

​Once the services are stopped it's time to get going on backing up our Veeam databases.  Veeam has 2 databases that it uses; VeeamBackup and VeeamBackupReporting.  We will need to back both of these up in order to restore on our new SQL server.  So, fire up SQL Server Management Studio and find the VeeamBackup database and follow the following

steps.

  • Right-Click
  • the VeeamBackup database and select Tasks->Backup
  • Make note of the location near the bottom where its' going to save the backup
  • file.
  • Click
  • 'OK' and browse to the targeted location and copy the backup to your new SQL server.

You will need to repeat the bulleted points above for the VeeamBackupReporting database as well.

Restore on your new SQL server as the same name

Now that we have the backups on the new SQL Server we will need to restore them.  The following is how I did

it.

  • Right-Click
  • Databases and Select Restore
  • in the 'To Database' field we will want to type the name of our target database.  I would just use the same name as it was before – 'VeeamBackup'
  • Here we need to select 'From Device' and then 'Add' our backup file that we have just copied
  • over.
  • After
  • we have added our file, be sure to check the checkbox under the Restore heading.
  • Check out the settings on the Options tab.  Here is where you will want to check to be sure that the mdf and ldf files will restore to the locations that you want them to.
  • When your happy, click 'OK'

Again, we need to repeat this for the VeeamBackupReporting database as well.

Security Setup

Depending on how had Veeam setup before, this may or may not need to be done, or it may need to be done in a different way.  Essentially the user that you are going to run the Veeam installation as will need to have db_owner rights to both of these databases.  So if you installed Veeam as a local user account previously, you might want to think about creating and using a domain account this time around, as now we have two servers that we need to authenticate on.  However you decide, you will need to grant that user dbo rights as follows…

  • Under Security->Logins, right click and select New Login.  Browse to the windows user account that you want to use.
  • In the 'User Mapping' section, select both VeeamBackup and VeeamBackupReporting and ensure that the db_owner role membership is checked off.
  • Also in that section, assign the Default Schema for both of those databases to dbo.

Remove and Re-Install Veeam

There may be other ways to 're-point' Veeam to the new database server (registry hacks), but for all intensive purposes it takes literally less than 5 minutes to install Veeam so i found this the easiest route.  Go into control panel and remove both Veeam Backup and Replication and the Veeam Enterprise Manager.  Once done, re-install both of these applications.  When prompted for your database location enter your desired information to point to the new SQL Server.  You should be prompted that a Veeam server is already connected to the database, when asked this just select 'Yes' to connect this (the new installation) server to the database instead.

And it's that easy!  You know have a more expandable database and the ability to utilize more RAM and CPU.

Just a note, I cannot guarantee that this will work for you…it worked great for my environment!  If in doubt, open up a support call with Veeam and have them give you a hand or directions to do so…  Also, if you are looking for a way to automate a backup of your Veeam Database, check out this post.

Veeam v6 – What’s New

So, Veeam one of the industry leaders in virtualization backup and data protection seem to be getting closer to the release of there anticipated version 6 of the Veeam Backup and Replication.  They've released the official What's New document outlining a slew of enhancements and new functionality that will be included with the version 6 of their flagship Backup and Replication product.  It's nothing new, as Veeam have been promoting the functionality of v6 with a series of webinars and sessions in the last few months, but its still nice to have all of these enhancements all combined together in one document.

Needless to say one of the biggest features of Veeam v6 is the Multi-Hypervisor support.  As of version 6 Veeam will now support both VMware and Microsoft Hyper-V all from the same interface.  Since I'm not a Hyper-V user I'll leave it to you to read up on the supported functionality yourself, but I'll touch on a few other of my favorite features below…Keep in mind, I've yet to use to use or see the product, so my opinions are purely based upon what I have seen in the webinars or read, so the final product could differ from what I think it will be like…
 
Scalability – Veeam has completely redesigned their backup architecture in v6.  With that they have the addition of backup proxy servers which offload the backup and replication traffic to the proxy server instead of the actual backup target.  This will allow for the use of a load balancing algorithm that splits the load amongst proxy servers, and in turn, allows for more concurrent jobs to run and faster backup speeds.  In terms of replication, the on-site backup proxy server can now send data directly to the target backup proxy server, completely bypassing the Veeam server itself.
 
1-Click Happiness – Veeam has simplified a lot of their processes by creating a bunch of 1-click functionality.  Veeam has added 1 click events to their Instant Level File Recovery, Failover, Failback, VM Restore, and Automated Upgrades.  Perhaps the most useful '1-click' event will be with the Instant Level File Recovery.  Prior to v6 I found this to be a monotonous task involving many steps and approvals to restore a file to a VM.  It will be nice to be able to do this with 1 click.
 
Backup Targets – Along with the Linux Backup Target, you can now set a Windows box as your backup target.
 
Traffic Throttling – In essence this allows you to do just that…throttle the Veeam Backup traffic.  This can be done via time based or day based as well.  This way we can guarantee what bandwidth will be used for Veeam traffic, and guarantee that we are not interfering with other traffic that might be flowing across a WAN link.
 
Wan Optimizations – There has been a lot of work done with WAN optimization, it appears in quite a few of the enhancements on the What's New document.  Essentially they have improved and optimized the protocol used to transfer data across a wan, allowed for multiple TCP/IP connections per job, and with the addition of the the traffic throttling, proxy architecture and windows targets you have no excuse to not get your data off-site.
 
Parallel Backup and Replication – An individual VM can now be processed by both a backup job and a replication job at the same time.  This eliminates the need to put your replication jobs on hold in order to satisfy a backup window. πŸ™‚
 
Replica Termination – In v5 and below, when a job was terminated, it would leave your latest restore point unusable until the next time the job ran.  In v6, this will roll back immediately, always leaving your latest restore point in a good state and able to power on.
 
1-click permanent Failover – This is something that was manual in previous versions which I documented here.  Now this all can be done with one click, to permanently failover to your replica.
 
Active Rollbacks – The restore points of a replica are now stored as native VMware Snapshots, leaving you with the ability to revert to a previous point in time without using the Veeam Backup and Replication server.
 
Improved Seeding – You can now use previous VMs located at your target site, or backups at your target site as the seed for your replica job, allowing you to start replication in an incremental fashion, rather than waiting for the first big initial seed of your VM.
 
Re-IP – one of the biggest and coolest enhancements in my book.  The ability to automatically re-ip your VMs at a DR site to align with your networks there.  Very cool.
 
Cluster Targets – Hey, we can now replicate to a cluster as well as a host.  Basically, if your replica target is a cluster and you lose a specific host, your replica job can continue to run as it's pointing to a cluster…
 
VM Migration – I'm not to sure what this is, as it seems to be new to v6.  In essence, it looks very similar to Storage vMotion in the way it will copy a running VM, and then copy just deltas that have changed during the first initial copy.  This could be very beneficial to those SMB's or ROBO offices that do not have Storage vMotion licensed.
 
VM Restores – There have been a number of enhancements in the line of restores.  Again, more 1 click options, the ability to restore multiple VMs at once, more options around the use of attaching the restores to Networks, as well as the Unique VM identifier will now remain unchanged when restoring the VM overtop of itself.
 
NTFS Permission Preservation – The permissions and ownership of files and folders restored to a Windows server can now be preserved during the restore πŸ™‚
 
UI Enhancements – The real-time stats window will now show more counters.  The job reports will now show the amount of changed data as well as compression and de-duplication ratios.
 
VM Ordering – You can now specify the order in which the VMs will be processed.  This is a small but nice thing to have.
 
Multi-User access – Multiple users can now access the Veeam server through RDP.  Before, if you left the Veeam application running, you would have to kill the old process before you could get into the application.
 
Again, I want to stress that I haven't tested or seen any of these enhancements and I hope I got them all correct.  Be sure to comment if I got anything wrong…
 
IMO, Veeam continues to release quality software that is incredibly intuitive and easy to use.  The ability to take the complex tasks of performing all of these functions and wrapping them up into '1 clicks' surely is amazing, and Veeam is doing a great job at doing so…  The functionality that v5 of Backup and Replication brought to the table was truly amazing, and i didn't know how they were going to top it with v6, but according to this document and what I have seen so far, it appears they have done so…  Good Work and Can't Wait!

The number of virtual devices exceeds the maximum for a given controller!!

Yes, that's the error I was presented with this morning after attempting to clone a new VM from a template. The number of virtual devices exceeds the maximum for a given controller!!

It's such a great error message, so explanatory. immediately I went to look at the number of drives in the VM, thinking maybe it has too many virtual disks or is attached to some other virtual disk or something, however, it only had 2….so, once again I turn to my pre-vmware support techniques (Google).

So, results pointed me to this KB article. Easy enough fix right, don't edit the hardware while cloning. which after some digging was exactly what had been done. Well…problem solved right?  Not really…

I looked at a few of the other google results, which all pointed to converting the template back to a vm, and selecting the correct network. I thought I would do this, as some of our templates still had the old default 'VM Network' attached to them, and since then we have added some different VLAN networks, which were our new default vm networks. So, hey, lets just do it anyways, templates were probably in dire need of some updating anyway.

So, convert to VM, right click -> Edit Settings…. Lets have a look….

or not!!!!

PropertyCollector.RetrieveContents for object "propertyCollector" on vCenter Server blah blah blah….of course….that's what's wrong with it…

So….what to do now…a few more google searches and the old remove/add trick and I'm back in business…

Basically, right click the VM -> Remove from Inventory. Then, browse the datastore that the VM lives on, right click on the .vmx file and 'Add to Inventory' and I was back in business….

I could once again edit the settings of that VM. By the time I got around to this however, I was tired…and couldn't remember what I was looking for in the first place…right, the networks…Nope! They were fine…However after completing all these steps I was able to do a successful clone.

Horizon App Manager 1.2 & ThinApp 4.7 Released.

Today VMware has announced the release of ThinApp 4.7 along with the release of Horizon App Manager 1.2.  Seems fitting that they were released at the same time as now ThinApp has the ability to package applications specifically for Horizon, and Horizon has added the support to catalog ThinApp Windows applications.

Before 1.2, Horizon App Manager was an app catalog which could be used to deliver a single sign on experience with active directory integration in order to publish SaaS apps such as Google Apps and box.net to end users.  With the ability to now publish those Windows applications that are used on a daily basis, I can see usage of this product ramping up.  

Essentially the horizon administrators manage what applications (both SaaS and ThinApp Packages) that the end users will see by tying the applications to Active Directory or Horizon specific groups of users.  From there and end user will log into the web portal using their AD credentials and click on their specified application.  Horizon then pulls the ThinApp application from the ThinApp repository and pushes it down to the client machine where it is stored for offline mode, and the appropriate shortcuts and start menu items are created.  From then on, if there is updates to the ThinApp packages, they are pushed down upon the end users next visit to the web portal.  Eric Sloof has a much more in-depth and technical explanation of the whole process here.

A lot of the big buzz from VMworld this year was centered around Project AppBlast which essentially allowed end users to stream ThinApp applications through the likes of Java and HTML5.  Although these releases still do not support any streaming, they are definitely a huge stepping stone to the completion of Project AppBlast.

More information on the Horizon App Manager release is available one the End User Computing Blog, while the ThinApp release is on the ThinApp Blog.  There is also a nice architecture video worth checking out below.

Christmas comes early for the VMware Community

Well that special time of year is coming around again.  Family, friends, turkey, beer, rum, excited kids, and more rum.  At least that is what Christmas is like for me.  Anyways, it seems as if the VMware community is starting to celebrate a little early this year with a couple of contests and great giveaways happening right now.  So, without further ado….

Vladan Seget (@vladan) over at ESX Virtualization has what he calls The biggest Contest ever organized at ESX Virtualization happening right now!  The grand prize being handed out there is a couple of NFR lisenses of the upcoming release of Veeam Backup and Replication v6.  Along with the licenses he is also handing out a copy of Trainsignals' VMware vSphere 5 training and a copy of Scott Lowes Mastering VMware vSphere 5.  So don't miss out on this one…head on over to ESX Virtualization now and get yourself entered.

And then there is the ever so entertaining Chad Sakac (@sakacc) who is handing out quite the slew of prizes over at his blog Virtual Geek.  Honestly, there is too much stuff to even list that he is handing out but just a short list includes some SSD's, Iomega IX2's, IPADs…there was one more give-away….oh yah, and EMC VNXe 3300…Wow!  Get over to Virtual Geek and complete the survey before it's too late..

Good Luck & Merry vXMAS

Migrating vCenter to a new server

Maybe its during the upgrade from vSphere 4.0 to 4.1 and you require the 64 bit hardware. Maybe you need to upgrade to take advantages of a newer OS and you just don't trust the next next done that Microsoft provides you. Maybe its the fact that you currently have a physical vCenter and you want to take advantage of VMware High Availability and Distributed Resource Scheduler. Or maybe its the complete opposite and you are currently virtualized and you have your reasons to be physical. Whatever your reasons may be, there will more than likely be a time where you as a VI admin will want or have to migrate your vCenter to a new server. In my case, it was option number 4.

We had been running a virtualized vCenter ever since our upgrade to vSphere 4, however with the addition of the Distributed Virtual Switch, along with more and more third party applications depending on vCenter, coupled with a failure that left me unable to assign a vm to a network I just thought it was time to move our vCenter Server outside of the cluster that it was controlling. The decision to go physical was purely an overkill, but i wanted to have my vCenter completely disconnected from the san fabrics and interconnects that are currently the interworkings of our i/o flowing in and out of our hosts. I had read about the recommendation of management clusters, but the costs of building that would for sure outweigh the advantages of having it virtualized. Also, this will give us a central spot to house our PowerCli scripts and also run our UPS shutdown scripts from. So, physical it is, and here is my plan to get there. It wouldnt have been much of a concern but i wanted to have a solution where the dvSwitches would continue to function, and where i wouldnt need to go and touch every host afterwards. So, assigning this new physical vCenter the same name and same IP was a key step. Since i wanted to ensure a smooth transition i ran this one through the lab first using these steps. So here is what i had. vCenter1 (the current active vCenter) and vCenter2 (the new vCenter).

1. Get everything that you need (vCenter installation, 64 bit sql native client, sysprep files, etc). If vCenter1 is virtualized be sure to take note on which host its running on as you will need to disable or disconnect its network later on.
2. When you are ready to go stop the vCenter service on vCenter1.
3. Now we need to disconnect or disable the network on vCenter1.
4. Delete the current computer account for vCenter1 from active directory. I assume you could also just rename it, i just chose to delete the account.
5. Now lets move over to vCenter2 and do a few things. Rename this machine to vCentre1 and also give it the same ip as vCenter1. This should ensure that we don't have to ssh into each host after the upgrade and touch the hosts file.
6. Now just complete the installation of vCenter on vCenter2 which is the now vCenter1. (Confused yet?). Note – when asked about the database be sure to select to use the existing db, otherwise you can kiss all your hard work goodbye.

Thats all, you should be able to connect to your new vCenter instance using the same name or IP as you always have. You may have to reconnect your hosts however, as a new password for the vpxuser would have been generated with the new install and the hosts and vCenter will be out of sync. Thats as simple as right clicking your host, selecting connect and providing root credentials though. There you have it, a brand new vCenter! While your at it you might as well defragment your vCenter Server database as well to give it that snappy new feeling again. Also, there is a KB article which takes you through some of the steps above here. As always if you notice anything that I'm lacking or if I'm performing actions that will cause the market to crash please comment and let me know.

The Resource Pool Priority Pie Paradox – Part 3 – The Powershell Code

Part 2 – The 4:1 Formula
Part 3 – Powershell Scripts

So in parts 1 and 2 of this series I explained (hopefully) what the resource pool priority pie paradox is and how to punch some key numbers into a formula and figure out what exactly you could set for custom shares on a production and test resource pool in order to come out with that 4:1 ratio.  In this part I'll show you how you can get those numbers from your own environment using the VMware PowerCli without having to do the math yourself.

Just a note, for the script to work you must only have two resource pools, which you assign to variables at the beginning of the script.  Along with the resource pools you need to assign your vCenter server name as well as the cluster name.  You may also need to pump in your credentials if you aren't running this from a trusted client.

Anyways, the script is below, feel free to modify as you please.  If you see a spot where I could be more efficient or if I'm doing anything completely crazy let me know…  You can also download it here if you don't feel much like copying and pasting..:)

#################################################################################
# ResourcePoolPie

#
# This script will poll look at VMs residing in a production and a test resource
# pool and determine how to best set the custom share value in order to maintian
# a 4:1 Production:Test ratio.  Note, you must be setup in a Production and Test
# Environment inside of one cluster.  Its kind of unique to my environment and
# may not apply to everyone elses, but feel free to change and modify what you
# need in order to make it work for you.
#
# The following variables will need to be assigned
#
#   $vcenterserver = ip address of vcenter
#   $clustername = name of cluster containing resource pools
#   $prodname = name of production resource pool
#   $testname = name of test resource pool
#
# Created By: Mike Preston, 2011
#
#
#################################################################################

Add-PSSnapin VMware.VimAutomation.Core
# Assign appropriate values to following variables.
$vcenterserver = ""
$clustername = ""
$prodname = ""
$testname = ""
# establish connection to vcenter server
$connection = Connect-VIServer $vcenterserver
# get cluster information
$clus = get-Cluster -Name $clustername | get-view
# get resource pool information
$prodpool = Get-ResourcePool -Location $clustername -Name $prodname
$testpool = Get-ResourcePool -Location $clustername -Name $testname
# get a list of vms in production and test
$prodvms = get-vm -Location $prodpool | where { $_.PowerState -eq "PoweredOn" }
$testvms = get-vm -Location $testpool | where { $_.PowerState -eq "PoweredOn" }
# initialize counters to zero
$totalprodcpu = 0
$totaltestcpu = 0
$totalprodmem = 0
$totaltestmem = 0
# loop through production pool and total cpu/memory
foreach ($vm in $prodvms)
{
    $totalprodcpu = $totalprodcpu + $vm.NumCPU
    $totalprodmem = $totalprodmem + $vm.MemoryMB
}
# loop through test pool and total cpu/memory
foreach ($vm in $testvms)
{
    $totaltestcpu = $totaltestcpu + $vm.NumCPU
    $totaltestmem = $totaltestmem + $vm.MemoryMB
}
# Begin CPU calculations
Write-Host "CPU Configuration"
Write-Host "=========================================================="
write-host "Production Pool contains" $prodvms.count "Powered On VMs containing" $totalprodcpu "cpus"
write-host "Test Pool contains" $testvms.count "Powered On VMs containing" $totaltestcpu "cpus"
write-host "Cluster has" $clus.summary.effectivecpu "MHZ to hand out"
#populate variables for formula a(4w-3x) = nx

 

$a = $totalprodcpu
$w = $clus.summary.effectivecpu
$n = $totalprodcpu + $totaltestcpu
Write-Host ""
# lets solve x πŸ™‚
Write-Host "Lets plug these numbers into our formula and solve x (Production Share)"
Write-Host "a = total number in production, w = total resources, n = total number in prod and test"
Write-Host "——————————–"
Write-Host "a(4w-3x) = nx) "
Write-Host "$a(4($w) – 3(x)) = $n(x)) "
# lets get some tmp vars initialized
$tmp1 = 4 * $w
Write-Host "$a($tmp1 – 3x) = $n(x)"
$tmp2 = $a * $tmp1
$tmp3 = 3 * $a
Write-Host "$tmp2 – $tmp3(x) = $n(x)"
$tmp4 = $n + $tmp3
Write-Host "$tmp4(x) = $tmp2"
$prodpoolresources = $tmp2 / $tmp4
Write-Host "x = $prodpoolresources"
Write-Host "——————————–"
$prodpoolresources = [Math]::Round($prodpoolresources,0)
$testpoolresources = $w – $prodpoolresources
$prodsharepercpu = $prodpoolresources / $totalprodcpu
$prodsharepercpu = [Math]::Round($prodsharepercpu,0)
$testsharepercpu = $testpoolresources / $totaltestcpu
$testsharepercpu = [Math]::Round($testsharepercpu,0)
# Display recommendations
Write-Host "Recommended Share setting for production $prodpoolresources Mhz split between" $prodvms.count "Vms with" $totalprodcpu "cpus resulting in" $prodsharepercpu "Mhz per cpu"
Write-Host "Recommended Share setting for test $testpoolresources Mhz split between" $testvms.count "Vms with" $totaltestcpu "cpus resulting in" $testsharepercpu "mhz per cpu"
# Begin calculating Memory
Write-Host "=========================================================="
Write-Host "Memory Configuration"
Write-Host "=========================================================="
write-host "Production Pool contains" $prodvms.count "Powered On VMs containing" $totalprodmem "MB of Memory"
write-host "Test Pool contains" $testvms.count "Powered On VMs containing" $totaltestmem "MB of Memory"
write-host "Cluster has" $clus.summary.effectivememory "MB of memory to hand out"
#populate variables for formula a(4w-3x) = nx
$a = $totalprodmem
$w = $clus.summary.effectivememory
$n = $totalprodmem + $totaltestmem
Write-Host ""
# lets solve x πŸ™‚
Write-Host "Lets plug these numbers into our formula and solve x (Production Share)"
Write-Host "——————————–"
Write-Host "a(4w-3x) = nx) "
Write-Host "$a(4($w) – 3(x)) = $n(x)) "
# lets get some tmp vars initialized
$tmp1 = 4 * $w
Write-Host "$a($tmp1 – 3x) = $n(x)"
$tmp2 = $a * $tmp1
$tmp3 = 3 * $a
Write-Host "$tmp2 – $tmp3(x) = $n(x)"
$tmp4 = $n + $tmp3
Write-Host "$tmp4(x) = $tmp2"
$prodpoolresources = $tmp2 / $tmp4
Write-Host "x = $prodpoolresources"
Write-Host "——————————–"
$prodpoolresources = [Math]::Round($prodpoolresources,0)
$testpoolresources = $w – $prodpoolresources
$prodsharepermb = $prodpoolresources / $totalprodmem
$testsharepermb = $testpoolresources / $totaltestmem
# Output results
Write-Host "Recommended Share setting for production $prodpoolresources MB split between" $prodvms.count "Vms with" $totalprodmem " MB of RAM resulting in $prodsharepermb shares per MB"
Write-Host "Recommended Share setting for test $testpoolresources MB split between" $testvms.count "Vms with" $totaltestmem " MB of RAM resulting $testsharepermb shares per MB"
Write-Host "=========================================================="

 

 

Part 2 – The 4:1 Formula
Part 3 – Powershell Scripts