Module: Glue::Candlepin::Consumer::ClassMethods
- Defined in:
- app/models/katello/glue/candlepin/consumer.rb
Instance Method Summary collapse
- #all_by_pool(pool_id) ⇒ Object
- #all_by_pool_uuid(pool_id) ⇒ Object
-
#interfaces(facts) ⇒ Object
interface listings come in the form of.
- #prepopulate!(systems) ⇒ Object
Instance Method Details
#all_by_pool(pool_id) ⇒ Object
347 348 349 350 351 |
# File 'app/models/katello/glue/candlepin/consumer.rb', line 347 def all_by_pool(pool_id) entitlements = Resources::Candlepin::Entitlement.get system_uuids = entitlements.delete_if { |ent| ent["pool"]["id"] != pool_id }.map { |ent| ent["consumer"]["uuid"] } return where(:uuid => system_uuids) end |
#all_by_pool_uuid(pool_id) ⇒ Object
353 354 355 356 357 |
# File 'app/models/katello/glue/candlepin/consumer.rb', line 353 def all_by_pool_uuid(pool_id) entitlements = Resources::Candlepin::Entitlement.get system_uuids = entitlements.delete_if { |ent| ent["pool"]["id"] != pool_id }.map { |ent| ent["consumer"]["uuid"] } return system_uuids end |
#interfaces(facts) ⇒ Object
interface listings come in the form of
net.interface.em1.ipv4_address net.interface.eth0.ipv4_broadcast
there are multiple entries for each interface, but we only need the ipv4 and mac addresses
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'app/models/katello/glue/candlepin/consumer.rb', line 366 def interfaces(facts) interfaces = [] facts.keys.each do |key| match = /net\.interface\.([^\.]*)/.match(key) if !match.nil? && !match[1].nil? interfaces << match[1] end end interface_set = [] interfaces.uniq.each do |interface| addr = facts["net.interface.#{interface}.ipv4_address"] # older subman versions report .ipaddr addr ||= facts["net.interface.#{interface}.ipaddr"] mac = facts["net.interface.#{interface}.mac_address"] interface_set << { :name => interface, :addr => addr, :mac => mac } if !addr.nil? || !mac.nil? end interface_set end |
#prepopulate!(systems) ⇒ Object
341 342 343 344 345 |
# File 'app/models/katello/glue/candlepin/consumer.rb', line 341 def prepopulate!(systems) uuids = systems.collect { |system| [:uuid, system.uuid] } items = Resources::Candlepin::Consumer.get(uuids) systems.each { |system| system.populate_from(items) } end |