Class: ProxyAPI::Puppet

Inherits:
Resource show all
Defined in:
lib/proxy_api/puppet.rb

Instance Attribute Summary

Attributes inherited from Resource

#url

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Puppet


3
4
5
6
# File 'lib/proxy_api/puppet.rb', line 3

def initialize args
  @url  = args[:url] + "/puppet"
  super args
end

Instance Method Details

#classes(env) ⇒ Object


16
17
18
19
20
21
22
# File 'lib/proxy_api/puppet.rb', line 16

def classes env
  return if env.blank?
  pcs = parse(get "environments/#{env}/classes")
  Hash[pcs.map { |k| [k.keys.first, Foreman::ImporterPuppetclass.new(k.values.first)] }]
rescue RestClient::ResourceNotFound
  []
end

#environment(env) ⇒ Object


12
13
14
# File 'lib/proxy_api/puppet.rb', line 12

def environment env
  parse(get "environments/#{env}")
end

#environmentsObject


8
9
10
# File 'lib/proxy_api/puppet.rb', line 8

def environments
  parse(get "environments")
end

#run(hosts) ⇒ Object


24
25
26
# File 'lib/proxy_api/puppet.rb', line 24

def run hosts
  parse(post({:nodes => hosts}, "run"))
end