• About me…
  • VMware
  • Powershell
  • DIY

ConfigMgr.nl

VMware, PowerShell, Automation, and more…

  • About me…
  • VMware
  • Powershell
  • DIY

Migrate Cisco Nexus 1000V to VDS with PowerShell

9 oktober 2019 PowerCli Powershell Script VMware No Comments

With the End of General Support (March 12, 2020) getting closer and closer I was asked to perform a migration and upgrade of a vSphere 6 environment. The plan was to install a new 6.7 VCSA and then migrate the hosts as-is to that new platform. After that the hosts could be upgraded to ESXi 6.7. So far so good but the current environment had Cisco 1000V distributed virtual switches so these had to go. The reason? Please read this FAQ: Discontinuation of third party vSwitch program.

At first I wanted to use the ‘Cisco Nexus 1000V to VMware VDS Migration Tool’ but I soon discovered that this tool was old and not maintained. I had several issues downloading and importing Python add-ins and although I managed to get the tool working, I didn’t have enough confidence to use this in a production environment.

So I decided to build my own tool in PowerShell based on the Python tool.
I started with the basic steps from the original tool:
⦁ Connection Details
⦁ Validate Migration
⦁ Create VDS
⦁ Migrate Host
⦁ Migrate Host Advanced
⦁ Migrate All
⦁ Remove VEM from host
⦁ Remove Nexus 1000V switch

Connection Details
The first function is Set-ConnectionDetails. In this function I ask for the user name and password for both vCenter and Cisco VSM. After connecting to vCenter and the VSM (Posh-SSH) I try to get some connection info from the VSM with the command “show svs connections”. After determining the connection status I retrieve the UUID in order to search for the Cisco DVS in vCenter. When it is found everything is ok and the function is finished.

Validate Migration
The second function is Validate-Migration. In this function the port profiles are collected with the command “show running-config port-profile” and saved in a text file for later use. I wanted to include some checks for unsupported features such as segmentation or LACP but I’m not sure how to incorporate those checks. So at the moment I will only save the port profiles as PortProfiles.txt.

Create VDS
This function is called Create-VDS and is used to create the VMware Distributed Switch with the necessary port groups based on the text file I saved in the previous function. This function contains magic!
The output of the command show running-config port-profile is one single string. But inside that string are values that I want to use such as the name of the profile, the description , and the VLAN id. To parse such a string is not so easy. But again, PowerShell to the rescue.

The ConvertFrom-String cmdlet extracts and parses structured properties from string content. This cmdlet generates an object by parsing text from a traditional text stream. For each string in the pipeline, the cmdlet splits the input by either a delimiter or a parse expression, and then assigns property names to each of the resulting split elements. You can provide these property names; if you do not, they are automatically generated for you.
The cmdlet’s default parameter set, ByDelimiter, splits exactly on the regular expression delimiter. It does not perform quote matching or delimiter escaping as the Import-Csv cmdlet does.
The cmdlet’s alternate parameter set, TemplateParsing, generates elements from the groups that are captured by a regular expression. For more information on regular expressions, see about_Regular_Expressions.
This cmdlet supports two modes: basic delimited parsing, and automatically-generated, example-driven parsing.
Delimited parsing, by default, splits the input at white space, and assigns property names to the resulting groups.
You can customize the delimiter by piping the ConvertFrom-String results into one of the Format-* cmdlets, or you can use the Delimiter parameter.
The cmdlet also supports automatically-generated, example-driven parsing based on the FlashExtract, research work by Microsoft Research.

So basically this is Machine Learning! You provide a template that looks like the string you want to parse and define the different properties you want returned. An example of such a template is shown here.

The first property I want to search for is called PortProfileName. The * is used for the first property. So when the second * comes along the cmdlet knows that is for the second set of properties. My second property is VLANs, the third is called Description and the last one is called PortGroupName.
Now when I parse the string with the command “gc PortProfiles.txt | ConvertFrom-String -TemplateContent $template” I get an object with properties that I can use later on.

So now I can do a foreach and use those properties to create the switch and portgroups.

Next time I will show you the other functions and the complete script. Till next time!

1000VCiscomigratepowershellVDS

vCenter Update Manager gives error status 404 in IE 11

Migrate Cisco Nexus 1000V to VDS with PowerShell - part 2

Geef een reactie Antwoord annuleren

Deze website gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.

Meest recente berichten

  • Handy one-liners
  • The system has insufficient locker space for the image profile
  • Testing Script Runtime Service for vSphere – part 2
  • Reporting on your Windows Server backup
  • Testing Script Runtime Service for vSphere – part 1

Jeroen BurenFollow

Jeroen Buren
jeroen_burenJeroen Buren@jeroen_buren·
15 apr

Had some spare time... So I did the HCI Master Specialist Exam and nailed it ;-) #vExpert #VMware #HCI

Reply on Twitter 1382574365389258752Retweet on Twitter 1382574365389258752Like on Twitter 138257436538925875220Twitter 1382574365389258752
jeroen_burenJeroen Buren@jeroen_buren·
15 apr

Join VMware's global event on May 5th & 6th to see their strategy for the new distributed workforce. There will be 13 technical sessions on @WorkspaceONE and @vmwarehorizon, @VMwareSDWAN, @vmw_carbonblack, and more! https://www.vmware.com/anywhere-workspace-event.html?src=so_6075a9bbde44b&cid=7012H000001l6vL #AnywhereWorkspace

Reply on Twitter 1382569804020744192Retweet on Twitter 1382569804020744192Like on Twitter 13825698040207441922Twitter 1382569804020744192
jeroen_burenJeroen Buren@jeroen_buren·
10 apr

Go #XRP Go... To infinity and beyond!

Reply on Twitter 1380903963772469253Retweet on Twitter 1380903963772469253Like on Twitter 13809039637724692531Twitter 1380903963772469253
jeroen_burenJeroen Buren@jeroen_buren·
10 apr

En weer 3 minuten kou geleden...

Reply on Twitter 1380801147368304640Retweet on Twitter 1380801147368304640Like on Twitter 13808011473683046401Twitter 1380801147368304640
jeroen_burenJeroen Buren@jeroen_buren·
5 apr

Het wordt nu toch echt lente!! 😂 #SpringTime

Reply on Twitter 1379101934813114375Retweet on Twitter 1379101934813114375Like on Twitter 13791019348131143754Twitter 1379101934813114375
Load More...

Categorieën

Proudly powered by WordPress | Theme: Doo by ThemeVS.