Class: Environment

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Authorization, Taxonomix
Defined in:
app/models/environment.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Authorization

#enforce_create_permissions, #enforce_destroy_permissions, #enforce_edit_permissions, #enforce_permissions, included, #permission_failed?

Methods included from Taxonomix

included

Class Method Details

.puppetEnvs(proxy = nil) ⇒ Object

TODO: this needs to be removed, as PuppetDOC generation no longer works if the manifests are not on the foreman host returns an hash of all puppet environments and their relative paths


38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/environment.rb', line 38

def puppetEnvs proxy = nil

  url = (proxy || SmartProxy.puppet_proxies.first).try(:url)
  raise ::Foreman::Exception.new(N_("Can't find a valid Foreman Proxy with a Puppet feature")) if url.blank?
  proxy = ProxyAPI::Puppet.new :url => url
  HashWithIndifferentAccess[proxy.environments.map { |e|
    [e, HashWithIndifferentAccess[proxy.classes(e).map {|k|
      klass = k.keys.first
      [klass, k[klass]["params"]]
    }]]
  }]
end

Instance Method Details

#as_json(options = { }) ⇒ Object


53
54
55
56
# File 'app/models/environment.rb', line 53

def as_json(options={ })
  options ||= { }
  super({ :only => [:name, :id] }.merge(options))
end

#to_paramObject


29
30
31
# File 'app/models/environment.rb', line 29

def to_param
  name
end