Sha256: 9406c396cc4de3c63d785365d5c3a12ae0fbbfa6242d00b4dbb2d35dfbba05f6

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

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

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

      def run
        output[:status] = 'IN PROGRESS'
        begin
          output[:data] = ::SccManager.get_scc_data(input[:base_url],
                                                    '/connect/organizations/repositories',
                                                    input[:login],
                                                    decrypt_field(input[:password]))
          output[:status] = 'SUCCESS'
        rescue StandardError => e
          ::Foreman::Logging.logger('foreman_scc_manager').error "Error while syncronizing SCC-Repositories: #{e}"
          output[:error] = e.to_s
          output[:status] = 'FAILURE'
        end
      end

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

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

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

      def humanized_output
        output.dup.update(data: "Trimmed (got #{output[:data]&.length} repositories")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_scc_manager-1.8.6 app/lib/actions/scc_manager/sync_repositories.rb
foreman_scc_manager-1.8.5 app/lib/actions/scc_manager/sync_repositories.rb
foreman_scc_manager-1.8.4 app/lib/actions/scc_manager/sync_repositories.rb
foreman_scc_manager-1.7.1 app/lib/actions/scc_manager/sync_repositories.rb
foreman_scc_manager-1.8.3 app/lib/actions/scc_manager/sync_repositories.rb