Commit 839207de by Dudás Ádám

vm: make public create method from private __create_instance

parent 70d27ff2
...@@ -359,19 +359,18 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -359,19 +359,18 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
params = dict(template=template, owner=owner, pw=pwgen()) params = dict(template=template, owner=owner, pw=pwgen())
params.update([(f, getattr(template, f)) for f in common_fields]) params.update([(f, getattr(template, f)) for f in common_fields])
params.update(kwargs) # override defaults w/ user supplied values params.update(kwargs) # override defaults w/ user supplied values
if '%d' not in params['name']:
if amount > 1 and '%d' not in params['name']:
params['name'] += ' %d' params['name'] += ' %d'
instances = [] customized_params = (dict(params,
for i in xrange(amount): name=params['name'].replace('%d', str(i)))
real_params = params for i in xrange(amount))
real_params['name'] = real_params['name'].replace('%d', str(i)) return [cls.create(cps, disks, networks, req_traits, tags)
instances.append(cls.__create_instance(real_params, disks, for cps in customized_params]
networks, req_traits, tags))
return instances
@classmethod @classmethod
def __create_instance(cls, params, disks, networks, req_traits, tags): def create(cls, params, disks, networks, req_traits, tags):
# create instance and do additional setup # create instance and do additional setup
inst = cls(**params) inst = cls(**params)
......
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