multi-clone.py: CSV import and MAC customization

multi-clone.py: CSV import and MAC customization

After a very busy year, I finally came around to improving my multi-clone.py pyVmomi script. I have added a minor improvement, being able to disable SSL certificate warnings, and two major improvements: CSV import and MAC customization

CSV Import

There is a new command line flag, -C, which allows you to specify a CSV file. This CSV file provides multi-clone.py with the necessary information to clone the template into a VM for each line. The fields in the CSV should be:

  • VM Name (mandatory)
  • Resource Pool (can be empty)
  • Folder (can be empty)
  • MAC address (can be empty)
  • Post-processing script (can be empty)

A line should look like this:

If one of the fields is empty, but the command line flag is provided, the value from the command line is used. For instance, if you started the script with the following command line:

and used the following CSV:

What would happen is:

  • VM01 is created in the Resource Pool ‘Testing’, in the folder ‘Tools’ and the post-processing script ‘/tmp/tools.sh’ will run
  • VM02 is created in the Resource Pool ‘Development’, in the folder ‘Linux’ and the post-processing script ‘/tmp/script.sh’ will run

So, the command line values are only used if no values in the CSV are provided.

Mac customization

In the CSV, you can provide a MAC address for each VM. This MAC address will be assigned to the first NIC the script finds on the new VM before powering it on (if that is not disabled).

Two warnings:

  • It is your responsibility to provide MAC addresses that are not in use on your network
  • The order in which the NICs are presented to the script when there are more than one, is not always the same. In all my tests it seems it will provide the first one that has been added as the first, but i can not guarantee that.

Overview

As always, you can find the script on my GitHub pagehttps://github.com/pdellaert/vSphere-Python/blob/master/multi-clone.py

For more documentation: https://github.com/pdellaert/vSphere-Python/blob/master/docs/multi-clone.md

And just for good measure, the full description of all flags as presented by the -h flag:

 

Tags: , , ,