snobear/ezmomi

clone template X times

jctanner opened this issue · 4 comments

If my PR to #3 is accepted, I'd like to further extend the clone subcommand to include a --count parameter. The purpose would be to allow the end user to clone a template multiple times in the same command.

Example:

emomzi clone --template=foo --hostname=bar-%d --count=4
Cloning foo to new host bar-0
Cloning foo to new host bar-1
Cloning foo to new host bar-2
Cloning foo to new host bar-3
Waiting for bar-0 to obtain an IP address
Waiting for bar-1 to obtain an IP address
Waiting for bar-2 to obtain an IP address
Waiting for bar-4 to obtain an IP address
bar-0 10.0.0.100
bar-1 10.0.0.101
bar-2 10.0.0.102
bar-3 10.0.0.103

Sounds good. A few thoughts/questions:

  • If a %d isn't specified, should ezmomi complain and exit, or just default the hostname to hostname-%d, for example?

In general, I like the idea of ezmomi doing the work for you with minimal params, but it would be annoying to fire off a whole bunch of VM clones to find out you don't like the host naming convention that it defaulted to :). So my vote would be to complain that ---count requires a %d in the hostname and exit.

  • add a check to complain and exit if --count is supplied with static --ips. Also brings up how to handle the situation of mixed dhcp and static, per #3.

First pass ... 70c2303

@snobear

  1. As written, it will default to adding a "-" suffix on the given hostname, if %s is not found in the string. I would say that this should be a policy call on your part and I will code to your decision.
  2. Yeah ... this is complicated until dhcp+static is sorted out. Perhaps it could just abort for now if NICs per VM > 1.

Thanks for the suggestions @jctanner , but I'm going to close this for now. I like the idea but it adds complexity to this tool, e.g. static IP assignment, that could easily be achieved with a wrapper script.