Class: Ridley::HostConnector::WinRM::CommandUploader
- Inherits:
-
Object
- Object
- Ridley::HostConnector::WinRM::CommandUploader
- Defined in:
- lib/ridley/host_connector/winrm/command_uploader.rb
Overview
Constant Summary collapse
- CHUNK_LIMIT =
1024
Instance Attribute Summary collapse
- #base64_file_name ⇒ String readonly
- #command_file_name ⇒ String readonly
- #winrm ⇒ WinRM::WinRMWebService readonly
Instance Method Summary collapse
-
#cleanup ⇒ Object
Runs a delete command on the files generated by #base64_file_name and #command_file_name.
-
#command ⇒ String
The command to execute the uploaded file.
-
#initialize(winrm) ⇒ CommandUploader
constructor
A new instance of CommandUploader.
-
#upload(command_string) ⇒ Object
Uploads the command encoded as base64 to a file on the host and then uses Powershell to transform the base64 file into the command that was originally passed through.
Constructor Details
#initialize(winrm) ⇒ CommandUploader
Returns a new instance of CommandUploader.
27 28 29 30 31 |
# File 'lib/ridley/host_connector/winrm/command_uploader.rb', line 27 def initialize(winrm) @winrm = winrm @base64_file_name = get_file_path("winrm-upload-base64-#{unique_string}") @command_file_name = get_file_path("winrm-upload-#{unique_string}.bat") end |
Instance Attribute Details
#base64_file_name ⇒ String (readonly)
22 23 24 |
# File 'lib/ridley/host_connector/winrm/command_uploader.rb', line 22 def base64_file_name @base64_file_name end |
#command_file_name ⇒ String (readonly)
24 25 26 |
# File 'lib/ridley/host_connector/winrm/command_uploader.rb', line 24 def command_file_name @command_file_name end |
#winrm ⇒ WinRM::WinRMWebService (readonly)
20 21 22 |
# File 'lib/ridley/host_connector/winrm/command_uploader.rb', line 20 def winrm @winrm end |
Instance Method Details
#cleanup ⇒ Object
Runs a delete command on the files generated by #base64_file_name and #command_file_name
50 51 52 53 |
# File 'lib/ridley/host_connector/winrm/command_uploader.rb', line 50 def cleanup winrm.run_cmd( "del #{base64_file_name} /F /Q" ) winrm.run_cmd( "del #{command_file_name} /F /Q" ) end |
#command ⇒ String
Returns the command to execute the uploaded file.
44 45 46 |
# File 'lib/ridley/host_connector/winrm/command_uploader.rb', line 44 def command "cmd.exe /C #{command_file_name}" end |
#upload(command_string) ⇒ Object
Uploads the command encoded as base64 to a file on the host and then uses Powershell to transform the base64 file into the command that was originally passed through.
38 39 40 41 |
# File 'lib/ridley/host_connector/winrm/command_uploader.rb', line 38 def upload(command_string) upload_command(command_string) convert_command end |