Bug 1378066

Summary: undefined method end_element
Product: [oVirt] ovirt-engine-sdk-ruby Reporter: movciari
Component: CoreAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED CURRENTRELEASE QA Contact: Lukas Svaty <lsvaty>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.0.1CC: bugs
Target Milestone: ovirt-4.0.5Flags: juan.hernandez: ovirt-4.0.z?
rule-engine: planning_ack?
juan.hernandez: devel_ack+
pstehlik: testing_ack+
Target Release: 4.0.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-ovirt-engine-sdk-4.0.2-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-18 07:38:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1366548    

Description movciari 2016-09-21 12:34:14 UTC
Description of problem:
when trying to add a new template using ruby sdk:
NoMethodError: undefined method `end_element' for #<OvirtSDK4::XmlWriter:0x00000002c34c48>
from /usr/share/gems/gems/ovirt-engine-sdk-4.0.1/lib/ovirtsdk4/writers.rb:564:in `write_one'

Version-Release number of selected component (if applicable):
ovirt-engine-sdk-4.0.1

How reproducible:
always

Steps to Reproduce:
require "ovirtsdk4"
connection = OvirtSDK4::Connection.new({
    :url => 'https://hostname/ovirt-engine/api',
    :username => 'admin@internal',
    :password => 'password',
    :insecure => true,
})
system_service = connection.system_service
vms_service = system_service.vms_service
templates_service = system_service.templates_service
cluster = system_service.clusters_service.list[0]
vm = vms_service.list[0]
tmpl = OvirtSDK4::Template.new({
    :name => "template",
    :vm => vm,
    :cluster => cluster
})
templates_service.add(tmpl)

Actual results:


Expected results:


Additional info:

Comment 1 Juan Hernández 2016-09-21 13:02:26 UTC
This is an error in the code generator, that affects writing lists of enum values. It is fixed by the proposed patch. It is triggered by the fact that you are sending the complete representations of the virtual machine and the cluster, when only the identifiers are required. Consider replacing your code with this:

  tmpl = OvirtSDK4::Template.new({
    :name => "template",
    :vm => {
      :id => vm.id,
    },
    :cluster => {
      :id => cluster.id,
    },
  })

The fix will be included in version 4.0.2 of the SDK.

Comment 2 Lukas Svaty 2016-10-18 14:08:34 UTC
verified in rubygem-ovirt-engine-sdk4-4.0.3-1.el7ev.x86_64