With VMware vCenter you get a feature-rich free product called VMware vCenter Converter. One of the things you can do with the Convertor product is to read disk images created by VMware Consolidated Backup and import them in a vCenter. In the current release the Convertor doesn’t come with any support for the PowerCLI automation tools but that doesn’t mean we can’t use the Convertor from our PowerShell scripts.In our environment we needed to be able to import VCB disk images of guests into our Disaster Recovery center, which is build around a number of ESXi servers, each using one or more local datastores . Since we do this at regular intervals (more than once !), we wanted to automate this process.
The Converter product comes with a number of DOS commands. We used the converter-tool command in our script. Looking at the syntax, we see that the command requires an XML file as input for the -jobsubmit parameter.
The layout of the XML file is, afaik, not documented, but by looking at the generated XML files from successful Converter jobs it was not too difficult to deduce most of the required nodes and their attributes.
The script has some additional features:
- The imported guests are connected to a specified portgroup. We use this to connect these guests to an isolated portgroup, so that an accidental start of the guest doesn’t cause any problems.
- The name of the imported guests contains the time stamp. This allows us to generate unique names and allows us to clean up older imports.
- The script has a very simple target selection algorithm. It looks for the ESXi server that has the most free disk space on it’s local datastore.
- The generated XML file, which is used for the Converter job, is saved for reference.
The script shows a very specific case of using the Converter from a PowerShell script, but I’m sure it can easily be adapted for other types of Converter jobs. Enjoy !