Monthly Archives: May 2013

Friday Shorts – vClouds, Veeammy Secret Features, DMZ stylin, Sysprep

So join now, ’cause at the Derek Zoolander Center For Kids Who Can’t Read Good And Wanna Learn To Do Other Stuff Good Too, we teach you that there’s more to life than just being really, really, really good looking. Right kids?!. – Derek Zoolander from Zoolander

Veeam keeps packing on features

veeam_logoOn Monday of last week, Veeam announced a couple of pretty cool new features that will be bundled in with the others that they have been slowly releasing over the last few months. One question that i have seen come up many times in the Veeam forums, sometimes even authored by myself is what the best way to get your backups offsite may be. Well Veeam has answered that with their very own wan acceleration and data movement options. Yup, your backup vendor is not only providing you with the option to move those backups offsite, but are now providing you with the most efficient way to do so. Veeam is slotted to be GA sometime in Q3 of this year! Cant wait! In the mean time have a look at what Veeam has put together for their monthly draw, a pretty sweet mobile lab that I wouldn’t mind getting my hands on.

DMZ and VMware vCloud Networking and Security

VMware LogoYou know vShield right? Ever wonder what VMwares’ recommendations are about how to properly design, configure, secure and deploy a fully virtualized DMZ are? If yes then you are in luck! A new technical whitepaper was put out this week titled Securing the DMZ with VMware vCloud® Networking and Security. This is no marketing stuff either. When they call it a technical paper they mean it. You will see how to setup the firewalls, the access rules, logging, VLANS, etc. Be sure to check it out!

The VMware clouds are rolling in

vCloudAs Im sure all of you have heard by now VMware has launched their own hybrid cloud model and added yet another acronym to their portfolio. The vCHS, or VMware vCloud Hybrid Service is supposed to hit a sky near you sometime in June. IMO I see this as a valid offering from VMware. One can only hope that the familiarity and comfort of the vSphere and vCloud will help to drive adoption. Certainly worth a look if you are a current vSphere customer

And in a tribute to the gloomy last 30 days or so before the Google Reader exit I thought I would try and include some of the many blog posts that I read on a daily basis and star inside of it. So without further ado i give you….

Sh!t I’ve Starred

vExpert – What it means to me!

vmw_logo_vmware-expertThere have been a ton of vExpert posts over the last few days since the announcement of the 2013 recipients so I’m just going to throw another one into the fire!  Once again I’m stoked to be nominated as a 2013 vExpert!  I find it amazing to look at my growth over the last three years and am proud of how far I’ve come, both professionally and personally and a big part of that is a direct result of this community.

So a big thank you to VMware, John Troyer, and the rest of the community team and most importantly the community itself.  I’ve always said that my main reason for starting this blog, doing those VMworld/VMUG presentations, evangelizing technology in general is not to gain titles like vExpert (although I’ll take it, it’s pretty sweet) it was to simply give back to the community that I’ve gained so much from.

More so than the title, it’s really the retweets, the comments, the thank you emails, the suggestions, the help and the feedback that I get from all of you that makes all of this worthwhile and self fulfilling.  Also big congrats to all of the new and returning vExperts!  There is a lot of them which is super awesome!  Honestly it’s a great group of people with a lot of brain power and its’ quite humbling to have my name listed next to some of them!  Big grats also going out to my fellow Toronto VMUGers Angelo Luciani and Eric Wright – well deserved on their parts!

So once again Thank You and cheers to another vYear!

Mike

My First vCenter Orchestrator Workflow – Part 6 – Resources

booksOK!  Finally the end of this series!  Honestly without the existence of the following resources there is no chance in hell that I would have been able to even develop a simple workflow, let along start scripting and what not.  I was a couple weeks into vCO before I even learned that you can switch to ‘design’ mode 😉

So, if you are looking for some awesomeness on vCO, have a look at the following…

Official vCenter Orchestrator Documentation – Should really be your first go to reference for all that is vCO

Automating vSphere with VMware vCenter Orchestrator – Although official docs SHOULD be your first go to item – I find that this book written by Cody Bunch actually IS my first go to reference.

www.vcoteam.info – Great blog with a ton of script examples and whatnot!  Bookmark this…

www.vcoportal.de – Ditto to the above line, might better bookmark this on while you in your bookmarks…This is a fabulous blog!

VMware vCenter Orchestrator blog – the official blog from VMware centered around vCO.

VMware API and SDK documentation – this always helps when trying to determine what type of objects or properties any given function requires.

Good Ol’ Twitter – Follow @cody_bunch, @josh_atwell, @vCOteam, @technicalvalues – there are a ton more but these are the ones that I can think of off the top of my head – just search for #vCO and find someone to ask your question to – community seems to be always willing to help.

Thanks for reading and hopefully you can find some usefulness out of vCO as I did!  I encourage everyone to explore what it has to offer, which the same results, everytime!  Check out the full series below…

My first vCenter Orchestrator Workflow

Friday Shorts – #Veeam SureReplica, #TOVMUG wagging, Au Revoir Les Habitants!

And now a 24th Stanley Cup banner will hang from the rafters of the famous Forum in Montreal! The Canadiens win the Stanley Cup!. – CBC’s Bob Cole in the dying seconds of game 5 of the 1993 Stanley Cup Finals

Veeam v7 adds SureReplica

veeamlogoVeeam has announced another feature of their upcoming release of Backup and Replication v7.  This time, applying the virtual lab and their SureBackup technology to your Veeam Replica’s – SureReplica.   A lot of environments I have seen that use Veeam use it to backup locally and replicate to a DR site.  So being able to put all of those dedicated resources in your DR site to work and spin up those replica’s inside isolated labs is a pretty awesome feature.  Aside from simply ensuring the integrity of the replica there are many use cases for an isolated virtual lab.  Think of things like patch management testing, application update testing, penetration testing, the list goes on and on!  This was only the 7th feature unveiled of v7 and Veeam has a couple more to showcase before finally releasing the product sometime this year 🙂   Sign up if you interested in being on of the first to know the new features.

TOVMUG Represent!

TorontoVMUG1-300x79You can’t be involved in the virtualization community and not know about Mike Lavericks’ chinwags!   If you don’t, certainly his latest one with Toronto VMUG Leader Angelo Luciani is a good one to start out with.  They had a great conversation in regards to VMUGs and community participation.  I’d definitely recommend checking it out!

Hey!  They were supposed to be 14th!

No surprise to anyone that follows me, or even reads the odd rant on this blog that I’m a huge Montreal Canadiens fan.  Well last night was a hard one to swallow but the team I’ve watched rally to 2nd place in the East were eliminated from the playoffs.  As much as I’d like to place blame on the refereeing, the 6 key injuries, the horrible icing calls, the fact of the matter is the Habs just weren’t good enough and Ottawa wanted it more.  Also they ran into some pretty steller goaltending by Anderson and it’s hard to beat that.   Either way its been nice to see that spark back into the Habs lineup, the one that used to be there when I was a kid.  For once in the last 10 years it’s evident that the habs have a future ahead of them with some great young players.  Au Revoir Les Habitants.  Lever Le Flambeau!

168444904_slide

My First vCenter Orchestrator Workflow – Part 5 – A little bit of SQL

orchestratepart5Thus far in this series of posts we have installed and configured vCenter Orchestrator as well as setup and utilized a couple of plugins; the vCenter plug-in and the PowerShell plug-in.  Before the series ends I wanted to go through one more plug-in.  The SQL plug-in.  The SQL plug-in is used for, well, you guessed it; running SQL queries against a database.  If you remember in Part 4 we setup a workflow that took two input parameters; a host and a location code.  The script then went on to create a new port group on a vSwitch named locationcode-VM_Network.  The logic in itself works fine and the workflow validates, the only problem I see with it is that the user needs to enter the ‘location code’ manually as an input.  Now I know you are all very careful and take your time when doing things, but I’m not, and more than likely after doing this 40 or 50 times you can count on me keying in that location code wrong 🙂 – Enter the SQL plugin.

So the setup is as follows; I have a database containing a table with the following columns; locationcode and deployed (boolean).  What I would like to do is have an input parameter that would allow me to select the location code from a list of non-deployed locations in a drop-down box (rather than manually enter this information in), and in turn pass the location code to my PowerShell script.  Once the script has ran I’d like to update the deployed column for that specific location, ensuring it isn’t displayed in the list again in turn ensuring I can’t deploy the same location twice.  Make sense?  I know it’s a lot to follow but the concepts of setting it up are pretty much the same no matter what you are looking to do.

Alright – enough background – Let’s get into it.  I’m not going to go through the installation of the SQL Plug-in – it’s exactly the same installation process as the Powershell plug-in which we covered in Part 4.  Similar to how we setup our Powershell host we need to setup our SQL server database connection inside of vCO.  To do this fire up your vCO client and navigate through the workflow tree to Library->SQL->Configuration and select the ‘Add a database’ workflow, right click and Start Workflow.  There are a few parameters as you can see that we need to pass to the workflow in order for it to successfully run.  First, give this connection a name and select your desired Database Type – in my case MS SQL.  Also here we need to pass a Connection URL.  Now if you don’t know anything about jdbc connection urls no fear, it’s not that difficult.  Simply enter it in the the following format…

jdbc:jtds:sqlserver://[SERVERNAME]:[SERVERPORT]/[DATABASENAME]

So, for a SQL Server with named DC.lab.local running on the default port 1433 and  database named ServerDeploy you would use the following…

jdbc:jtds:sqlserver://dc.lab.local:1433/ServerDeploy

SetupSQLPic1

After clicking Next we are once again presented with our Shared/Per User session mode – again, I chose shared to use one simple set of credentials rather than a per user authentication.  When you are ready click ‘Submit’ to add your new database to vCO’s inventory.  One thing to note here is that this step is not necessary   If we wanted we could perform all of this at run time inside code, however for tutorial purposes and learning purposes it’s sometimes easier to do it this way.

Alright, nuff config!  It’s time now to get started on our task at hand; Querying the database for non-deployed servers and pushing the result as a drop-down box as an input parameter to our workflow that we created in Part 4.  First off there is a simple change we need to make to our existing workflow.  Here’s a tip – don’t feel like buffalo-ing your original workflow, simply right click on it and  select ‘Duplicate Workflow’ to copy it.  OK, first off we need a new attribute.  We originally have locationcode setup an input parameter of type string – and we still need this, however the result we get back from our database will be an array of strings.  So, on the General tab of your workflow create a new attribute called  databaseParameter of type SQL:Database and assign it the value of the Database we created earlier (this should allow you to browse the inventory to do so).  Once you are done that simply Save & Close and continue on with any validation errors.

Workflow-pic1-NewAttr

So here comes the real magic!   We need to take that database attribute and pass it to a newly created action which will in turn spit out an array of string attributes (our locations in our database).   Again, you could do the following all in script embedded within your workflow, but you never know when you are going to need to reuse something so I’ve decided to create a new action to do so.    To create an new action be sure you are on ‘Design’ view from within your client and click on the actions tab in the left hand side menu.  Where you place your action doesn’t really matter, I chose to right click com.vmware.library.sql and create my action inside that module.  Just remember where you put it and what you named it:).

Workflow-pic2-NewAction

OK, you should now be in the Action editor.  This is where we are going to place the code that does all the querying of the database.  As I said earlier we need to pass this Action a database parameter and it will return an array of string.   The setup of input parameters and return types, along with all the other work we are going to do is all done on the scripting tab.  First off define your return type of an Array/string.  Secondly add an input parameter of type SQL:Database.  You can see all of this outlined in the capture below…

Workflow-pic2b-ActionEditor

Hey!  That was easy!  Now it’s time for a little scripting.  vCO script is nothing but Javascript which calls the rich set of API’s that vSphere provides, along with the functions and properties of all the plug-ins provided in vCO.  The script I used is displayed below…

1
2
3
4
5
6
7
8
9
10
var resultingArray = new Array();
 
var query = "SELECT locationcode FROM Locations WHERE deployed = 0";
var resultingActiveRecords = databaseParameter.readCustomQuery(query);
for each (var resultRecord in resultingActiveRecords) {
var locationcode = resultRecord.getProperty("locationcode");
resultingArray.push(locationcode);
}
 
return resultingArray;

Simply paste this into the script pane of your action.  As you can see it’s a pretty simple script.  Creates and array, queries our database, pushes the locationcode column value of each record returned into that array and finally returns the array.  So – time to Save and Close and head back to our workflow.

So at this point we are left with 2 tasks.  The first being the creation of the drop-down box as an input.  To do this we will need to change the way our original input parameter, locationcode, is displayed.  This is done on the Presentation tab of our script editor.  Be sure you have selected locationcode in the Presentation tree that the top of the screen and select the icon to add a new property to it.  There are many several different properties listed but the one we are after is called Predefined list of elements.  Under the value field of our new property select the icon to assign an action.  In the popup find/filter for our action we created earlier, assign the actions parameter to our database parameter and click Apply.

WorkFlow-pic3-RunAction

There done right…well, kinda, you could run the workflow now and it would populate our input and it would go ahead and run the PowerCLI script and the VM Network would be created, however if you remember it was my intent to go back at the end of the workflow and update our database to ensure that the same locationcode could not be selected twice.  To do this we will need to drag a new Scriptable task element to run after we invoke our PowerCLI script.  Inside this scriptable task we will need to import a couple of local attributes in order to accomplish the sql we need to do, the locationcode, and the databaseParameter.

Workflow-pic4-NewScriptableTask

As for the script it’s going to look very similar to the syntax that we placed inside of our action with the exception of and executeCustomQuery function in place of the readCustomQuery and the actual query itself is different.  The following is what I used…

1
2
var query = "UPDATE locations SET deployed= 1 WHERE locationcode= '" + locationcode+ "'";
databaseParameter.executeCustomQuery(query);

And now at last we are done!!  Go ahead and run your workflow, either from within the vCO client or the Web Client and you should now see a drop-down selection for the locationcode.  Once it’s selected once the script will run, create the VM Network, then update our database to ensure that the selected locationcode is not shown again in the drop-down.

Workflow-pic5-alldone

So that my friends is the end of the line for me on creating my first vCenter Orchestrator Workflow but it is most definitely not the end of the line with vCO.  With access to a huge set of vSphere API’s along with all of the functionality and properties provided by its’ plugins, throw in some sweet integration with the vSphere Web Client I’m beginning to see my usage of vCO ramp up within my current role.  This series has hardly even grazed the surface in terms of vCO’s functionality so I urge you all to go out there and learn as much as you can about this product.  I’ll do one more post in the series and outline some of the resources that I’ve found along the creation of this workflow so expect to see that soon.

My first vCenter Orchestrator Workflow

Using PowerCLI to set multipath policy based on array model

powerclilogoGoing through all of your hosts and setting your multipathing policy manually through either the C# or the vSphere Web Client can certainly be a trying task.  Sure, if you have 2 or 3 hosts it might be alright, but anything above that and things start to get pretty monotonous really fast!  Also we have all known that if you need to perform the same task more than once it’s always better to script it – Firstly it creates consistency across your environment, secondly it saves you time, and thirdly it helps the economy as you are out buying coffee when normally you would be at your desk clicking….

So all that leads me to the following script…  For the most part the script does two things – first it gets a list of all of your LUNS associated with a host or group of hosts, second, it sets up your desired multipathing policy on those luns based on the model of array presenting them as well as marks paths as preferred if applicable…  That being said, I’ve only included a few different models inside the script below, to see a full list of models you can run “esxcli storage nmp satp rule list”  from the esxcli to list all of the models and integrate them into the script as you see fit.

So first off you can see that the script accepts a parameter – if you pass the string fixall with the call of the script it will just continue without prompts, otherwise, it asks you for a y/n answer.   Also, when setting a path policy to fixed you might want to specify a preferred path – you can see that I’ve set this up as vmhba1, just be sure to customize the script to your liking for your environment…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#fixall - if equals autoyes then don't prompt for y/n
param ($fixall)
 
$vcenter = "vcenterserver"
$username = "username"
$password = "password"
 
$hostcontainer = "cluster or datacenter containing hosts to check"
 
Write-Host "Connecting to vCenter Server..."
$success = connect-viserver $vcenter -username $username -Password $password
 
$vmhosts = get-vmhost -Location $hostcontainer
 
foreach ($vmhost in $vmhosts)
{
  Write-Host "Processing " $vmhost.Name"......" -ForegroundColor white -BackgroundColor Red
 
  #get all luns of type 'disk' from host
  $luns = get-ScsiLun -VMhost $vmhost -LunType disk
 
  foreach ($lun in $luns)
  {
    $multipath = $lun.MultipathPolicy
    $canname = $lun.CanonicalName
    $model = $lun.Model
    # if lun belongs to EVA
    if ($model -eq "HSV400")
    {
      $defaultpolicy = "roundrobin"
      if ($multipath -ne $defaultpolicy)
      {
        #get matching datastore name of lun
        $ds = Get-Datastore | Where-Object {$_.Extensiondata.Info.vmfs.Extent.DiskName -eq "$canname"}
        $dsname = $ds.Name
        Write-Host "$dsname" -foregroundcolor red -backgroundcolor yellow -nonewline; Write-Host " is on the EVA and is currently set to " -nonewline; Write-Host "$multipath" -ForegroundColor yellow -nonewline; Write-Host " where it should be " -nonewline; Write-Host "Round Robin" -ForegroundColor green -NoNewline; Write-Host " - Fix? " -NoNewline;
        if ($fixall -eq "autoyes")
        {
          $fix = "y"
        }
        else
        {
          $fix = Read-Host " y/[N]:"
        }
        if ($fix -eq "y")
        {
          $lun | set-ScsiLun -MultipathPolicy $defaultpolicy
          Write-Host "***Complete***" -Foregroundcolor green
        }
      }
    }
    #if lun belongs to an MSA
    elseif ($model -eq "MSA1000 VOLUME")
    {
      $defaultpolicy = "fixed"
      $prefPathHBA = "vmhba1"
      if ($multipath -ne $defaultpolicy)
      {
        #get corresponding datastore name of lun
        $ds = Get-Datastore | Where-Object {$_.Extensiondata.Info.vmfs.Extent.DiskName -eq "$canname"}
        $dsname = $ds.Name
        Write-Host "$dsname" -foregroundcolor red -backgroundcolor yellow -nonewline; Write-Host " is on the MSA and is currently set to " -nonewline; Write-Host "$multipath" -ForegroundColor yellow -nonewline; Write-Host " where it should be " -nonewline; Write-Host "Fixed" -ForegroundColor green -NoNewline; Write-Host " - Fix? " -NoNewline;
        if ($fixall -eq "autoyes")
        {
          $fix = "y"
        }
        else
        {
          $fix = Read-Host " y/[N]:"
        } 
        if ($fix -eq "y")
        {
          $lunpath = Get-ScsiLunPath -scsilun $lun | where-object {$_.ExtensionData.Adapter -like "*$prefPathHBA"}
          $lun | set-ScsiLun -MultipathPolicy $defaultpolicy -PreferredPath $lunpath -confirm:$false
        }
      }
    }
  }
}

Again I don’t claim to be a Powershell/PowerCLI scriptmaster, so if you see any performance enhancements, problems, suggestions, concerns please use the comments section below to let me know… – Anyone can write a script, but it takes a community to make it a great script.