When importing an image, detect its architecture and stash that as an
:architecture attribute on the Image itself. When creating a deployable,
look for the attribute and restrict HWPs to those matching.
This depends on a matching patch to aeolus-image-rubygem.
Resolves
https://bugzilla.redhat.com/show_bug.cgi?id=795743
---
src/app/controllers/deployables_controller.rb | 6 +++++-
src/app/models/hardware_profile.rb | 1 +
src/lib/image.rb | 3 ++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/deployables_controller.rb
b/src/app/controllers/deployables_controller.rb
index e37bc4a..3fdea3f 100644
--- a/src/app/controllers/deployables_controller.rb
+++ b/src/app/controllers/deployables_controller.rb
@@ -37,7 +37,11 @@ class DeployablesController < ApplicationController
require_privilege(Privilege::CREATE, Deployable)
if params[:create_from_image]
@image = Aeolus::Image::Warehouse::Image.find(params[:create_from_image])
- @hw_profiles = HardwareProfile.frontend.list_for_user(current_user,
Privilege::VIEW)
+ if @image.respond_to?(:architecture)
+ @hw_profiles =
HardwareProfile.frontend.for_architecture((a)image.architecture).list_for_user(current_user,
Privilege::VIEW)
+ else
+ @hw_profiles = HardwareProfile.frontend.list_for_user(current_user,
Privilege::VIEW)
+ end
@deployable.name = @image.name
@selected_catalogs = params[:catalog_id].to_a
load_catalogs
diff --git a/src/app/models/hardware_profile.rb b/src/app/models/hardware_profile.rb
index 087d2ae..a75e4de 100644
--- a/src/app/models/hardware_profile.rb
+++ b/src/app/models/hardware_profile.rb
@@ -43,6 +43,7 @@ class HardwareProfile < ActiveRecord::Base
has_many :permissions, :as => :permission_object, :dependent => :destroy
has_many :instances
scope :frontend, :conditions => { :provider_id => nil }
+ scope :for_architecture, lambda {|arch|
includes(:architecture).where('hardware_profile_properties.value' => arch)}
has_many :provider_instances, :class_name => "Instance",
:foreign_key => "provider_hardware_profile_id"
diff --git a/src/lib/image.rb b/src/lib/image.rb
index 9911703..cfdbc78 100644
--- a/src/lib/image.rb
+++ b/src/lib/image.rb
@@ -25,9 +25,10 @@ class Image
raise Aeolus::Conductor::Base::ImageNotFound unless img.present?
# We have the image name in the cloud provider, so we might as well use it
xml ||= "<image><name>#{img.name}</name></image>"
if img.name.present?
+ arch = img.architecture
provider = provider_account.provider
account_id = provider_account.credentials_hash['username']
- image = Aeolus::Image.import(provider.name, provider.provider_type.deltacloud_driver,
image_id, account_id, environment.name, xml)
+ image = Aeolus::Image.import(provider.name, provider.provider_type.deltacloud_driver,
image_id, account_id, environment.name, xml, arch)
image
end
end
--
1.7.6.5