Class: Api::V2::PuppetdbNodesController

Inherits:
V2::BaseController
  • Object
show all
Includes:
Api::Version2
Defined in:
app/controllers/api/v2/puppetdb_nodes_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



26
27
28
29
30
# File 'app/controllers/api/v2/puppetdb_nodes_controller.rb', line 26

def destroy
  uuid = Puppetdb.client.deactivate_node(@node)
  response = { job: { uuid: uuid } }
  process_success response
end

#importObject



35
36
37
38
# File 'app/controllers/api/v2/puppetdb_nodes_controller.rb', line 35

def import
  facts = Puppetdb.client.facts(@node)
  @host = PuppetdbHost.new(facts: facts).to_host
end

#indexObject



12
13
14
# File 'app/controllers/api/v2/puppetdb_nodes_controller.rb', line 12

def index
  @nodes = Puppetdb.client.query_nodes
end

#resource_nameObject

Overrides because PuppetDB is not backed by ActiveRecord



41
42
43
# File 'app/controllers/api/v2/puppetdb_nodes_controller.rb', line 41

def resource_name
  'node'
end

#resource_scopeObject



45
46
47
# File 'app/controllers/api/v2/puppetdb_nodes_controller.rb', line 45

def resource_scope
  @nodes
end

#unknownObject



17
18
19
20
21
# File 'app/controllers/api/v2/puppetdb_nodes_controller.rb', line 17

def unknown
  @foreman_hosts = Host.unscoped.pluck(:name)
  @puppetdb_hosts = Puppetdb.client.query_nodes
  @nodes = @puppetdb_hosts - @foreman_hosts
end