Revision 43c4bd72
Added by Marek Hulán over 9 years ago
app/models/domain.rb | ||
---|---|---|
audited :allow_mass_assignment => true
|
||
|
||
validates_lengths_from_database
|
||
has_many_hosts
|
||
has_many :hostgroups
|
||
#order matters! see https://github.com/rails/rails/issues/670
|
||
before_destroy EnsureNotUsedBy.new(:hosts, :hostgroups, :subnets)
|
||
before_destroy EnsureNotUsedBy.new(:interfaces, :hostgroups, :subnets)
|
||
has_many :subnet_domains, :dependent => :destroy
|
||
has_many :subnets, :through => :subnet_domains
|
||
belongs_to :dns, :class_name => "SmartProxy"
|
||
has_many :domain_parameters, :dependent => :destroy, :foreign_key => :reference_id, :inverse_of => :domain
|
||
has_many :parameters, :dependent => :destroy, :foreign_key => :reference_id, :class_name => "DomainParameter"
|
||
has_many :interfaces, :class_name => 'Nic::Base'
|
||
has_many :primary_interfaces, :class_name => 'Nic::Base', :conditions => { :primary => true }
|
||
has_many :hosts, :through => :interfaces
|
||
has_many :primary_hosts, :through => :primary_interfaces, :source => :host
|
||
|
||
accepts_nested_attributes_for :domain_parameters, :allow_destroy => true
|
||
include ParameterValidators
|
||
... | ... | |
['name']
|
||
end
|
||
|
||
# overwrite method in taxonomix, since domain is not direct association of host anymore
|
||
def used_taxonomy_ids(type)
|
||
return [] if new_record?
|
||
Host::Base.joins(:primary_interface).where(:nics => {:domain_id => id}).pluck(type).compact.uniq
|
||
end
|
||
|
||
end
|
Also available in: Unified diff
Fixes #7456 - Extract primary interface from host
Contributions from:All host must have at least one primary interface and one provision (can
be the same interface). Primary interface gives host a name so even
unamanaged host have primary interface (we skip validations of other
attributes for unamanged hosts though).
Host still have name attribute which is a cache of primary interface name.
Therefore we can use the host name in SQL queries, as a friendly_id etc.
- realm moved to the primary tab
- fqdn in nics table
- flags in nics table
- checkboxes for provision and primary flags
- modal resize fix
- original fields for primary NIC removed
- skipping validation for new resources
- warnings before switching flags and table update
- host name and primary interface name connected
- host domain name in the page title
- nics on host show page
- clearing modal window on cancel
- fixed domain validation in NIC::Base
- ip suggestion for all interfaces
- flags switchable from the overview table
- use icons instead of text for primary/provision on NICs overview tab
- attempt to fix sending NIC template
- fix fqdn algorithm
- ip addres in the overview table
- fix for class name collision
- better behavior of host name <-> primary name sync
- fix for subnet combobox values
- fix for modal poping up on form submission
- network partial for CRs moved from VM tab to modal
- fix ip suggestion race for ipam=db