diff --git a/app/controllers/api/v2/hosts_controller.rb b/app/controllers/api/v2/hosts_controller.rb index 49c655d87c5..38c22d4e645 100644 --- a/app/controllers/api/v2/hosts_controller.rb +++ b/app/controllers/api/v2/hosts_controller.rb @@ -134,7 +134,7 @@ def status def vm_compute_attributes render :json => {} unless @host - attrs = @host.vm_compute_attributes + attrs = @host.vm_compute_attributes || {} safe_attrs = {} attrs.each_pair do |k,v| # clean up the compute attributes to be suitable for output @@ -146,7 +146,7 @@ def vm_compute_attributes safe_attrs[k] = v end end - render :json => { :compute_attributes => safe_attrs } + render :json => safe_attrs end api :PUT, "/hosts/:id/puppetrun", N_("Force a Puppet agent run on the host") diff --git a/test/functional/api/v2/hosts_controller_test.rb b/test/functional/api/v2/hosts_controller_test.rb index d5141627559..f3c7f0bfd02 100644 --- a/test/functional/api/v2/hosts_controller_test.rb +++ b/test/functional/api/v2/hosts_controller_test.rb @@ -260,7 +260,7 @@ def last_host get :vm_compute_attributes, { :id => host.to_param } assert_response :success data = JSON.parse(@response.body) - assert_equal data, "compute_attributes" => { "cpus" => 4 } + assert_equal data, "cpus" => 4 ComputeResource.any_instance.unstub(:vm_compute_attributes_for) end