Bug 1406084 - Using REST API - encountering "NoMethodError: undefined method `key?' for #<Array..."
Summary: Using REST API - encountering "NoMethodError: undefined method `key?' for #<A...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Provisioning
Version: 5.6.0
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: GA
: 5.9.0
Assignee: Greg McCullough
QA Contact: Martin Kourim
URL:
Whiteboard: rest:api
Depends On:
Blocks: 1443247 1443248
TreeView+ depends on / blocked
 
Reported: 2016-12-19 16:41 UTC by Thomas Hennessy
Modified: 2020-07-16 09:04 UTC (History)
12 users (show)

Fixed In Version: 5.9.0.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1443247 1443248 (view as bug list)
Environment:
Last Closed: 2018-03-06 14:41:29 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
customer provided log showing request and error response (19.92 KB, text/plain)
2016-12-19 16:41 UTC, Thomas Hennessy
no flags Details

Description Thomas Hennessy 2016-12-19 16:41:38 UTC
Created attachment 1233425 [details]
customer provided log showing request and error response

Description of problem: Customer using REST API to provision Windows VM and is encountering undefined method 'key?' error 


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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:
customer logs provided

Comment 2 Thomas Hennessy 2016-12-19 17:35:13 UTC
Created attachment 1233450 [details]
current logs as provided by customer

Comment 3 Greg McCullough 2017-01-09 15:11:28 UTC
This error occurred because the data for the sysprep_timezone dialog field is stored differently then other fields.  Instead of hashes the data is stored in an array which is causing the reported method error.

INFO -- : MIQ(ManageIQ::Providers::Vmware::InfraManager::ProvisionWorkflow#set_ws_field_value) processing key <customize:sysprep_timezone(string)> with values <[["(GMT-12:00) International Date Line West", "000"], ["(GMT-11:00) Midway Island, Samoa", "001"], ...

We will need to look into the best method to resolve this issue.

As a work-around I would suggest the user remove the timezone value from the vm_fields data being passed and provide the value as part of the additional_values section.  Then they will need to modify an automate method to apply this value to the provision task before the task is sent to the provider.

Comment 4 Andy Hakala 2017-01-13 15:34:04 UTC
Another workaround that will work for this issue is to create a custom provision dialog for the service account that is being used to access the API. In this dialog I changed the `syspre_timezone` to optional and defaulted the value to `020` (Central Time).

Comment 7 CFME Bot 2017-04-18 15:46:26 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/d7bb1da4d14cd066ed4271275f26198b5fdf7aa5

commit d7bb1da4d14cd066ed4271275f26198b5fdf7aa5
Author:     Greg McCullough <gmccullo>
AuthorDate: Thu Apr 13 22:02:29 2017 -0400
Commit:     Greg McCullough <gmccullo>
CommitDate: Thu Apr 13 22:02:29 2017 -0400

    Remove call reverse! for timezone after converting structure to hash.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1406084

 app/models/miq_provision_virt_workflow.rb | 1 -
 1 file changed, 1 deletion(-)

Comment 10 Martin Kourim 2017-11-24 18:18:47 UTC
Verified using
POST /api/provision_requests
{
    "version": "1.1",
    "template_fields": {
        "guid": "56595c62-318b-11e7-bfda-001a4a447b87"
    },
    "vm_fields": {
        "number_of_cpus": 1,
        "vm_name": "test_rest_prov_1113",
        "vm_memory": "2048",
        "vlan": "DPortGroup (DSwitch)",
        "sysprep_timezone": "095"
    },
    "requester": {
        "user_name": "admin",
        "owner_first_name": "John",
        "owner_last_name": "Doe",
        "owner_email": "jdoe",
        "auto_approve": true
    },
    "tags": {
        "network_location": "Internal",
        "cc": "001"
    },
    "additional_values": {
        "request_id": "1001"
    },
    "ems_custom_attributes": {},
    "miq_custom_attributes": {}
}


Note You need to log in before you can comment on or make changes to this bug.