VMware Cloud Community
Danooo
Contributor
Contributor

Migrate templates from vSwitch to dvSwitch

Hi All,

Recently we have upgraded our vSphere licenses to Enterprise Plus and this gave us an opportunity to upgrade our networking from standard vSwitches to dvSwitches.  VMware give the option to migrate VMs from existing vSwich port groups to the new dv port groups and this is great. What about migrating templates? Looking at my vSwitch I can see that templates are bind to the port groups. Is there any chance to migrate templates from vSwitch to dvSwitch automatically? Now I have to convert each template to VM, change network settings, and convert VM to template again. Having hundrets of templates this is very painful. I'm looking some workaround for this. Thanks for any answer from your side.

Daniel.

0 Kudos
1 Reply
sflanders
Commander
Commander

Unfortunately, a simple migration option does not exist for this. Given the large number of templates I would suggest scripting the migration. PowerCLI will allow you to do this. A sample shell for this type of script can be found here: http://ict-freak.nl/2010/01/21/powercli-move-template/.

Here is some sample code (has not been tested):

function Migrate-Template-Network{
    param( [string] $template, [string] $network)

    if($template -eq ""){Write-Host "Enter a Template name"}
    if($network -eq ""){Write-Host "Enter updated Network name"}

    Write-Host "Converting $template to VM"
    $vm = Set-Template -Template (Get-Template $template) -ToVM

    Write-Host "Updating network adapter of $template"
    $vm = Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $network -Confirm:$false 

    Write-Host "Converting $template back to template"
    ($vm | Get-View).MarkAsTemplate() | Out-Null
}
Hope this helps! === If you find this information useful, please award points for "correct" or "helpful". ===
0 Kudos