Sha256: 88e9a9e71ebb89b0963b1411199b16848bc16f3f4c703755ba4a51defe7b6557

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module Actions
  module SccManager
    class SyncProducts < Actions::EntryAction
      def plan(scc_account)
        action_subject(scc_account)
        plan_self(id: scc_account.id,
                  base_url: scc_account.base_url,
                  login: scc_account.login,
                  password: scc_account.password)
      end

      def run
        output[:status] = 'SUCCESS'
        begin
          output[:data] = ::SccManager.get_scc_data(input.fetch(:base_url),
                                                    '/connect/organizations/products',
                                                    input.fetch(:login),
                                                    input.fetch(:password))
        rescue StandardError
          output[:status] = 'FAILURE'
        end
      end

      def finalize
        SccAccount.find(input.fetch(:id)).update_scc_products(output.fetch(:data)) if output[:status] == 'SUCCESS'
      end

      def rescue_strategy
        Dynflow::Action::Rescue::Fail
      end

      def humanized_name
        _('Sync SUSE subscriptions (Products)')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_scc_manager-1.4.0 app/lib/actions/scc_manager/sync_products.rb