Module: ForemanKatelloEngine::Bindings

Defined in:
lib/foreman_katello_engine/bindings.rb

Class Method Summary collapse

Class Method Details

.activation_keyObject



28
29
30
# File 'lib/foreman_katello_engine/bindings.rb', line 28

def activation_key
  resource(KatelloApi::Resources::ActivationKey)
end

.activation_keys_to_subscriptions(org_label, env_label, content_view_label = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/foreman_katello_engine/bindings.rb', line 32

def activation_keys_to_subscriptions(org_label, env_label, content_view_label = nil)
  ak_query = {}
  if content_view_label
    content_views, _ = self.content_view.index('organization_id' => org_label,
                                               'label' => content_view_label)
    if content_view = content_views.first
      ak_query['content_view_id'] = content_view['id']
    end
  end
  environments, _ = self.environment.index('organization_id' => org_label, 'name' => env_label)
  if environment = environments.first
    ak_query['environment_id'] = environment['id']
  end
  if ak_query.any?
    activation_keys, _ = self.activation_key.index(ak_query)
    return activation_keys.reduce({}) do |h, ak|
      h.update(ak['name'] => ak['pools'].map { |pool| pool['productName'] })
    end
  else
    return nil
  end
end

.client_configObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/foreman_katello_engine/bindings.rb', line 8

def client_config
  {
    :base_url => Setting['katello_url'],
    :enable_validations => false,
    :system => 'system_foreman',
    :oauth => {
      :consumer_key => Setting['oauth_consumer_key'],
      :consumer_secret => Setting['oauth_consumer_secret']
    }
  }
end

.content_viewObject



24
25
26
# File 'lib/foreman_katello_engine/bindings.rb', line 24

def content_view
  resource(KatelloApi::Resources::ContentView)
end

.environmentObject



20
21
22
# File 'lib/foreman_katello_engine/bindings.rb', line 20

def environment
  resource(KatelloApi::Resources::Environment)
end