Revision 79b7dbb7 snf-cyclades-app/synnefo/logic/backend.py
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
301 | 301 |
source_date=etime, message=message, details=details) |
302 | 302 |
|
303 | 303 |
|
304 |
def create_instance(vm, public_nic, flavor, image, password, personality):
|
|
304 |
def create_instance(vm, public_nic, flavor, image, password=None):
|
|
305 | 305 |
"""`image` is a dictionary which should contain the keys: |
306 | 306 |
'backend_id', 'format' and 'metadata' |
307 | 307 |
|
... | ... | |
351 | 351 |
# kw['os'] = settings.GANETI_OS_PROVIDER |
352 | 352 |
kw['ip_check'] = False |
353 | 353 |
kw['name_check'] = False |
354 |
|
|
354 | 355 |
# Do not specific a node explicitly, have |
355 | 356 |
# Ganeti use an iallocator instead |
356 |
# |
|
357 | 357 |
#kw['pnode'] = rapi.GetNodes()[0] |
358 |
|
|
358 | 359 |
kw['dry_run'] = settings.TEST |
359 | 360 |
|
360 | 361 |
kw['beparams'] = { |
361 |
'auto_balance': True, |
|
362 |
'vcpus': flavor.cpu, |
|
363 |
'memory': flavor.ram} |
|
362 |
'auto_balance': True, |
|
363 |
'vcpus': flavor.cpu, |
|
364 |
'memory': flavor.ram} |
|
365 |
|
|
366 |
if provider == 'vlmc': |
|
367 |
image_id = 'null' |
|
368 |
else: |
|
369 |
image_id = image['backend_id'] |
|
364 | 370 |
|
365 | 371 |
kw['osparams'] = { |
366 |
'img_id': image['backend_id'], |
|
367 |
'img_passwd': password, |
|
372 |
'config_url': vm.config_url, |
|
373 |
# Store image id and format to Ganeti |
|
374 |
'img_id': image_id, |
|
368 | 375 |
'img_format': image['format']} |
369 |
if personality: |
|
370 |
kw['osparams']['img_personality'] = json.dumps(personality) |
|
371 |
|
|
372 |
if provider != None and provider == 'vlmc': |
|
373 |
kw['osparams']['img_id'] = 'null' |
|
374 | 376 |
|
375 |
kw['osparams']['img_properties'] = json.dumps(image['metadata']) |
|
377 |
if password: |
|
378 |
# Only for admin created VMs !! |
|
379 |
kw['osparams']['img_passwd'] = password |
|
376 | 380 |
|
377 | 381 |
# Defined in settings.GANETI_CREATEINSTANCE_KWARGS |
378 | 382 |
# kw['hvparams'] = dict(serial_console=False) |
383 |
|
|
379 | 384 |
log.debug("Creating instance %s", utils.hide_pass(kw)) |
380 | 385 |
with pooled_rapi_client(vm) as client: |
381 | 386 |
return client.CreateInstance(**kw) |
Also available in: Unified diff