diff --git a/app/lib/actions/katello/host/register.rb b/app/lib/actions/katello/host/register.rb index 177506bbf13..d05be3323fd 100644 --- a/app/lib/actions/katello/host/register.rb +++ b/app/lib/actions/katello/host/register.rb @@ -24,8 +24,6 @@ def plan(host, consumer_params, content_view_environment, activation_keys = []) host.subscription_facet = plan_subscription_facet(host, activation_keys, consumer_params) host.save! - ::Katello::Host::SubscriptionFacet.update_facts(host, consumer_params[:facts]) unless consumer_params[:facts].blank? - action_subject host cp_create = plan_action(Candlepin::Consumer::Create, cp_environment_id: content_view_environment.cp_id, @@ -33,7 +31,7 @@ def plan(host, consumer_params, content_view_environment, activation_keys = []) return if cp_create.error plan_self(uuid: cp_create.output[:response][:uuid], host_id: host.id, hostname: host.name, - user_id: User.current.id) + user_id: User.current.id, :facts => consumer_params[:facts]) plan_action(Pulp::Consumer::Create, uuid: cp_create.output[:response][:uuid], name: host.name) end end @@ -46,6 +44,14 @@ def humanized_name end end + def run + host = ::Host.find(input[:host_id]) + unless input[:facts].blank? + ::Katello::Host::SubscriptionFacet.update_facts(host, input[:facts]) + input[:facts] = 'TRIMMED' + end + end + def finalize host = ::Host.find(input[:host_id]) host.content_facet.uuid = input[:uuid] diff --git a/app/lib/actions/katello/host/update.rb b/app/lib/actions/katello/host/update.rb index f4da03b4249..2b32f631ebc 100644 --- a/app/lib/actions/katello/host/update.rb +++ b/app/lib/actions/katello/host/update.rb @@ -6,7 +6,7 @@ class Update < Actions::EntryAction def plan(host, consumer_params = nil) action_subject host - plan_self(:hostname => host.name) + plan_self(:hostname => host.name, :facts => consumer_params.try(:[], :facts), :host_id => host.id) sequence do host.content_facet.save! if host.content_facet @@ -17,7 +17,6 @@ def plan(host, consumer_params = nil) else consumer_params = host.subscription_facet.consumer_attributes end - ::Katello::Host::SubscriptionFacet.update_facts(::Host.find(host.id), consumer_params[:facts]) unless consumer_params[:facts].blank? host.subscription_facet.save! plan_action(::Actions::Candlepin::Consumer::Update, host.subscription_facet.uuid, consumer_params) end @@ -28,6 +27,14 @@ def plan(host, consumer_params = nil) end end + def run + host = ::Host.find(input[:host_id]) + unless input[:facts].blank? + ::Katello::Host::SubscriptionFacet.update_facts(host, input[:facts]) + input[:facts] = 'TRIMMED' + end + end + def resource_locks :update end diff --git a/test/actions/katello/host/register_test.rb b/test/actions/katello/host/register_test.rb index 6c0e9fd6cce..e9d983c4733 100644 --- a/test/actions/katello/host/register_test.rb +++ b/test/actions/katello/host/register_test.rb @@ -26,7 +26,6 @@ class RegisterTest < ActiveSupport::TestCase action = create_action action_class new_host = Host::Managed.new(:name => 'foobar', :managed => false) action.stubs(:action_subject).with(new_host) - ::Katello::Host::SubscriptionFacet.expects(:update_facts).with(new_host, rhsm_params[:facts]) plan_action action, new_host, rhsm_params, @content_view_environment assert_action_planed_with(action, candlepin_class, :cp_environment_id => @content_view_environment.cp_id,