Class: ChefEc2NodeRm::Knife

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/chef_ec2_node_rm/knife.rb

Instance Method Summary collapse

Methods included from Logging

#logger, logger, #logger_device, logger_device

Constructor Details

#initialize(command) ⇒ Knife

Returns a new instance of Knife.



5
6
7
# File 'lib/chef_ec2_node_rm/knife.rb', line 5

def initialize(command)
  @command = "knife #{command} --format json"
end

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/chef_ec2_node_rm/knife.rb', line 9

def run
  logger.debug("Knife command: #{@command}")
  result = `#{@command}`
  result_parsed = begin
    JSON.parse(result)
  rescue JSON::ParserError
    result
  end
  logger.debug("Knife output: #{result_parsed}")
  result_parsed
end