Tuesday, May 29, 2012

Creating Server 2012 LBFO Teams grouping by default gateway

Here is where I take my two previous posts and splice them together into something useful.

The previous posts contain the details of picking through the various portions of the script, here I just toss it together with some useful loops and work through the Groups that I created.

Once again, this is all PowerShell v3 and Server 2012. 

Recall that my scenario is:

Someone racked this server, they jacked it to the management network, the VM production network, and the storage network. I want to know what NICs are jacked where and group and summarize them.  And each of these networks has DHCP running as I have no time to manually assign IP addresses any longer. They are divided physically in the top of the rack with three switches.

The meat of the script is:

$ips = Get-NetAdapter -Physical | where {$_.Status -eq "Up"} | Get-NetIPConfiguration | Group-Object -property IPv4DefaultGateway


foreach ($group in $ips) {
    # test for no gateway we expect DHCP to give one, if there isn’t one then this really isn’t useful is it?


    If ([string]$group.Values.nexthop -ne "0.0.0.0") {

        $nicList = @()
        foreach ($nic in $group.Group) {
            $nicList += $nic.InterfaceAlias
        }

        $name = [string]$group.Values.nexthop

        $team = New-NetLbfoTeam -Name $name -TeamNicName ($name + "Team") -TeamMembers ($nicList) -TeamingMode SwitchIndependent -LoadBalancingAlgorithm HyperVPort -Confirm:$false 
            
        Clear-Variable -Name nicList

        Do {$team = Get-NetLbfoTeam -Name $team.Name
            sleep 2}
        until ($team.Status -eq "Up")

        Get-NetIPAddress -InterfaceAlias $team.TeamNics | select IPAddress

    }
}

The default LoadBalancingAlgorithm is TransportPorts and works in most general cases. 
If the team is specific to supporting VMs and it has an External Virtual Switch attached then HyperVPort should be used.

Friday, May 25, 2012

Creating an LBFO Team with PowerShell

Moving right along this PowerShell theme I have been working a bit is writing a script that would build me an LBFO team.

For those of you that have not heard of an LBFO team – lets just say that you will love it.  In-the-box NIC teaming.

Yes!  Windows Server 2012 has in-box NIC teaming.  The term is LBFO – Load Balancing FailOver.  You will need that to find the cmdlets.

You can create an LBFO team using Server Manager – it is quick, painless, works well.

With PowerShell I will simply guide you past the problem that I kept tripping over.  And that is sending your list of NIC aliases in as an array of strings.

Back to what I am doing.  I got all fancy with my one liner for selecting my NICs.

That is another post.

But, now that I have that list of NICs – it is the interface alias that is the important part.  That is what the New-NetLBFOTeam cmdlet wants.

Once you have that, it is really simple.

$team = New-NetLbfoTeam -Name $name -TeamNicName ($name ) -TeamMembers ($nicList) -TeamingMode SwitchIndependent -LoadBalancingAlgorithm HyperVPort -Confirm:$false

On a side note: the default LoadBalancingAlgorithm is TransportPorts and works in most general cases.  If the team is specific to supporting VMs and it has an External Virtual Switch attached then HyperVPort should be used.

This has been discussed in the //BUILD/ presentations that are so frequently referenced.

Now, if you have gotten used to Hyper-V VM objects you know that those are ‘live’ – this is not the case with the networking objects.

So, if you want your script to wait until the team is ‘up’ you need a bit of a loop.  I did it this way, a simple Do Until testing for the status to change to Up.

Do {$team = Get-NetLbfoTeam -Name $team.Name
    sleep 2}
until ($team.Status -eq "Up")

Notice that I need to keep querying the team. 

You will recall that Hyper-V PowerShell objects are ‘live’ – that is; you grab a VM object, change it, and the object that you already had is updated.  Not the case here, this is much more like CIM / WMI – where you have to do something then check on it.

Monday, May 21, 2012

Finding and sorting Server 2012 NICs with PowerShell

If you are using Server 2008 (any release) you should just go on now, this is about PowerShell v3 in Server 2012.

You can stay to see how easy this is becoming though.

So, I came up with this one liner – I am pretty proud of it, I am not a developer and not a big fan of one-liners as they are difficult to pass to other folks for them to understand, but this works.

$ips = Get-NetAdapter -Physical | where {$_.Status -eq "Up"} | Get-NetIPConfiguration | Group-Object -property IPv4DefaultGateway

Now, what does this give me?

This gives me an array (a couple levels deep due to the Group (which I had never used before).

I end up with an array of Groups.  Each Group is named with the IPv4 Default Gateway of the NICs.

Within the group is a list of NICs that all have that IPv4 default gateway in common.

The one liner first Gets the Network Adapter object for only the Physical NICs that are jacked ( ‘up’ ).

Get-NetAdapter -Physical | where {$_.Status -eq "Up"}

The NICs that meet that criteria – I then get the NetIPConfiguration of (as this is where the Gateway property is hiding).  And I group them based on the IPvDefaultGateway. 

Get-NetIPConfiguration | Group-Object -property IPv4DefaultGateway

My assumption here is that if the NIC is ‘up’ it has a DHCP address.

This is all fine and good you think, but how is this real?  What is the scenario? 

Someone racked this server, they jacked it to the management network, the VM production network, and the storage network.  I want to know what NICs are jacked where and group and summarize them.  And each of these networks has DHCP running as I have no time to manually assign IP addresses any longer.  They are divided physically in the top of the rack with three switches.  (two posts into the future will use this).

Friday, May 18, 2012

Server 2012 Core and SCVMM 2012 SP1

I recently ran across an interesting tidbit related to Server Core and SCVMM 2012 SP1 CTP.

For SCVMM to push its agent to the Hyper-V Server there is a need for the hidden share to be present.

Well, I had installed Server 2012 Core, and joined it to my domain. 

Then I went to SCVMM and tried to add the host.  Nope, failure.  And the error code indicated that the hidden admin share was not available.

Here is the error:

Error (415)
Agent installation failed copying C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager\agents\I386\3.1.1042.0\msiInstaller.exe to \\bjelks5.brianeh.local\ADMIN$\msiInstaller.exe.
The network path was not found

Recommended Action
1. Ensure bjelks5.brianeh.local is online and not blocked by a firewall.
2. Ensure that file and printer sharing is enabled on bjelks5.brianeh.local and it not blocked by a firewall.
3. Ensure that there is sufficient free space on the system volume.
4. Verify that the ADMIN$ share on bjelks5.brianeh.local exists. If the ADMIN$ share does not exist, reboot bjelks5.brianeh.local and then try the operation again.


Warning (10444)
The VMM management server was unable to impersonate the supplied credentials.

Recommended Action
To add a host in a disjointed domain namespace, ensure that the credentials are valid and of a domain account. In addition, the SCVMMService must run as the local system account or a domain account with sufficient privileges to be able to impersonate other users.

Like a good Server 2012 inductee I started PowerShell and typed Get-SMBShare – and out came the hidden admin share, so I thought, all good.  Nope.

I rebooted. Nope.

Must be Firewall related.  Time for more PowerShell.

To find all the firewall related cmdlets:  Get-Command *NetFirewall*

Great, lets take a look at the Rules, I am familiar with those.

Get-NetFirewallRule –enabled true

Hmm.. Lots there.  But when I did the same on the SCVMM Server I had a slightly different list.  I wonder if there is a dependency on the Rules that begin with “FileServer”.

I played around with Set-NetFirewallRule and various ways to enable rules.

I will tell you what, these cmdlets are not very friendly.  Lots if CIM errors back.  Lots of verbose strings.

In the end I fixed it but I cheated because I could not use wildcards to enable a Group.  Instead I added the FileServer role (the base one) and that resolved the problem – I have noticed this is enabled on the Full / GUI version of Server 2012 all the time and it would be very ‘Core’ for it to be off.

Install-WindowsFeature FS-Fileserver

That fixed it.  And enabled SCVMM to push its agents.

Tuesday, May 15, 2012

Estimating space for Hyper-V snapshots

A forum post inspired me to not directly answer a question this morning, but rather explain something so that folks can think about it instead.

The original post asked the following:

3 nodes Windows server 2008 R2
I have 3 nodes Hyper-V Cluster CSV in fiber channel with a multiple volumes.
1.What the amount of free space, I should keep the volume csv not to fail for lack of space.
2. Can I create a new volume and configure snapshots to be saved only in this new volume?
3. What is the recommended size for the other volume to store the snapshots.

I see two ways to answer this -

  1. directly answer question #2 and wait for the individual to fail
  2. Attempt to answer #1 and #3 (which estimation here is nearly impossible – due to chaos and randomness).

I jumped straight to a description of the technology – which I have not blogged about for some time, but it just seems to linger.

Here is my response:

You as asking questions about how to size a snapshot volume as if you have a background with ESX / VMware.

A snapshot is a moment in time - a differencing disk and configuration. Not a location where copies of VMs are saved off to.

The disk portion of a snapshot uses a differencing disk. Each differencing disk has the potential to grow to the full size of its parent. If its parent is a fixed disk, it will get that big - if it is a dynamic disk it can reach the maximum.

So, in theory - one snapshot can double the amount of storage required for a VM.

Also, a snapshot location is a runtime location. Where the snapshot is located is where the VM is now running from - until that snapshots is deleted and the snapshot is merged back in.

Knowing this, don't plan on using a slower or different class of storage - unless you are very specific and consistent about how you use snapshots and take this into consideration.

By default snapshots are in the same location as the VHD (and as the VM) - Hyper-V (the product) implemented this model with the R2 release because folks were getting into all kinds of trouble by separating the VM snapshots from configuration from VHD and when it came time to upgrade storage or migrate the VMs wound up broken.

So, you can separate the locations, but you need to be clear on how that benefits you. It is more about your process and procedure than the technology.

You might find this useful: http://itproctology.blogspot.com/search?q=snapshot

On a side note:

There is a growing swell in the Hyper-V forums of questions where folks just want to do something but are not taking the time to understand the implementation, they just push on and have problems.  Back in the day we used to refer to this as RTFM.  But you can’t say that in a forum.  But I plead with you, read the manual.

Thursday, May 10, 2012

Works on MY cloud

For the current shift to the ‘cloud’ I have found it necessary to update the classic “works on my computer” badge.  (I have been threatening to do this for a long time)

Many of us in the software business are very familiar with the classic response to a bug of:  “No Repro” or “Not Reproducible”

There are many reasons for these types of answers, but the most common is that I am not the developer and I am not running the software on his machines or in the same way that she did.  This resulted in the classic “works on my machine”:

WorksOnMyMachine

For the cloud era these applications are generally part of a large distributed system and that is what we are testing – many moving parts, many roles, many different systems.  Errors happen all over the place.  And everything is now a cloud.

So, my proposal has been to update the classic badge of jest to the cloud era and the “Works on my cloud” is born:

WorksOnMyCloud