Bug 1256713

Summary: [REST-API] changing vmPool name is possible through rest-api
Product: [oVirt] ovirt-engine Reporter: Omer Frenkel <ofrenkel>
Component: GeneralAssignee: Shahar Havivi <shavivi>
Status: CLOSED CURRENTRELEASE QA Contact: Israel Pinto <ipinto>
Severity: low Docs Contact:
Priority: medium    
Version: ---CC: bazulay, bugs, juan.hernandez, lsurette, mgoldboi, michal.skrivanek, pstehlik, rbalakri, Rhev-m-bugs, shavivi, slitmano, smelamud, srevivo, tjelinek, ykaul
Target Milestone: ovirt-4.2.0Keywords: Automation
Target Release: 4.2.0.2Flags: shavivi: needinfo-
rule-engine: ovirt-4.2+
rule-engine: planning_ack+
rule-engine: devel_ack+
mavital: testing_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1256411 Environment:
Last Closed: 2017-12-20 10:43:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Omer Frenkel 2015-08-25 10:18:56 UTC
+++ This bug was initially created as a clone of Bug #1256411 +++

Description of problem:

During automated testing we change a vmPool's name. This option is supposed to be blocked and it is blocked on UI.
Furthermore another small thing which I find strange is a difference between the results of the same update with a slightly different body message:

say my template's name is 'test'

1. if I try the name like this:

HEADERS:
"Content-Type: application/xml" 
"Accept: application/x-virt-viewer" 

PUT https://{engine_ip}/ovirt-engine/api/vmpools/{vm_pool_id}/

body:

<vmpool href= "/ovirt-engine/api/vmpools/{vm_pool_id}" id="{vm_pool_id}">
<actions>
<link href= "/ovirt-engine/api/vmpools/{vm_pool_id}/allocatevm" rel="allocatevm"/>
</actions>
<name>test-sefi</name>
<description/>
<link href= "/ovirt-engine/api/vmpools/{vm_pool_id}/permissions" rel="permissions"/>
<size>3</size>
<cluster href= "/ovirt-engine/api/clusters/{cluster_id}" id="{cluster_id}"/>
<template href= "/ovirt-engine/api/templates/{template_id}" id="{template_id}"/>
<prestarted_vms>0</prestarted_vms>
<max_user_vms>1</max_user_vms>
</vmpool>

the name of the pool changes to 'test-sefi' as opposed to expected behaviour.

2. if I chang the body message so it doesn't include the cluster_id and template_id, like so:

body:

<vmpool href= "/ovirt-engine/api/vmpools/{vm_pool_id}" id="{vm_pool_id}">
<actions>
<link href= "/ovirt-engine/api/vmpools/{vm_pool_id}/allocatevm" rel="allocatevm"/>
</actions>
<name>test-sefi</name>
<description/>
<link href= "/ovirt-engine/api/vmpools/{vm_pool_id}/permissions" rel="permissions"/>
<size>3</size>
<prestarted_vms>0</prestarted_vms>
<max_user_vms>1</max_user_vms>
</vmpool>

I get status code 404:

<fault>
<reason>Operation Failed</reason>
<detail>Entity not found: Vms: pool=test-sefi</detail>
</fault>

Version-Release number of selected component (if applicable):

rhevm-3.6.0-0.12.master.el6

How reproducible:

always

Steps to Reproduce:

1. Create pool with name 'test'.
2. try to change name as mentioned above (1)

Actual results:

Name of the vmPool changes.

Expected results:

operation should fail with informative message explaining that vmPool name cannot be changed.

Additional info:

--- Additional comment from Juan Hernández on 2015-08-25 12:35:36 IDT ---

When a the template isn't given as part of the request the RESTAPI has to find it, and in order to do so it has to locate the VM data of the pool. To do this it uses the name of the pool. If the name of the pool is modified in the same requests the RESTAPI uses the new name instead of the old one. This needs to be fixed:

  restapi: Locate VM data using pool id, not name
  https://gerrit.ovirt.org/45289

--- Additional comment from Juan Hernández on 2015-08-25 12:37:01 IDT ---

I think that the issue described in the previous comment should be fixed in 3.6, consider re-targeting the bug.

Making the name editable or not is outside of the scope of the RESTAPI.

Comment 1 Omer Frenkel 2015-08-25 10:22:59 UTC
please note, bug 1256411 fix the failure for updating vm-pool name without setting the template.

this bug is to disable the edit of vm-pool in the engine.

Comment 3 Red Hat Bugzilla Rules Engine 2015-11-30 19:13:25 UTC
Target release should be placed once a package build is known to fix a issue. Since this bug is not modified, the target version has been reset. Please use target milestone to plan a fix for a oVirt release.

Comment 4 Moran Goldboim 2016-03-27 09:17:07 UTC
Postponing to next version due to capacity.

Comment 5 sefi litmanovich 2016-12-15 16:08:28 UTC
Please note that the bug extends not only to the vm name, but to all it's properties. Currently any pool vm is editable completely via API where it should not the same as it's not in UI. Changing the bug's name.

Comment 6 Michal Skrivanek 2016-12-21 09:08:35 UTC
The bug was not addressed in time for 4.1. Postponing to 4.2

Comment 7 sefi litmanovich 2017-02-27 13:06:48 UTC
Changing the name of this bug again after it caused some confusion.
This bug was initially about changing the pool name via REST API which should be disabled.
I changed it to editing a vm from the pool via REST API which should also be disabled.. I was mistaking name of the pool with name of vm from the pool.

Comment 9 Israel Pinto 2017-08-15 10:43:28 UTC
Verify with:

Steps:
1. Create pool with 3 vms
2. Update vmpool name with REST API
With and without cluster and template 

Results:
Both ways update vmpool name not allowed.

PASS

More info:

Without cluster and template:
Request:
<vm_pool>
 <name>test-israel</name>
 <description/>
 <size>3</size>
 <prestarted_vms>0</prestarted_vms>
 <max_user_vms>1</max_user_vms>
</vm_pool>
Response:
<fault>
 <detail>[Cannot change VM-Pool name.]</detail>
 <reason>Operation Failed</reason>
</fault>
With cluster and template:
Request:
<vm_pool>
 <cluster id="ff4a2b05-5e0d-41f4-865a-7f4553d49480"/>
 <template id="9823fe6d-eadf-42cf-9949-69d82a3d4750"/>
 <name>test-israel</name>
 <description/>
 <size>3</size>
 <prestarted_vms>0</prestarted_vms>
 <max_user_vms>1</max_user_vms>
</vm_pool>
Response:
<fault>
 <detail>[Cannot change VM-Pool name.]</detail>
 <reason>Operation Failed</reason>
</fault>

Comment 10 Sandro Bonazzola 2017-12-20 10:43:29 UTC
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.

Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.