Although vCenter Orchestrator does offer an upgrade path for their appliances there are times where I have found myself needing to deploy a new one and migrate all of my configuration and workflows to it. vCO has some great built in workflows that can configure itself, but nothing that really deals with workflows. Sure, you can export and import workflows one at time using the client, which may be ok if you have 10 workflows, but what if you have 20, 40, 100 that you need to migrate. That could get pretty monotonous.
The shear energy of a mouse click.
That’s right – who wants to exert all that energy of clicking on the mouse to get these workflows migrated when we can just orchestrate or automate it – after all, this is vCenter Orchestrator we are talking about. vCO has a REST plugin that allows us to create workflows around any application that offers one, but did you know that vCO also has it’s own REST API available for us to use? So that’s where I started with my task of migrating workflows and by the time I got to writing this post it truly ended up being a community effort.
“Steal from the best”
This was a quote that I seen on one of Alan Renouf’s slides during a VMworld presentation on PowerCLI. “Steal from the best”, “Don’t re-invent the wheel” – sayings that have resonated with me for my entire career – Why re-do something if it has already been done. So when I set out on this small project I ended up using two main sources; This post by William Lam on VirtuallyGhetto on how to use curl to export a single vCO workflow and this forum reply by igaydajiev who “showed me the light” on how to import a workflow back in! Without these two guys I wouldn’t have been able to do any of this.
Enough already let’s get to it!
So I chose to go the PowerShell route to accomplish this as I’m not too familiar with the REST plugin for vCO. As well, I am targeting only a certain category – so basically what the script does is take in the following parameters
- OldvCOServer – the old vCO appliance
- OldvCOUser/OldvCOPass – credentials for the old appliance
- OldvCOCategory – Category Name to export workflows from
- TempFolder – Location to store the exported workflows
- NewvCOServer – The new vCO appliance
- NewvCOUser/NewvCOPass – credentials for the new appliance
- NewvCOCategory – Category name on new server where you would like the worfkflows imported.
As far as an explanation I’ll just let you follow the code and figure it out. It’s basically broke into two different sections; the export and the import. During the import routine there is a little bit of crazy wonky code that gets the ID of the targeted category. This is the only way I could figure out how to get it and I’m sure there is a way more efficient way of doing so, but for now, this will have to do. Anyways, the script is shown below and is downloadable here.