Sha256: 89270cf8958321575ba7e07f14ede6f62fa44f47a7e1e4fecc51b65b97954ab6

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

module Actions
  module SccManager
    class SyncProducts < Actions::EntryAction
      include EncryptValue

      def plan(scc_account)
        action_subject(scc_account)
        password = encrypt_field(scc_account.password)
        plan_self(id: scc_account.id,
          base_url: scc_account.base_url,
          login: scc_account.login,
          password: password)
      end

      def run
        products = ::SccManager.get_scc_data(input.fetch(:base_url),
          '/connect/organizations/products',
          input.fetch(:login),
          decrypt_field(input.fetch(:password)))
        output[:data] = ::SccManager.sanitize_products(products).values
      rescue StandardError => e
        ::Foreman::Logging.logger('foreman_scc_manager').error "Error while syncronizing SCC-Products: #{e}"
        error! e.to_s
      end

      def finalize
        # this is only executed if 'run' succeeds
        SccAccount.find(input.fetch(:id)).update_scc_products(output.fetch(:data))
      end

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

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

      def humanized_output
        output.dup.update(data: 'Trimmed')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_scc_manager-4.0.0 app/lib/actions/scc_manager/sync_products.rb
foreman_scc_manager-3.1.1 app/lib/actions/scc_manager/sync_products.rb
foreman_scc_manager-3.1.0 app/lib/actions/scc_manager/sync_products.rb
foreman_scc_manager-3.0.0 app/lib/actions/scc_manager/sync_products.rb