Class: Beaker::DSL::PEClientTools::ExecutableHelper::Private
- Inherits:
-
Object
- Object
- Beaker::DSL::PEClientTools::ExecutableHelper::Private
- Includes:
- Beaker::DSL, Helpers::HostHelpers, Beaker::DSL::Patterns, Wrappers
- Defined in:
- lib/beaker-pe/pe-client-tools/executable_helper.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #build_win_batch_command(host, batch_contents, command_options) ⇒ Object
- #tool(tool, *args, &block) ⇒ Object
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
101 102 103 |
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 101 def logger @logger end |
Instance Method Details
#build_win_batch_command(host, batch_contents, command_options) ⇒ Object
145 146 147 148 149 150 151 152 |
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 145 def build_win_batch_command( host, batch_contents, ) = Time.new.strftime('%Y-%m-%d_%H.%M.%S') # Create Temp file # make file fully qualified batch_file = "#{host.system_temp_path}\\#{timestamp}.bat" create_remote_file(host, batch_file, batch_contents) Beaker::Command.new("\"#{batch_file}\"", [], ) end |
#tool(tool, *args, &block) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/beaker-pe/pe-client-tools/executable_helper.rb', line 103 def tool(tool, *args, &block) host = args.shift @logger = host.logger = {} .merge!(args.pop) if args.last.is_a?(Hash) if host.platform =~ /win/i program_files = host.exec(Beaker::Command.new('echo', ['%PROGRAMFILES%'], :cmdexe => true)).stdout.chomp client_tools_dir = "#{program_files}\\#{['Puppet Labs', 'Client', 'tools', 'bin'].join('\\')}\\" tool_executable = "\"#{client_tools_dir}puppet-#{tool.to_s}.exe\"" #TODO does this need to be more detailed to pass exit codes???? # TODO make batch file direct output to separate file batch_contents ="call \#{tool_executable} \#{args.join(' ')}\n" @command = build_win_batch_command( host, batch_contents, {:cmdexe => true}) else tool_executable = '/opt/puppetlabs/client-tools/bin/' << "puppet-#{tool.to_s}" @command = Beaker::Command.new(tool_executable, args, {:cmdexe => true}) end result = host.exec(@command, ) # Also, let additional checking be performed by the caller. if block_given? case block.arity #block with arity of 0, just hand back yourself when 0 yield self #block with arity of 1 or greater, hand back the result object else yield result end end result end |