Module: Glue::Candlepin::Consumer
- Included in:
- Katello::System
- Defined in:
- app/models/katello/glue/candlepin/consumer.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Constant Summary collapse
- SYSTEM =
"system"- HYPERVISOR =
"hypervisor"- CANDLEPIN =
"candlepin"- CP_TYPES =
[SYSTEM, HYPERVISOR, CANDLEPIN]
Class Method Summary collapse
-
.included(base) ⇒ Object
TODO: break up method.
Class Method Details
.included(base) ⇒ Object
TODO: break up method
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/katello/glue/candlepin/consumer.rb', line 9 def self.included(base) # rubocop:disable MethodLength base.send :include, LazyAccessor base.send :include, InstanceMethods base.send :extend, ClassMethods base.class_eval do lazy_accessor :href, :facts, :cp_type, :idCert, :owner, :lastCheckin, :created, :guestIds, :installedProducts, :autoheal, :releaseVer, :serviceLevel, :capabilities, :entitlementStatus, :initializer => :candlepin_consumer_info lazy_accessor :candlepin_consumer_info, :initializer => (lambda do |_s| if uuid consumer_json = Resources::Candlepin::Consumer.get(uuid) convert_from_cp_fields(consumer_json) end end) lazy_accessor :entitlements, :initializer => lambda { |_s| Resources::Candlepin::Consumer.entitlements(uuid) } lazy_accessor :pools, :initializer => lambda { |_s| entitlements.collect { |ent| Resources::Candlepin::Pool.find ent["pool"]["id"] } } lazy_accessor :virtual_host, :initializer => (lambda do |_s| host_attributes = Resources::Candlepin::Consumer.virtual_host(self.uuid) (System.find_by(:uuid => host_attributes['uuid']) || System.new(host_attributes)) if host_attributes end) lazy_accessor :virtual_guests, :initializer => (lambda do |_s| guests_attributes = Resources::Candlepin::Consumer.virtual_guests(self.uuid) guests_attributes.map do |attr| System.find_by(:uuid => attr['uuid']) || System.new(attr) end end) lazy_accessor :compliance, :initializer => lambda { |_s| Resources::Candlepin::Consumer.compliance(uuid) } lazy_accessor :events, :initializer => lambda { |_s| Resources::Candlepin::Consumer.events(uuid) } validates :cp_type, :inclusion => {:in => CP_TYPES}, :if => :new_record? validates :facts, :presence => true, :if => :new_record? end end |