Class: Actions::SccManager::SyncRepositories

Inherits:
EntryAction
  • Object
show all
Includes:
EncryptValue
Defined in:
app/lib/actions/scc_manager/sync_repositories.rb

Instance Method Summary collapse

Instance Method Details

#finalizeObject



24
25
26
27
# File 'app/lib/actions/scc_manager/sync_repositories.rb', line 24

def finalize
  # this is only executed if 'run' succeeds
  SccAccount.find(input[:scc_account][:id]).update_scc_repositories(output[:data])
end

#humanized_nameObject



33
34
35
# File 'app/lib/actions/scc_manager/sync_repositories.rb', line 33

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

#humanized_outputObject



37
38
39
# File 'app/lib/actions/scc_manager/sync_repositories.rb', line 37

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

#plan(scc_account) ⇒ Object



6
7
8
9
10
11
12
# File 'app/lib/actions/scc_manager/sync_repositories.rb', line 6

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

#rescue_strategyObject



29
30
31
# File 'app/lib/actions/scc_manager/sync_repositories.rb', line 29

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

#runObject



14
15
16
17
18
19
20
21
22
# File 'app/lib/actions/scc_manager/sync_repositories.rb', line 14

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