Class: Actions::SccManager::SyncProducts

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

Instance Method Summary collapse

Instance Method Details

#finalizeObject



26
27
28
29
# File 'app/lib/actions/scc_manager/sync_products.rb', line 26

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

#humanized_nameObject



35
36
37
# File 'app/lib/actions/scc_manager/sync_products.rb', line 35

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

#humanized_outputObject



39
40
41
# File 'app/lib/actions/scc_manager/sync_products.rb', line 39

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

#plan(scc_account) ⇒ Object



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

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

#rescue_strategyObject



31
32
33
# File 'app/lib/actions/scc_manager/sync_products.rb', line 31

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

#runObject



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

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