Class: HammerCLIForemanVirtWhoConfigure::SystemCaller
- Inherits:
-
Object
- Object
- HammerCLIForemanVirtWhoConfigure::SystemCaller
- Defined in:
- lib/hammer_cli_foreman_virt_who_configure/system_caller.rb
Instance Method Summary collapse
-
#initialize(tempfile = nil) ⇒ SystemCaller
constructor
A new instance of SystemCaller.
- #system(commad) ⇒ Object
Constructor Details
#initialize(tempfile = nil) ⇒ SystemCaller
Returns a new instance of SystemCaller.
3 4 5 |
# File 'lib/hammer_cli_foreman_virt_who_configure/system_caller.rb', line 3 def initialize(tempfile = nil) @tempfile = tempfile || Tempfile.new('virt_who') end |
Instance Method Details
#system(commad) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/hammer_cli_foreman_virt_who_configure/system_caller.rb', line 7 def system(commad) result = nil begin @tempfile.write(commad) @tempfile.flush # to make sure the command is complete result = Kernel.system("/usr/bin/bash #{@tempfile.path}") ensure @tempfile.close @tempfile.unlink end result end |