Class: ChefEc2NodeRm::Knife
- Inherits:
-
Object
- Object
- ChefEc2NodeRm::Knife
- Includes:
- Logging
- Defined in:
- lib/chef_ec2_node_rm/knife.rb
Instance Method Summary collapse
-
#initialize(command) ⇒ Knife
constructor
A new instance of Knife.
- #run ⇒ Object
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
#run ⇒ Object
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 |