Module: Katello::Concerns::HostgroupExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/models/katello/concerns/hostgroup_extensions.rb

Instance Method Summary collapse

Instance Method Details

#add_organization_for_environmentObject



59
60
61
62
63
64
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 59

def add_organization_for_environment
  #ensures that the group's orgs include whatever lifecycle environment is assigned
  if self.lifecycle_environment && !self.organizations.include?(self.lifecycle_environment.organization)
    self.organizations << self.lifecycle_environment.organization
  end
end

#content_and_puppet_match?Boolean

Returns:

  • (Boolean)


66
67
68
69
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 66

def content_and_puppet_match?
  self.content_view && self.lifecycle_environment && self.content_view == self.environment.try(:content_view) &&
      self.lifecycle_environment == self.environment.try(:lifecycle_environment)
end

#content_sourceObject

instead of calling nested_attribute_for(:content_source_id) in Foreman, define the methods explictedly



33
34
35
36
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 33

def content_source
  return super if ancestry.nil? || self.content_source_id.present?
  SmartProxy.find_by(:id => inherited_content_source_id)
end

#content_viewObject



22
23
24
25
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 22

def content_view
  return super if ancestry.nil? || self.content_view_id.present?
  Katello::ContentView.find_by(:id => inherited_content_view_id)
end

#inherited_content_source_idObject



38
39
40
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 38

def inherited_content_source_id
  inherited_ancestry_attribute(:content_source_id)
end

#inherited_content_view_idObject



42
43
44
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 42

def inherited_content_view_id
  inherited_ancestry_attribute(:content_view_id)
end

#inherited_kickstart_repository_idObject



50
51
52
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 50

def inherited_kickstart_repository_id
  inherited_ancestry_attribute(:kickstart_repository_id)
end

#inherited_lifecycle_environment_idObject



46
47
48
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 46

def inherited_lifecycle_environment_id
  inherited_ancestry_attribute(:lifecycle_environment_id)
end

#lifecycle_environmentObject



27
28
29
30
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 27

def lifecycle_environment
  return super if ancestry.nil? || self.lifecycle_environment_id.present?
  Katello::KTEnvironment.find_by(:id => inherited_lifecycle_environment_id)
end

#rhsm_organization_labelObject



54
55
56
57
# File 'app/models/katello/concerns/hostgroup_extensions.rb', line 54

def rhsm_organization_label
  #used for rhsm registration snippet, since hostgroup can belong to muliple organizations, use lifecycle environment or cv
  (self.lifecycle_environment || self.content_view).try(:organization).try(:label)
end