module ForemanSalt::Concerns::HostgroupExtensions

def all_salt_modules

def all_salt_modules
  ForemanSalt::SaltModule.in_environment(salt_environment).where(:id => salt_module_ids + inherited_salt_module_ids)
end

def inherited_salt_environment_id

def inherited_salt_environment_id
  self[:salt_environment_id] || nested(:salt_environment_id)
end

def inherited_salt_module_ids

def inherited_salt_module_ids
  ancestors.map(&:salt_module_ids).flatten.uniq
end

def inherited_salt_modules

def inherited_salt_modules
  ForemanSalt::SaltModule.where(:id => inherited_salt_module_ids)
end

def inherited_salt_proxy_id

def inherited_salt_proxy_id
  self[:salt_proxy_id] || nested(:salt_proxy_id)
end

def salt_environment

def salt_environment
  if ancestry.present?
    ForemanSalt::SaltEnvironment.find_by_id(inherited_salt_environment_id)
  else
    super
  end
end

def salt_master

def salt_master
  salt_proxy.to_s
end

def salt_proxy

def salt_proxy
  if ancestry.present?
    SmartProxy.with_features('Salt').find_by_id(inherited_salt_proxy_id)
  else
    super
  end
end