Class: UnimatrixCLI::Citadel::Instance::ScpCommand
- Inherits:
-
CitadelCommand
- Object
- UnimatrixCLI::Command
- CitadelCommand
- UnimatrixCLI::Citadel::Instance::ScpCommand
- Defined in:
- lib/unimatrix_cli/citadel/instance/scp_command.rb
Constant Summary collapse
- DIRECTIONS =
%w( from to )
Constants inherited from CitadelCommand
CitadelCommand::APIS, CitadelCommand::PRIVATE_SUBNETS, CitadelCommand::ROOT
Instance Method Summary collapse
- #execute ⇒ Object
-
#execute_scp ⇒ Object
—————————————————————————-.
Methods inherited from CitadelCommand
#account, #aws_client, #instance_details, #instance_list, #instances_by_zone, #key, #load_environment, #user, #write_instance_details
Methods inherited from UnimatrixCLI::Command
available_commands, descendants, #initialize, #read_file, #validate, #validate_collection, #write
Methods included from UnimatrixParser
Constructor Details
This class inherits a constructor from UnimatrixCLI::Command
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/unimatrix_cli/citadel/instance/scp_command.rb', line 16 def execute if [ :direction ] && DIRECTIONS.include?( [ :direction ] ) super execute_scp else write( message: "#{ @options[ :direction ] } is not a valid direction", error: true ) end end |
#execute_scp ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/unimatrix_cli/citadel/instance/scp_command.rb', line 31 def execute_scp user_to_use = [ :user ] || user base = "scp -o StrictHostKeyChecking=no -i #{ key } " if [ :direction ] == 'to' command = base + "#{ @options[ :local_file ] } #{ user_to_use }@" + "#{ instance_details[ :dns ] }:#{ @options[ :remote_file ] }" else command = base + "#{ user_to_use }@#{ instance_details[ :dns ] }" + ":#{ @options[ :remote_file ] } #{ @options[ :local_file ] }" end exec command end |