Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1448832

Summary: API | read_only attribute is being ignored when attaching a disk to VM via API
Product: [oVirt] ovirt-engine Reporter: Raz Tamir <ratamir>
Component: BLL.StorageAssignee: Tal Nisan <tnisan>
Status: CLOSED CURRENTRELEASE QA Contact: Raz Tamir <ratamir>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.1.2.1CC: bugs, stirabos
Target Milestone: ovirt-4.1.3Keywords: Automation
Target Release: 4.1.3Flags: rule-engine: ovirt-4.1+
rule-engine: blocker+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-06 13:10:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
engine and vdsm logs none

Description Raz Tamir 2017-05-08 10:51:44 UTC
Created attachment 1277084 [details]
engine and vdsm logs

Description of problem:
When attaching a disk to VM with a read_only attribute set to 'true':
<disk_attachment>
    <active>true</active>
    <interface>virtio</interface>
    <read_only>true</read_only>
    <disk id="67ad3f68-a248-4bb3-85e1-36e358cf1d32"/>
</disk_attachment>

The read_only value is being ignored and it is set to 'false'


Version-Release number of selected component (if applicable):
ovirt-engine-4.1.2.1-0.1.el7
vdsm-4.19.12-1.el7ev.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Create VM
2. Create disk
3. Attach the disk to VM with property <read_only> set to 'true'

POST api/vms/e6894991-ac5d-4654-8a8e-eefa8b2804cc/diskattachments

body:

<disk_attachment>
    <active>true</active>
    <interface>virtio</interface>
    <read_only>true</read_only>
    <disk id="67ad3f68-a248-4bb3-85e1-36e358cf1d32"/>
</disk_attachment>

The response is:

<disk_attachment href="/ovirt-engine/api/vms/e6894991-ac5d-4654-8a8e-eefa8b2804cc/diskattachments/67ad3f68-a248-4bb3-85e1-36e358cf1d32" id="67ad3f68-a248-4bb3-85e1-36e358cf1d32">
    <active>true</active>
    <bootable>false</bootable>
    <interface>virtio</interface>
    <pass_discard>false</pass_discard>
    <read_only>false</read_only>
    <uses_scsi_reservation>false</uses_scsi_reservation>
    <disk href="/ovirt-engine/api/disks/67ad3f68-a248-4bb3-85e1-36e358cf1d32" id="67ad3f68-a248-4bb3-85e1-36e358cf1d32"/>
    <vm href="/ovirt-engine/api/vms/e6894991-ac5d-4654-8a8e-eefa8b2804cc" id="e6894991-ac5d-4654-8a8e-eefa8b2804cc"/>
</disk_attachment>


from engine.log:

2017-05-08 13:40:20,938+03 INFO  [org.ovirt.engine.core.bll.storage.disk.AttachDiskToVmCommand] (default task-11) [456bc663-4c93-4da0-8fd1-5c4106a6568b] Running command: AttachDiskToVmCommand internal: false. Entities affected :  ID: e6894991-ac5d-4654-8a8e-eefa8b2804cc Type: VMAction group CONFIGURE_VM_STORAGE with role type USER,  ID: 67ad3f68-a248-4bb3-85e1-36e358cf1d32 Type: DiskAction group ATTACH_DISK with role type USER
2017-05-08 13:40:20,975+03 INFO  [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (default task-11) [456bc663-4c93-4da0-8fd1-5c4106a6568b] EVENT_ID: USER_ATTACH_DISK_TO_VM(2,016), Correlation ID: 456bc663-4c93-4da0-8fd1-5c4106a6568b, Call Stack: null, Custom Event ID: -1, Message: Disk aaaaa was successfully attached to VM golden_env_mixed_virtio_3_1 by admin@internal-authz.


Actual results:


Expected results:


Additional info:

When running the command with the body:

<disk_attachment>
    <active>true</active>
    <interface>virtio</interface>
    <disk id="67ad3f68-a248-4bb3-85e1-36e358cf1d32">
        <read_only>true</read_only>
    </disk>
</disk_attachment>

(The read_only is part of disk object)

The operation works fine

Comment 1 Raz Tamir 2017-06-04 13:01:55 UTC
Verified on rhevm-4.1.3.1-0.1.el7

Response body:

<disk_attachment href="/ovirt-engine/api/vms/44fb34dc-9df1-4ca2-b336-a106f0017bc6/diskattachments/0ca3ebb6-ad8f-4120-ba26-80f5f6db3841" id="0ca3ebb6-ad8f-4120-ba26-80f5f6db3841">
    <active>true</active>
    <bootable>false</bootable>
    <interface>virtio</interface>
    <pass_discard>false</pass_discard>
    <read_only>true</read_only>    <<======= VERIFIED
    <uses_scsi_reservation>false</uses_scsi_reservation>
    <disk href="/ovirt-engine/api/disks/0ca3ebb6-ad8f-4120-ba26-80f5f6db3841" id="0ca3ebb6-ad8f-4120-ba26-80f5f6db3841"/>
    <vm href="/ovirt-engine/api/vms/44fb34dc-9df1-4ca2-b336-a106f0017bc6" id="44fb34dc-9df1-4ca2-b336-a106f0017bc6"/>
</disk_attachment>