Revision d797d04a src/image/Image.cc

View differences:

src/image/Image.cc
474 474
    string driver;
475 475
    string disk_attr_type;
476 476

  
477
    bool ro;
478

  
477 479
    ostringstream iid;
478 480

  
479 481
    img_type   = type;
......
484 486

  
485 487
    string template_target;
486 488
    string template_driver;
489
    string template_ptype;
487 490

  
488 491
    get_template_attribute("TARGET", template_target);
489 492
    get_template_attribute("DRIVER", template_driver);
493
    get_template_attribute("PERSISTENT_TYPE", template_ptype);
494

  
495
    TO_UPPER(template_ptype);
490 496

  
491
   //---------------------------------------------------------------------------
492
   //                       DEV_PREFIX ATTRIBUTE
493
   //---------------------------------------------------------------------------
497
    //---------------------------------------------------------------------------
498
    //                       DEV_PREFIX ATTRIBUTE
499
    //---------------------------------------------------------------------------
494 500
    if ( dev_prefix.empty() ) //DEV_PEFIX not in DISK, check for it in IMAGE
495 501
    {
496 502
        get_template_attribute("DEV_PREFIX", dev_prefix);
......
503 509
        disk->replace("DEV_PREFIX", dev_prefix);
504 510
    }
505 511

  
506
   //---------------------------------------------------------------------------
507
   //                       BASE DISK ATTRIBUTES
508
   //---------------------------------------------------------------------------
512
    //--------------------------------------------------------------------------
513
    //                       BASE DISK ATTRIBUTES
514
    //--------------------------------------------------------------------------
509 515
    disk->replace("IMAGE",    name);
510 516
    disk->replace("IMAGE_ID", iid.str());
511 517
    disk->replace("SOURCE",   source);
......
515 521
        disk->replace("DRIVER",template_driver);
516 522
    }
517 523

  
518
   //---------------------------------------------------------------------------
519
   //   TYPE, READONLY, CLONE, and SAVE attributes
520
   //---------------------------------------------------------------------------
524
    //--------------------------------------------------------------------------
525
    //   READONLY attribute
526
    //--------------------------------------------------------------------------
527
    if ( type == CDROM || template_ptype == "IMMUTABLE" )
528
    {
529
        disk->replace("READONLY", "YES");
530
    }
531
    else if ( disk->vector_value("READONLY", ro) != 0 )
532
    {
533
        if ( get_template_attribute("READONLY", ro) )
534
        {
535
            disk->replace("READONLY", ro);
536
        }
537
        else
538
        {
539
            disk->replace("READONLY", "NO");
540
        }
541
    }
542

  
543
    //--------------------------------------------------------------------------
544
    //   CLONE & SAVE attributes
545
    //--------------------------------------------------------------------------
521 546
    if ( persistent_img )
522 547
    {
523
        disk->replace("CLONE","NO");
524
        disk->replace("SAVE","YES");
525
        disk->replace("PERSISTENT","YES");
548
        disk->replace("PERSISTENT", "YES");
549
        disk->replace("CLONE", "NO");
550

  
551
        if ( template_ptype == "IMMUTABLE" )
552
        {
553
            disk->replace("SAVE", "NO");
554
        }
555
        else
556
        {
557
            disk->replace("SAVE", "YES");
558
        }
526 559
    }
527 560
    else
528 561
    {
529
        disk->replace("CLONE","YES");
530
        disk->replace("SAVE","NO");
562
        disk->replace("CLONE", "YES");
563
        disk->replace("SAVE", "NO");
531 564
    }
532 565

  
566
    //--------------------------------------------------------------------------
567
    //   TYPE attribute
568
    //--------------------------------------------------------------------------
533 569
    switch(type)
534 570
    {
535 571
        case OS:
536 572
        case DATABLOCK: //Type is FILE or BLOCK as inherited from the DS
537
          disk_attr_type = disk_type_to_str(disk_type);
538
          disk->replace("READONLY","NO");
573
            disk_attr_type = disk_type_to_str(disk_type);
539 574
        break;
540 575

  
541 576
        case CDROM: //Always use CDROM type for these ones
542
          disk_attr_type = "CDROM";
543
          disk->replace("READONLY","YES");
577
            disk_attr_type = "CDROM";
544 578
        break;
545 579

  
546 580
        default: //Other file types should not be never a DISK
547 581
        break;
548 582
    }
549 583

  
550
    disk->replace("TYPE",disk_attr_type);
584
    disk->replace("TYPE", disk_attr_type);
551 585

  
552
    //---------------------------------------------------------------------------
586
    //--------------------------------------------------------------------------
553 587
    //   TARGET attribute
554
    //---------------------------------------------------------------------------
555

  
588
    //--------------------------------------------------------------------------
556 589
    // TARGET defined in the Image template, but not in the DISK attribute
557 590
    if ( target.empty() && !template_target.empty() )
558 591
    {

Also available in: Unified diff