Project

General

Profile

Bug #12154

Cannot create host via API using compute profile created in the UI.

Added by Alex Shepherd about 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Difficulty:
trivial
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

I've been trying to create DigitalOcean droplets using TheForeman's API, and have found what I'm pretty certain is a bug in the Compute Profile form.

The problem: The Compute Profile form uses the local database's image.id as the select value, where all other compute resources use image.uuid. This means that when saved, image_id in compute_attributes contains the local PostgreSQL database's image id, not the provider's UUID, which is used to identify the image to the Compute Resource provider. Needless to say, sending DO an ID that only exists in our local database doesn't work, and we get the message "This image does not belong to ...".

To fix the issue, :id needed changing to :uuid in app/views/compute_resources_vms/form/digitalocean/_base.html.erb on the image_selection line

This broke the UI, as it was unable to use image.uuid in the normal Host creation form. To fix it I added uuid to attr_accessor on app/models/concerns/fog_extensions/digitalocean/image.rb

This now appears to work for both UI and API host creation with Profiles.

Associated revisions

Revision d4519974 (diff)
Added by Alex Shepherd almost 6 years ago

Fix #12154 - use image.uuid instead of image.id to fix API host creation

History

#2 Updated by Shlomi Zadok about 6 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Alex Shepherd
  • Pull request https://github.com/theforeman/foreman-digitalocean/pull/9 added
  • Pull request deleted ()

#3 Updated by Tommy McNeely about 6 years ago

Thanks Alex, can you fix your commit message as per the "standards" ... maybe something like

Fixes #12154 - use image.uuid instead of image.id to fix API host creation

~tommy

#4 Updated by Alex Shepherd almost 6 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF