Class: Api::V2::PuppetdbNodesController
- Inherits:
-
V2::BaseController
- Object
- V2::BaseController
- Api::V2::PuppetdbNodesController
- Includes:
- Api::Version2
- Defined in:
- app/controllers/api/v2/puppetdb_nodes_controller.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #import ⇒ Object
- #index ⇒ Object
-
#resource_name ⇒ Object
Overrides because PuppetDB is not backed by ActiveRecord.
- #resource_scope ⇒ Object
- #unknown ⇒ Object
Instance Method Details
#destroy ⇒ Object
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 |
#import ⇒ Object
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 |
#index ⇒ Object
12 13 14 |
# File 'app/controllers/api/v2/puppetdb_nodes_controller.rb', line 12 def index @nodes = Puppetdb.client.query_nodes end |
#resource_name ⇒ Object
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_scope ⇒ Object
45 46 47 |
# File 'app/controllers/api/v2/puppetdb_nodes_controller.rb', line 45 def resource_scope @nodes end |
#unknown ⇒ Object
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 |