Revision 4bf3dea1

View differences:

src/image/Image.cc
447 447
    get_template_attribute("DEV_PREFIX", prefix);
448 448

  
449 449
   //---------------------------------------------------------------------------
450
   //                       NEW DISK ATTRIBUTES
450
   //                       BASE DISK ATTRIBUTES
451 451
   //---------------------------------------------------------------------------
452 452

  
453
    map<string,string> new_disk;
453
    disk->replace("IMAGE",    name);
454
    disk->replace("IMAGE_ID", iid.str());
455
    disk->replace("SOURCE",   source);
454 456

  
455
    new_disk.insert(make_pair("IMAGE",    name));
456
    new_disk.insert(make_pair("IMAGE_ID", iid.str()));
457
    new_disk.insert(make_pair("SOURCE",   source));
458

  
459
    if (!bus.empty())
460
    {
461
        new_disk.insert(make_pair("BUS",bus));
462
    }
463
    else if (!template_bus.empty())
457
    if (bus.empty() && !template_bus.empty()) //BUS in Image, not in DISK
464 458
    {
465
        new_disk.insert(make_pair("BUS",template_bus));
459
        disk->replace("BUS",template_bus);
466 460
    }
467 461

  
468
    if (!driver.empty())
469
    {
470
        new_disk.insert(make_pair("DRIVER",driver));
471
    }
472
    else if (!template_driver.empty())
462
    if (driver.empty() && !template_driver.empty())//DRIVER in Image,not in DISK
473 463
    {
474
        new_disk.insert(make_pair("DRIVER",template_driver));
464
        disk->replace("DRIVER",template_driver);
475 465
    }
476 466

  
477 467
   //---------------------------------------------------------------------------
......
480 470

  
481 471
    if ( persistent_img )
482 472
    {
483
        new_disk.insert(make_pair("CLONE","NO"));
484
        new_disk.insert(make_pair("SAVE","YES"));
473
        disk->replace("CLONE","NO");
474
        disk->replace("SAVE","YES");
485 475
    }
486 476
    else
487 477
    {
488
        new_disk.insert(make_pair("CLONE","YES"));
489
        new_disk.insert(make_pair("SAVE","NO"));
478
        disk->replace("CLONE","YES");
479
        disk->replace("SAVE","NO");
490 480
    }
491 481

  
492 482
    switch(type)
493 483
    {
494 484
        case OS:
495 485
        case DATABLOCK:
496
          new_disk.insert(make_pair("TYPE","DISK"));
497
          new_disk.insert(make_pair("READONLY","NO"));
486
          disk->replace("TYPE","DISK");
487
          disk->replace("READONLY","NO");
498 488
        break;
499 489

  
500 490
        case CDROM:
501
          new_disk.insert(make_pair("TYPE","CDROM"));
502
          new_disk.insert(make_pair("READONLY","YES"));
491
          disk->replace("TYPE","CDROM");
492
          disk->replace("READONLY","YES");
503 493
        break;
504 494
    }
505 495

  
......
507 497
   //   TARGET attribute
508 498
   //---------------------------------------------------------------------------
509 499

  
510
    if (!target.empty())
511
    {
512
        new_disk.insert(make_pair("TARGET", target));
513
    }
514
    else if (!template_target.empty())
500
    if (target.empty()) //No TARGET in DISK attribute
515 501
    {
516
        new_disk.insert(make_pair("TARGET", template_target));
517
    }
518
    else
519
    {
520
        switch(type)
502
        if (!template_target.empty())
503
        {
504
            disk->replace("TARGET", template_target);
505
        }
506
        else
521 507
        {
522
            case OS:
523
                prefix += "a";
524
            break;
508
            switch(type)
509
            {
510
                case OS:
511
                    prefix += "a";
512
                break;
525 513

  
526
            case CDROM:
527
                prefix += "c"; // b is for context
528
            break;
514
                case CDROM:
515
                    prefix += "c"; // b is for context
516
                break;
529 517

  
530
            case DATABLOCK:
531
                prefix += static_cast<char>(('e'+ *index));
532
                *index  = *index + 1;
533
            break;
518
                case DATABLOCK:
519
                    prefix += static_cast<char>(('e'+ *index));
520
                    *index  = *index + 1;
521
                break;
534 522

  
535
        }
523
            }
536 524

  
537
        new_disk.insert(make_pair("TARGET", prefix));
525
            disk->replace("TARGET", prefix);
526
        }
538 527
    }
539 528

  
540
    disk->replace(new_disk);
541

  
542 529
    return 0;
543 530
}
544 531

  

Also available in: Unified diff