Project

General

Profile

Actions

Bug #10093

closed

Creating VMware host over API with compute profile doesn't perform image provisioning

Added by Chad Walstrom over 9 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Compute resources - VMware
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Scenario: Clone a VMware image via API using compute_profiles
  Given that a VMware vSphere cluster is a compute resource,
  And given that a compute profile exists on that resource,
  And given that the compute profile has a valid VMware image associated with it,
  And given that a hostgroup associated is with that compute profile,
  When I POST to /api/v2/hosts with the hostgroup_id and compute_resource_id,
  Then I should create a new VMware guest as a clone from the specified image.

This scenario fails in the following conditional expression:

      if args[:image_id].present?
        clone_vm(args)
      else
        vm = new_vm(args)
        vm.save
      end

The test "#create_vm calls clone_vm when image provisioning" currently succeeds because it is incorrectly instantiating the input hash with indifferent access. Updating the test to use an unmodified "image_id" key will show the test correctly failing, exposing this bug.

A suggestion to fix this is:

    Modified   app/models/compute_resources/foreman/model/vmware.rb
diff --git a/app/models/compute_resources/foreman/model/vmware.rb b/app/models/compute_resources/foreman/model/vmware.rb
index 9c4d471..9871d8b 100644
--- a/app/models/compute_resources/foreman/model/vmware.rb
+++ b/app/models/compute_resources/foreman/model/vmware.rb
@@ -313,7 +313,7 @@ module Foreman::Model
       test_connection
       return unless errors.empty?

-      args = parse_networks(args)
+      args = parse_networks(args.with_indifferent_access)
       if args[:image_id].present?
         clone_vm(args)
       else
@@ -470,4 +470,3 @@ module Foreman::Model
     end
   end
 end
-

Actions #1

Updated by Dominic Cleal over 9 years ago

  • Subject changed from VMware#create_vm calls clone_vm when image provisioning to Creating VMware host over API with compute profile doesn't perform image provisioning
  • Category set to Compute resources - VMware
Actions #2

Updated by The Foreman Bot over 9 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2294 added
  • Pull request deleted ()
Actions #3

Updated by Anonymous over 9 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #4

Updated by Dominic Cleal over 9 years ago

  • Assignee set to Chad Walstrom
  • Translation missing: en.field_release set to 28
Actions

Also available in: Atom PDF