Class: ForemanDatacenter::DeviceType
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ForemanDatacenter::DeviceType
- Includes:
- Authorizable, ScopedSearchExtensions
- Defined in:
- app/models/foreman_datacenter/device_type.rb
Constant Summary collapse
- SUBDEVICE_ROLES =
['None', 'Parent', 'Child'].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #child? ⇒ Boolean
- #devices_count ⇒ Object
- #management_interfaces ⇒ Object
- #network_interfaces ⇒ Object
- #parent? ⇒ Boolean
- #to_label ⇒ Object
Class Method Details
.for_host(host) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/foreman_datacenter/device_type.rb', line 48 def self.for_host(host) fact = host.fact_value_by_name('productname') if fact device_type = find_by(model: fact.value) if device_type device_type else manufacturer = Manufacturer.for_host(host) if manufacturer create( manufacturer: manufacturer, model: fact.value ) end end end end |
Instance Method Details
#child? ⇒ Boolean
70 71 72 |
# File 'app/models/foreman_datacenter/device_type.rb', line 70 def child? subdevice_role == 'Child' end |
#devices_count ⇒ Object
42 43 44 45 46 |
# File 'app/models/foreman_datacenter/device_type.rb', line 42 def devices_count @devices_count ||= self.class.where(id: id). joins(:devices). count end |
#management_interfaces ⇒ Object
78 79 80 |
# File 'app/models/foreman_datacenter/device_type.rb', line 78 def management_interfaces interface_templates.select(&:mgmt_only) end |
#network_interfaces ⇒ Object
74 75 76 |
# File 'app/models/foreman_datacenter/device_type.rb', line 74 def network_interfaces interface_templates.reject(&:mgmt_only) end |
#parent? ⇒ Boolean
66 67 68 |
# File 'app/models/foreman_datacenter/device_type.rb', line 66 def parent? subdevice_role == 'Parent' end |
#to_label ⇒ Object
82 83 84 |
# File 'app/models/foreman_datacenter/device_type.rb', line 82 def to_label model end |