test-kitchen / kitchen-vra

A Test Kitchen driver for VMware vRealize Automation
Apache License 2.0
13 stars 22 forks source link

extra parameters - undefined method `split' for :"provider-APP_Server~Hostname":Symbol #33

Closed RoinGrindwald closed 5 years ago

RoinGrindwald commented 5 years ago

Versions:

Platform Details

Scenario:

Kitchen Create is unable to provision with vra driver due to a undefined method for Symbol ~

Steps to Reproduce:

Adding any extra parameters that are required will result in the error. But if you try without them you cannot submit due to missing required parameters.

platforms:
  - name: Application Server Test
    driver:
      catalog_name: Application Server
      cpus: 2
      memory: 4096
      extra_parameters:
        provider-APP_Server~Hostname:
          type: string
          value: vra-test

Expected Result:

You should see Message: undefined method `split' for :"provider-APP_Server~Hostname":Symbol in your kitchen.log.

Actual Result:

I, [2019-04-29T11:31:37.957948 #7784]  INFO -- default-Application Server Test: -----> Creating <default-Application Server Test>...
I, [2019-04-29T11:31:37.959376 #7784]  INFO -- default-Application Server Test: Building vRA catalog request...
I, [2019-04-29T11:31:37.959689 #7784]  INFO -- default-Application Server Test: Fetching Catalog ID by Catalog Name
I, [2019-04-29T11:31:42.959130 #7784]  INFO -- default-Application Server Test: Fetching Subtenant ID by Subtenant Name
E, [2019-04-29T11:31:43.068519 #7784] ERROR -- default-Application Server Test: Create failed on instance <default-Application Server Test>.
E, [2019-04-29T11:31:43.069388 #7784] ERROR -- default-Application Server Test: ------Exception-------
E, [2019-04-29T11:31:43.069532 #7784] ERROR -- default-Application Server Test: Class: NoMethodError
E, [2019-04-29T11:31:43.069641 #7784] ERROR -- default-Application Server Test: Message: undefined method `split' for :"provider-APP_Server~Hostname":Symbol
E, [2019-04-29T11:31:43.069743 #7784] ERROR -- default-Application Server Test: ----------------------
E, [2019-04-29T11:31:43.069844 #7784] ERROR -- default-Application Server Test: ------Backtrace-------
E, [2019-04-29T11:31:43.069955 #7784] ERROR -- default-Application Server Test: C:/Users/username/AppData/Local/chefdk/gem/ruby/2.5.0/gems/vmware-vra-2.6.1/lib/vra/request_parameters.rb:54:in `set'
E, [2019-04-29T11:31:43.070054 #7784] ERROR -- default-Application Server Test: C:/Users/username/AppData/Local/chefdk/gem/ruby/2.5.0/gems/vmware-vra-2.6.1/lib/vra/request_parameters.rb:34:in `set_parameters'
E, [2019-04-29T11:31:43.070157 #7784] ERROR -- default-Application Server Test: C:/Users/username/AppData/Local/chefdk/gem/ruby/2.5.0/gems/vmware-vra-2.6.1/lib/vra/catalog_request.rb:65:in `set_parameters'
E, [2019-04-29T11:31:43.070256 #7784] ERROR -- default-Application Server Test: C:/Users/username/AppData/Local/chefdk/gem/ruby/2.5.0/gems/kitchen-vra-2.6.0/lib/kitchen/driver/vra.rb:241:in `block in catalog_request'
E, [2019-04-29T11:31:43.070418 #7784] ERROR -- default-Application Server Test: C:/Users/username/AppData/Local/chefdk/gem/ruby/2.5.0/gems/kitchen-vra-2.6.0/lib/kitchen/driver/vra.rb:240:in `each'
E, [2019-04-29T11:31:43.070545 #7784] ERROR -- default-Application Server Test: C:/Users/username/AppData/Local/chefdk/gem/ruby/2.5.0/gems/kitchen-vra-2.6.0/lib/kitchen/driver/vra.rb:240:in `catalog_request'
E, [2019-04-29T11:31:43.070655 #7784] ERROR -- default-Application Server Test: C:/Users/username/AppData/Local/chefdk/gem/ruby/2.5.0/gems/kitchen-vra-2.6.0/lib/kitchen/driver/vra.rb:145:in `request_server'
E, [2019-04-29T11:31:43.070760 #7784] ERROR -- default-Application Server Test: C:/Users/username/AppData/Local/chefdk/gem/ruby/2.5.0/gems/kitchen-vra-2.6.0/lib/kitchen/driver/vra.rb:119:in `create'
E, [2019-04-29T11:31:43.070873 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:484:in `public_send'
E, [2019-04-29T11:31:43.071007 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:484:in `block in perform_action'
E, [2019-04-29T11:31:43.071123 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:551:in `synchronize_or_call'
E, [2019-04-29T11:31:43.071228 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:513:in `block in action'
E, [2019-04-29T11:31:43.071361 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
E, [2019-04-29T11:31:43.071463 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:512:in `action'
E, [2019-04-29T11:31:43.071609 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:484:in `perform_action'
E, [2019-04-29T11:31:43.071742 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:394:in `create_action'
E, [2019-04-29T11:31:43.071851 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:382:in `block (2 levels) in transition_to'
E, [2019-04-29T11:31:43.071955 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/lifecycle_hooks.rb:45:in `run_with_hooks'
E, [2019-04-29T11:31:43.072059 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:381:in `block in transition_to'
E, [2019-04-29T11:31:43.072165 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:380:in `each'
E, [2019-04-29T11:31:43.072265 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:380:in `transition_to'
E, [2019-04-29T11:31:43.072427 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/instance.rb:129:in `create'
E, [2019-04-29T11:31:43.072530 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/command.rb:197:in `public_send'
E, [2019-04-29T11:31:43.072631 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/command.rb:197:in `run_action_in_thread'
E, [2019-04-29T11:31:43.072775 #7784] ERROR -- default-Application Server Test: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/test-kitchen-1.23.2/lib/kitchen/command.rb:169:in `block (2 levels) in run_action'
E, [2019-04-29T11:31:43.072879 #7784] ERROR -- default-Application Server Test: ----End Backtrace-----
stuartpreston commented 5 years ago

Hi @RoinGrindwald - we sat down and had a look at this and it appears to be the way that the specified key from your kitchen.yml file is sent through to an external library (vmware-vra gem). We would appreciate your help trying our workaround first and then we can work out how to push out a fix:

Please could you try editing your local copy of the following file: C:/Users/username/AppData/Local/chefdk/gem/ruby/2.5.0/gems/vmware-vra-2.6.1/lib/vra/request_parameters.rb

On line 54, change split_key = key.split("~") to split_key = key.to_s.split("~")

If that solves the problem, then let us know and we'll figure out how to get the changes into the vmware-vra-gem projectand push out the changes in a future ChefDK/Chef Workstation.

Stuart /cc @russellseymour

PopPopDevOps commented 5 years ago

I just attempted this and still not passing my extra parameters through. I am having the same issue as this https://github.com/chef-partners/vmware-vra-gem/issues/73. Trying to pass in a RHEL version or an SSH key.

RoinGrindwald commented 5 years ago

I have just tested this and it fixed the error of not splitting the ~ from the parameters, but even though all mandatory extra parameters are specified, it still saying they are missing.

platforms:
  - name: Application Server Test
    driver:
      catalog_name: Application Server
      subtenant_name: Windows Services
      cpus: 2
      memory: 4096
      extra_parameters:
        provider-_deploymentName:
          type: string
          value: Testing Test-kitchen
        provider-Hostname:
          type: string
          value: test001
        provider-APP_Server~MaintenenceWindow:
          type: string
          value: 'SAT 12:00-13:00'
        provider-APP_Server~ServerDescription:
          type: string
          value: Testing Test Kitchen
        provider-APP_Server~SRM:
          type: boolean
          value: false
        provider-image:
          type: string
          value: ValueSet.WindowsServer2016
        provider-Vrm.DataCenter.Location:
          type: string
          values: lab
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [Unable to submit request: The data specified within the request is invalid., Field with id APP_Server~SRM is required., Field with id APP_Server~ServerDescription is required., Field with id APP_Server~Hostname is required., Field with id APP_Server~MaintenenceWindow is required., The value for the field with id MaintenenceWindow should be among the permitted values.] on default-Application Server Test
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
stuartpreston commented 5 years ago

@RoinGrindwald Good that you were able to get slightly further. Do you have the rest of the Exception with any stack trace? Without your specific VRA setup it's hard to debug, but clearly the server thinks there's something wrong with the format of the requests being sent in. Is there any debug in logs available on the server that would help decipher what we're sending in vs what you've configured in your kitchen.yml?

I'm guessing some of these extra parameter names are being sent in a format the server doesn't understand. This might just be confirming this statement that extra parameters were not working with VRA 7: https://github.com/chef-partners/vmware-vra-gem/blob/master/README.md#creating-a-request-from-a-yaml-or-json-payload

# create a parameters array, although this only works with VRA6, since VRA7 can have complex data
parameters = yaml_data['requestData']['entries'].map {|item| [item['key'], item['value'].values].flatten }
RoinGrindwald commented 5 years ago

@stuartpreston I created a new Blueprint in VRA for testing and removed/unenforced a bunch of the mandatory fields. I was able to get kitchen create to send a request to VRA. The issue though was none of the CPU, Memory, or Notes were actually captured of the request. I set the kitchen.yaml to 2 cpus and 4096 memory but came through with the defaults 1 cpus and 1024 memory. So something is defiantly wrong with how it's sending this to VRA.

PopPopDevOps commented 5 years ago

If we use the much older version of kitchen-vra (2.2.0) and vmware-vra (2.1.3) we are able to pass in the extra parameters with the newest version of ChefDK (3.9.0) to our vRA server (Version: 7.5.0 (Build: 10053500)). As soon as we switch to any of the newer gems for vra we no longer pass the extra parameters.

stuartpreston commented 5 years ago

@RoinGrindwald Reviewing the above, are you able to try the specified versions of these gems in your system to see if the parameters get passed?

Also, I wanted to double check that you have tried with and without the provider- part of the parameter name in the kitchen.yml? Reviewing the specs for the vRA API, it is possible later versions do not require this part passed in.

PopPopDevOps commented 5 years ago

In my working tests with the older gems I am not using the provider- in the parameters. I have tried with and without for the newer versions and nothing passes.

stuartpreston commented 5 years ago

This should be fixed by the release that was just made to the vmware-vra gem (2.7.0) - as kitchen-vra pins to any 2.x release you should be able to update your chef/ruby installation using chef gem install vmware-vra. The kitchen-vra gem has not been modified.

Please note the provider- prefix on the parameter name should not be required and you should see all parameters included nested parameters in the inputs when you deploy a Blueprint.

mcascone commented 5 years ago

Hi folks, I just upgraded to v2.7.0 and got this error: ERROR: Vra::Exception::RequestError: Unable to submit request: Invalid filter '(userName eq "mcascone" and domain eq null)': Invalid filter value beginning at position 38

Moments prior to upgrading, i successfully ran the spin 3 times with no problems.

My command: knife vra server create $catitem -N 'ICERemote-4' -r 'role[ice-remote-uat]'