Revision 2a599282
b/snf-cyclades-app/synnefo/api/servers.py | ||
---|---|---|
327 | 327 |
|
328 | 328 |
password = util.random_password() |
329 | 329 |
|
330 |
# TODO: Just copied code from backend.py to fix the images backend_id |
|
331 |
# for archipelagos. Find a better way and remove double checks |
|
332 |
img_id = image['backend_id'] |
|
333 |
provider = None |
|
334 |
disk_template = flavor.disk_template |
|
335 |
if flavor.disk_template.startswith("ext"): |
|
336 |
disk_template, provider = flavor.disk_template.split("_", 1) |
|
330 |
disk_template, provider = util.get_flavor_provider(flavor) |
|
331 |
if provider: |
|
332 |
flavor.disk_template = disk_template |
|
333 |
flavor.disk_provider = provider |
|
334 |
flavor.disk_origin = None |
|
337 | 335 |
if provider == 'vlmc': |
338 |
img_id = 'null' |
|
336 |
flavor.disk_origin = image['backend_id'] |
|
337 |
image['backend_id'] = 'null' |
|
339 | 338 |
|
340 | 339 |
# dispatch server created signal |
341 | 340 |
server_created.send(sender=vm, created_vm_params={ |
342 |
'img_id': img_id,
|
|
341 |
'img_id': image['backend_id'],
|
|
343 | 342 |
'img_passwd': password, |
344 | 343 |
'img_format': str(image['format']), |
345 | 344 |
'img_personality': str(personality), |
b/snf-cyclades-app/synnefo/api/util.py | ||
---|---|---|
505 | 505 |
raise OverLimit("Maximum size of personality exceeded") |
506 | 506 |
except AssertionError: |
507 | 507 |
raise BadRequest("Malformed personality in request") |
508 |
|
|
509 |
|
|
510 |
def get_flavor_provider(flavor): |
|
511 |
"""Extract provider from disk template. |
|
512 |
|
|
513 |
Provider for `ext` disk_template is encoded in the disk template |
|
514 |
name, which is formed `ext_<provider_name>`. Provider is None |
|
515 |
for all other disk templates. |
|
516 |
|
|
517 |
""" |
|
518 |
disk_template = flavor.disk_template |
|
519 |
provider = None |
|
520 |
if disk_template.startswith("ext"): |
|
521 |
disk_template, provider = disk_template.split("_", 1) |
|
522 |
return disk_template, provider |
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
367 | 367 |
kw['name'] = vm.backend_vm_id |
368 | 368 |
# Defined in settings.GANETI_CREATEINSTANCE_KWARGS |
369 | 369 |
|
370 |
# Identify if provider parameter should be set in disk options. |
|
371 |
# Current implementation support providers only fo ext template. |
|
372 |
# To select specific provider for an ext template, template name |
|
373 |
# should be formated as `ext_<provider_name>`. |
|
374 |
provider = None |
|
375 |
disk_template = flavor.disk_template |
|
376 |
if flavor.disk_template.startswith("ext"): |
|
377 |
disk_template, provider = flavor.disk_template.split("_", 1) |
|
378 |
|
|
379 |
kw['disk_template'] = disk_template |
|
370 |
kw['disk_template'] = flavor.disk_template |
|
380 | 371 |
kw['disks'] = [{"size": flavor.disk * 1024}] |
372 |
provider = flavor.provider |
|
381 | 373 |
if provider: |
382 | 374 |
kw['disks'][0]['provider'] = provider |
383 | 375 |
|
384 | 376 |
if provider == 'vlmc': |
385 |
kw['disks'][0]['origin'] = image['backend_id']
|
|
377 |
kw['disks'][0]['origin'] = flavor.disk_origin
|
|
386 | 378 |
|
387 | 379 |
kw['nics'] = [public_nic] |
388 | 380 |
if settings.GANETI_USE_HOTPLUG: |
... | ... | |
403 | 395 |
'vcpus': flavor.cpu, |
404 | 396 |
'memory': flavor.ram} |
405 | 397 |
|
406 |
if provider == 'vlmc': |
|
407 |
image_id = 'null' |
|
408 |
else: |
|
409 |
image_id = image['backend_id'] |
|
410 |
|
|
411 | 398 |
kw['osparams'] = { |
412 | 399 |
'config_url': vm.config_url, |
413 | 400 |
# Store image id and format to Ganeti |
414 |
'img_id': image_id,
|
|
401 |
'img_id': image['backend_id'],
|
|
415 | 402 |
'img_format': image['format']} |
416 | 403 |
|
417 | 404 |
if password: |
Also available in: Unified diff