Revision e4fde4e3
Added by Ivan Necas about 10 years ago
app/models/concerns/encryptable.rb | ||
---|---|---|
|
||
def puts_and_logs(msg)
|
||
logger.info msg
|
||
puts msg if defined?(Rake) && !Rails.env.test?
|
||
puts msg if Foreman.in_rake? && !Rails.env.test?
|
||
end
|
||
|
||
def is_encryptable?(str)
|
||
... | ... | |
end
|
||
end
|
||
end
|
||
end
|
||
end
|
app/models/config_template.rb | ||
---|---|---|
include Authorizable
|
||
include Taxonomix
|
||
audited :allow_mass_assignment => true
|
||
self.auditing_enabled = !(File.basename($0) == "rake" && ARGV.include?("db:migrate"))
|
||
self.auditing_enabled = !Foreman.in_rake?('db:migrate')
|
||
attr_accessible :name, :template, :template_kind, :template_kind_id, :snippet, :template_combinations_attributes, :operatingsystems, :operatingsystem_ids, :audit_comment
|
||
validates :name, :presence => true, :uniqueness => true
|
||
validates :name, :template, :presence => true
|
app/models/host/managed.rb | ||
---|---|---|
:if => Proc.new { |host| host.managed && pxe_build? }
|
||
validates :ip, :format => {:with => Net::Validations::IP_REGEXP}, :if => Proc.new { |host| host.require_ip_validation? }
|
||
validates :ptable_id, :presence => {:message => N_("cant be blank unless a custom partition has been defined")},
|
||
:if => Proc.new { |host| host.managed and host.disk.empty? and not defined?(Rake) and pxe_build? }
|
||
:if => Proc.new { |host| host.managed and host.disk.empty? and not Foreman.in_rake? and pxe_build? }
|
||
validates :serial, :format => {:with => /[01],\d{3,}n\d/, :message => N_("should follow this format: 0,9600n8")},
|
||
:allow_blank => true, :allow_nil => true
|
||
validates :provision_method, :inclusion => {:in => PROVISION_METHODS, :message => N_('is unknown')}, :if => Proc.new {|host| host.managed?}
|
app/models/operatingsystem.rb | ||
---|---|---|
end
|
||
|
||
def downcase_release_name
|
||
self.release_name.downcase! unless defined?(Rake) or release_name.nil? or release_name.empty?
|
||
self.release_name.downcase! unless Foreman.in_rake? or release_name.nil? or release_name.empty?
|
||
end
|
||
|
||
def boot_files_uri(medium, architecture)
|
app/models/puppetclass.rb | ||
---|---|---|
|
||
puts "*********Proccessing environment #{env} *************"
|
||
cmd = "puppetdoc --output #{out} --modulepath #{modulepaths} -m rdoc"
|
||
puts cmd if defined?(Rake)
|
||
puts cmd if Foreman.in_rake?
|
||
sh cmd do |ok, res|
|
||
if ok
|
||
# Add a link to the class browser
|
app/models/user.rb | ||
---|---|---|
include Foreman::ThreadSession::UserModel
|
||
include Taxonomix
|
||
audited :except => [:last_login_on, :password, :password_hash, :password_salt, :password_confirmation], :allow_mass_assignment => true
|
||
self.auditing_enabled = !(File.basename($0) == "rake" && ARGV.include?("db:migrate"))
|
||
self.auditing_enabled = !Foreman.in_rake?('db:migrate')
|
||
|
||
attr_protected :password_hash, :password_salt, :admin
|
||
attr_accessor :password, :password_confirmation
|
config/application.rb | ||
---|---|---|
SETTINGS[:gce] = defined?(::Fog) && defined?(::Google::APIClient::VERSION)
|
||
SETTINGS[:openstack] = SETTINGS[:rackspace] = SETTINGS[:ec2] = !! defined?(::Fog)
|
||
|
||
require File.expand_path('../../lib/foreman.rb', __FILE__)
|
||
require File.expand_path('../../lib/timed_cached_store.rb', __FILE__)
|
||
require File.expand_path('../../lib/foreman/exception', __FILE__)
|
||
require File.expand_path('../../lib/core_extensions', __FILE__)
|
config/initializers/fix_cache.rb | ||
---|---|---|
fix_db_cache = Setting::General.find_or_initialize_by_name('fix_db_cache',
|
||
:description => 'Fix DB cache on next Foreman restart',
|
||
:settings_type => 'boolean', :default => false)
|
||
if File.basename($0) != "rake" && fix_db_cache.value
|
||
if !Foreman.in_rake? && fix_db_cache.value
|
||
CacheManager.recache!
|
||
end
|
||
end
|
||
end
|
lib/core_extensions.rb | ||
---|---|---|
end
|
||
|
||
def self.per_page
|
||
# defined?(Rake) prevents the failure of db:migrate for postgresql
|
||
# Foreman.in_rake? prevents the failure of db:migrate for postgresql
|
||
# don't query settings table if in rake
|
||
return 20 if defined?(Rake)
|
||
return 20 if Foreman.in_rake?
|
||
Setting.entries_per_page rescue 20
|
||
end
|
||
end
|
lib/foreman.rb | ||
---|---|---|
def self.is_uuid?(str)
|
||
!!(str =~ UUID_REGEXP)
|
||
end
|
||
|
||
def self.in_rake?(rake_task = nil)
|
||
defined?(Rake) && Rake.application.top_level_tasks.any? do |running_rake_task|
|
||
rake_task.nil? || running_rake_task == rake_task
|
||
end
|
||
end
|
||
end
|
test/functional/api/v1/hosts_controller_test.rb | ||
---|---|---|
:domain_id => domains(:mydomain).id,
|
||
:ip => '10.0.0.20',
|
||
:mac => '52:53:00:1e:85:93',
|
||
:ptable_id => ptables(:one).id,
|
||
:architecture_id => Architecture.find_by_name('x86_64').id,
|
||
:operatingsystem_id => Operatingsystem.find_by_name('Redhat').id,
|
||
:puppet_proxy_id => smart_proxies(:one).id,
|
test/functional/api/v2/hosts_controller_test.rb | ||
---|---|---|
:domain_id => domains(:mydomain).id,
|
||
:ip => '10.0.0.20',
|
||
:mac => '52:53:00:1e:85:93',
|
||
:ptable_id => ptables(:one).id,
|
||
:architecture_id => Architecture.find_by_name('x86_64').id,
|
||
:operatingsystem_id => Operatingsystem.find_by_name('Redhat').id,
|
||
:puppet_proxy_id => smart_proxies(:one).id,
|
test/unit/host_observer_test.rb | ||
---|---|---|
disable_orchestration
|
||
host = as_admin do
|
||
Setting[:token_duration] = 30
|
||
host = Host.create! :name => "foo", :mac => "aabbeeddccff", :ip => "2.3.4.244", :managed => true,
|
||
host = Host.create! :name => "foo", :mac => "aabbeeddccff", :ip => "2.3.4.244", :managed => true, :ptable => ptables(:one),
|
||
:build => true, :architecture => architectures(:x86_64), :environment => Environment.first, :puppet_proxy_id => smart_proxies(:one).id,
|
||
:domain => Domain.first, :operatingsystem => operatingsystems(:redhat), :subnet => subnets(:one),
|
||
:root_pass => "xybxa6JUkz63w", :url_options => {:host => 'foreman', :protocol => "http://"}
|
test/unit/host_test.rb | ||
---|---|---|
|
||
test "should not save if IP is not in the right subnet" do
|
||
if unattended?
|
||
host = Host.create :name => "myfullhost", :mac => "aabbecddeeff", :ip => "123.05.02.03",
|
||
host = Host.create :name => "myfullhost", :mac => "aabbecddeeff", :ip => "123.05.02.03", :ptable => ptables(:one),
|
||
:domain => domains(:mydomain), :operatingsystem => Operatingsystem.first, :subnet => subnets(:one), :managed => true,
|
||
:architecture => Architecture.first, :environment => Environment.first, :ptable => Ptable.first, :puppet_proxy => smart_proxies(:puppetmaster)
|
||
assert !host.valid?
|
||
... | ... | |
end
|
||
|
||
test "should save if owner_type is User or Usergroup" do
|
||
host = Host.new :name => "myfullhost", :mac => "aabbecddeeff", :ip => "2.3.4.03",
|
||
host = Host.new :name => "myfullhost", :mac => "aabbecddeeff", :ip => "2.3.4.03", :ptable => ptables(:one),
|
||
:domain => domains(:mydomain), :operatingsystem => operatingsystems(:redhat), :subnet => subnets(:one), :puppet_proxy => smart_proxies(:puppetmaster),
|
||
:subnet => subnets(:one), :architecture => architectures(:x86_64), :environment => environments(:production), :managed => true,
|
||
:owner_type => "User", :root_pass => "xybxa6JUkz63w"
|
Also available in: Unified diff
Fixes #4976 - ensure the process is really running inside a rake task