Class: Entitlement::PayPerUse

Inherits:
Entry
  • Object
show all
Defined in:
lib/entitlement/pay_per_use.rb

Overview

This entry allows you to specify pay as you go ruby code to be run for checking entitlement validity

Instance Attribute Summary

Attributes inherited from Entry

#file

Instance Method Summary collapse

Methods inherited from Entry

#days_left, #expiring?, #notify_if_expiring, #purgable?

Constructor Details

#initialize(modules, public_key, api_url, company, node_name, &validate) ⇒ PayPerUse

Returns a new instance of PayPerUse.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/entitlement/pay_per_use.rb', line 29

def initialize(modules, public_key, api_url, company, node_name, &validate)
  api_url           ||= 'http://api.enterprisemodules.com/api/activation'
  @activated_modules  = []
  @activation_uri     = URI(api_url)
  @public_key         = public_key
  @company            = company
  @node_name          = node_name
  @transaction_object = transaction_object
  @cipher_key         = 'p4yasy0ugo_enterprise_modules163'
  @cipher_iv          = '0834921903420174'
  begin
    @catalog_uuid     = catalog_uuid
    @catalog_version  = catalog_version
  rescue NoMethodError
    # No catalog yet leave catalog items empty
  end
  super(modules, nil, nil, &validate)
end

Instance Method Details

#all_checks?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/entitlement/pay_per_use.rb', line 54

def all_checks?
  local_validated? ? true : validate_via_api
end

#inspectObject



58
59
60
61
# File 'lib/entitlement/pay_per_use.rb', line 58

def inspect
  super
  puts 'Pay as you go: <some custom checks>'
end

#valid?(full_action, _resources = nil) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/entitlement/pay_per_use.rb', line 48

def valid?(full_action, _resources = nil)
  fetch_module_name(full_action)
  Puppet.debug 'Found a pay as you go entitlement...'
  all_checks?
end