Here is a paper that I worked on at my team at Microsoft. The Enterprise Engineering Center (http://www.microsoft.com/eec) has a IBM XIV array that we used with the other array on campus.
Windows Server 2008 Hyper-V Geographically Dispersed Cluster with IBM XIV Storage iSCSI
You can find more info on the Tunnel used in this whitepaper at http://www.mikepoulson.com/2011/06/l2tpv3-performance-tweaks-for-hyperv.html
Wednesday, July 27, 2011
How to create differencing disk VM from template on SCVMM 2012 via powershell
This quick post will provide an example of how to create a Virtual Machine (VM) based off an VMM template that utilizes differencing disks.
This is special because VMM does not support this natively. So you have to contact the target HyperV host (via WMI) to create the Diff disk. In addition to need to make sure that the HyperV host has the parent VHD already in place.
The Powershell cmdlet below does the following
This is special because VMM does not support this natively. So you have to contact the target HyperV host (via WMI) to create the Diff disk. In addition to need to make sure that the HyperV host has the parent VHD already in place.
The Powershell cmdlet below does the following
- Looks up the specified Hardware profile
- Looks up the specified template (this is used to get the parent VHD location/name)
- Looks up info on the specified target HyperV host (so we can find the placement drive)
- Checks to see if the ParentVHD already exists on the HyperV hosts Placement Drive
- If the VHD does not exist it copies it to the HyperV host
- Creates Diff Disk via WMI on hyperV host pointing to parent VHD
- Creates the VM via the New-SCVirtualMachine cmdlet using the UseLocalVirtualHardDisk command. (this tells VMM to allow Diff disks).
param($VMName,$TemplateName = "Windows Server 2008 R2 SP1 Enterprise", $HardwareProfileName = "ServerHardware", $VMMHost = "SCVMM",$targethostname = $null) $Err = 0 If ($VMName -eq $null) { Write-Host "`nERROR: Incorrect arguments" -foregroundcolor red -backgroundcolor black Write-Host "`nREQUIRED ARGUMENTS:" -foregroundcolor cyan Write-Host "`n -VMName `"Name of the VM to create`"" -foregroundcolor cyan Write-Host "`n -TemplateName `"Name of the VMM Template`"" -foregroundcolor cyan Write-Host "`n -HardwareProfileName `"Name of the VMM Hardware Profile to use with the template`"" -foregroundcolor cyan Write-Host "`n -VMMHost `"VMM Computername`"" -foregroundcolor cyan Write-Host "`n -targetHostname `"Computername of HyperV host to target`"" -foregroundcolor cyan Exit $Err } function CreateDiffDiskOnHost { param([string]$hostComputerName, [string]$childPath, [string]$parentPath) #get the image mgmt service instance for the host computer $VHDService = get-wmiobject -class "Msvm_ImageManagementService" -namespace "root\virtualization" -computername $hostComputerName #create a differencing disk from the base disk $Result = $VHDService.CreateDifferencingVirtualHardDisk($childPath, $parentPath) } function TestFileLock { ## Attempts to open a file and trap the resulting error if the file is already open/locked param ([string]$filePath ) $filelocked = $false $fileInfo = New-Object System.IO.FileInfo $filePath trap { Set-Variable -name locked -value $true -scope 1 continue } $fileStream = $fileInfo.Open( [System.IO.FileMode]::OpenOrCreate, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None ) if ($fileStream) { $fileStream.Close() } $obj = New-Object Object $obj | Add-Member Noteproperty FilePath -value $filePath $obj | Add-Member Noteproperty IsLocked -value $filelocked $obj } write-host "VMName is $VMName" write-host "Template is $TemplateName" write-host "Hardware Profile is $HardwareProfileName" write-host "VMMHost is $VMMHost" write-host "Target Host is $targethostname" $guid = [guid]::NewGuid() write-host "Lookup the base hardware Profile $HardwareProfileName" $HardwareProfile = Get-SCHardwareProfile -VMMServer $VMMHost | where {$_.Name -eq $HardwareProfileName} if ($HardwareProfile -eq $null) { write-host "Failed to lookup HardwareProfile $HardwareProfileName" -foregroundcolor red -backgroundcolor black EXIT 1 } write-host "Getting information for template $TemplateName" $Template = Get-SCVMTemplate -VMMServer $VMMHost -All | where {$_.Name -eq $TemplateName} if ($Template -eq $null) { write-host "Failed to lookup Template $TemplateName" -foregroundcolor red -backgroundcolor black EXIT 1 } #Get the VHD info for the template $VHD = Get-SCVirtualharddisk | where {$_.Name -eq $template.VirtualDiskDrives[0].VirtualHardDisk} write-host "Template VHD Path " $VHD.SharePath if ($targethostname -eq $null) { write-host "Invalid targethostname" -foregroundcolor red -backgroundcolor black exit 1 } $vmhost = Get-SCVMHost $targethostname $vmHostPath = [string]$vmhost.vmpaths write-host "Target VMHost: " $vmhost.name write-host "Target Drive: " $vmhost.VMPaths $remotePath = "\\" + $vmhost.name + "\" + $vmHostPath.substring(0,1) + "$\" + [system.io.path]::GetFileName($VHD.SharePath) "Checking to see if Parent VHD exists on HV Host Drive" "RemotePath: $remotePath" if (Test-Path $remotePath) { "Parent VHD already exists on HV Host" } else { "$RemotePath does not exist, going to Copy" [System.IO.File]::Copy($VHD.SharePath,$remotePath); } "Creating Diff Disk" $targetVHDPath = $vmHostPath + $VMName + ".vhd" $ParentVHDPath = $vmHostPath + [system.io.path]::GetFileName($VHD.SharePath) CreateDiffDiskOnHost "$vmhost" "$targetVHDPath" "$ParentVHDPath" Start-Sleep -s 20 $targetVHDRemotePath = "\\" + $vmhost.name + "\" + $vmHostPath.substring(0,1) + "$\" + $VMName + ".vhd" if (Test-Path $targetVHDRemotePath) { "Diff Disk Created at:$targetVHDRemotePath" } else { "$targetVHDRemotePath does not exist yet. Sleeping for a few" Start-Sleep -s 30 if (Test-Path $targetVHDRemotePath) { "Disk was created." } else { write-host "Failed to find VHD $targetVHDRemotePath after sleep, exiting" -foregroundcolor red -backgroundcolor black exit 1 } } #Set a random startup delay to reduce VM startup IOPs overload $startDelay = Get-Random -minimum 1 -maximum 30 $lockstate = TestFileLock "$targetVHDRemotePath" if ($lockstate.IsLocked) { "File locked, sleeping" Start-Sleep -s 30 } $mv = move-SCvirtualharddisk -Bus 0 -Lun 0 -IDE -path $targetVHDPath -jobgroup $guid $description = $template.tag New-SCVirtualMachine -Name $vmName -VMHost $vmHost -VMTemplate $template -UseLocalVirtualHardDisk -HardwareProfile $HardwareProfile -ComputerName $vmName -path $vmHostPath -delaystartseconds $startDelay -Description "$description" -mergeanswerfile $true -BlockDynamicOptimization $false -StartVM -JobGroup "$guid" -RunAsynchronously -StartAction "AlwaysAutoTurnOnVM" -StopAction "SaveVM"
Monday, July 18, 2011
Home Circuit Power Monitoring
Ever wonder why your home power bill is so high? Or just want to know how much power you use in various parts of your house through the whole day?
I have the LCD display in my living room near the TV so that I can quickly see how much energy my home is consuming.
For my 30th birthday I got all the parts I need to do per-circuit power monitoring for my whole house. By doing branch circuit monitoring I can answer many questions about my enery usage.
Google Power Meter Data
My1240.com Data
Controller 1
I have one of the Blue Line Power monitors for Microsoft Hohm (http://www.bluelineinnovations.com/Products/PowerCost-Monitor/). This product did not allow me to see how much a single room or circuit was using. It was a start.
I have the LCD display in my living room near the TV so that I can quickly see how much energy my home is consuming.
Microsoft Hohm Data (Sunday, Got up at ~9am) |
For my 30th birthday I got all the parts I need to do per-circuit power monitoring for my whole house. By doing branch circuit monitoring I can answer many questions about my enery usage.
- What does this mean? I can tell you things like:
- How often does my water heater (http://www.geappliances.com/heat-pump-hot-water-heater/high-efficiency-water-heater-savings.htm) turn on.
- How long does it run
- How much power does it use
- Exactly how much does it cost me for it to run
- How much power does my house use when I turn off all my normal items
- Leaving things like laptop and cell phone chargers on
- How much does it cost me to run my AC in the summer? Is it worth leaving on all day or turning on just when I get home
- Or in my case thanks to Insteon I can turn it on before I leave work!
The Solution:
I got the ECM1240 system from Brultech.com. Specifically the PP3-200-X (http://www.brultech.com/home/store/product.php?id_product=34)
I installed solid core CTs on each breaker on my home circuit panel.
To hold the ECM1240 brains I installed a PVC box just next to my main panel to hold all the low voltage items.
The ECM1240 allows me to view my data in real-time via the my1240.com website, read the data from google powermeter or push it into my own data collection environment.
The CONS about the 1240 system are:
- The software to manage the 1240 collection devices has more bugs in it than Windows ME. It crashes often and overall is a piece of junk.
- The solution by default only supports Google powermeter not www.Microsoft-hohm.com.
- While google powermeter has its ups one thing that is has a serious issue with it is the User interface sucks
- The ability to export the data into CSV format from google is nice. Not an option on www.Microsoft-hohm.com
- The ability to share access to my power data from google is nice. Not an option on www.Microsoft-hohm.com
- With Google Powermeter and Microsoft-hohm.com being retired I will have to find a new way to view my power data.
Google Power Meter Data
My1240.com Data
Controller 1
Controller 2
Controller 3
Sunday, July 17, 2011
The Delta Touch2O faucet
How I love my Delta Touch2O faucet.
http://www.youtube.com/watch?v=niy8WlqHw3M
We had to have an additional hole drilled so that we could install it. Most of the videos/blogs talk about how it is a big pain to install. But I found it quite simple. We don't have a lot of room under the sink but i was able to get it done by myself in less than 1 hour.
Also we read that there are issues with the batteries draining quickly and needing replacements often. We have had the same batteries installed for over 1 year now. It is used everyday by 3 sometimes 4 people.
I cannot wait to get one for the bathrooms!
http://www.youtube.com/watch?v=niy8WlqHw3M
We had to have an additional hole drilled so that we could install it. Most of the videos/blogs talk about how it is a big pain to install. But I found it quite simple. We don't have a lot of room under the sink but i was able to get it done by myself in less than 1 hour.
Also we read that there are issues with the batteries draining quickly and needing replacements often. We have had the same batteries installed for over 1 year now. It is used everyday by 3 sometimes 4 people.
I cannot wait to get one for the bathrooms!
Managing Microsoft IIS, Active Directory and DNS from .net
Update 7/17/2011: New links
This code was one of my first coding project from 11-10-2006
Today I am posting sample code on how to manage IIS 6 and Active directory using ADSI in VB.NET.
And managing DNS (creating zones, records and enumeration) using WMI in VB.NET.
There are four separate projects.
This code is posted as-is! It is to be used as a sample on how to do the work. It is not intended to be used in production!
http://dl.dropbox.com/u/3275573/blog/web.zip - ADSI management of IIS 6 Sites and AppPools
http://dl.dropbox.com/u/3275573/blog/DNS.zip - WMI management of Microsoft DNS Zones and Records
http://dl.dropbox.com/u/3275573/blog/ActiveDirectory.zip- ADSI management of Active Directory contacts, Groups, Users, Recipient Policies, Accepted Domains objects (Exchange 2007)
http://dl.dropbox.com/u/3275573/blog/IISSiteID.zip - C# code on generating IIS SiteID
This code was one of my first coding project from 11-10-2006
Today I am posting sample code on how to manage IIS 6 and Active directory using ADSI in VB.NET.
And managing DNS (creating zones, records and enumeration) using WMI in VB.NET.
There are four separate projects.
This code is posted as-is! It is to be used as a sample on how to do the work. It is not intended to be used in production!
http://dl.dropbox.com/u/3275573/blog/web.zip - ADSI management of IIS 6 Sites and AppPools
http://dl.dropbox.com/u/3275573/blog/DNS.zip - WMI management of Microsoft DNS Zones and Records
http://dl.dropbox.com/u/3275573/blog/ActiveDirectory.zip- ADSI management of Active Directory contacts, Groups, Users, Recipient Policies, Accepted Domains objects (Exchange 2007)
http://dl.dropbox.com/u/3275573/blog/IISSiteID.zip - C# code on generating IIS SiteID
Subscribe to:
Posts (Atom)
10 Years from last post
Well world! After the last almost 10 years I have been up to a few things in life and work. Most recently I was working at Microsoft on ...
-
The TFS Build Activity logs have lots of useful information. Unfortunately this information is not real easy to get to. Using the TFS 2012...
-
Repost from old Blog Today I had a con-call to talk about disk quota and how to automate the setting and reading of Quota. So i thought t...