Commit 9403e818 by Őry Máté

vm: add number to mass-created VMs' name

parent cc595a39
......@@ -355,9 +355,16 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
params = dict(template=template, owner=owner, pw=pwgen())
params.update([(f, getattr(template, f)) for f in common_fields])
params.update(kwargs) # override defaults w/ user supplied values
return [cls.__create_instance(params, disks, networks, req_traits,
tags) for i in xrange(amount)]
if '%d' not in params['name']:
params['name'] += ' %d'
instances = []
for i in xrange(amount):
real_params = params
real_params['name'] = real_params['name'].replace('%d', str(i))
instances.append(cls.__create_instance(real_params, disks,
networks, req_traits, tags))
return instances
def __create_instance(cls, params, disks, networks, req_traits, tags):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment