abiquo-installer-tests 20120104 → 20121023.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +11 -7
- data/bin/abiquo-installer-tests +68 -43
- data/tests/1.8.5/abiquo_ciab.rb +21 -0
- data/tests/1.8.5/abiquo_kvm.rb +25 -0
- data/tests/1.8.5/abiquo_lvmiscsi.rb +17 -0
- data/tests/1.8.5/abiquo_monolithic.rb +12 -0
- data/tests/1.8.5/abiquo_nfs_repository.rb +23 -0
- data/tests/1.8.5/abiquo_platform.rb +39 -0
- data/tests/1.8.5/abiquo_remote_services.rb +115 -0
- data/tests/1.8.5/abiquo_server.rb +63 -0
- data/tests/1.8.5/abiquo_v2v.rb +37 -0
- data/tests/1.8.5/abiquo_vbox.rb +27 -0
- data/tests/1.8.5/abiquo_xen.rb +27 -0
- data/tests/2.0/abiquo_ciab.rb +9 -0
- data/tests/2.0/abiquo_community_hypervisor.rb +52 -0
- data/tests/2.0/abiquo_kvm.rb +5 -23
- data/tests/2.0/abiquo_monolithic.rb +12 -1
- data/tests/2.0/abiquo_platform.rb +2 -2
- data/tests/2.0/abiquo_remote_services.rb +15 -38
- data/tests/2.0/abiquo_server.rb +7 -1
- data/tests/2.0/abiquo_v2v.rb +42 -0
- data/tests/2.0/abiquo_vbox.rb +5 -25
- data/tests/2.0/abiquo_xen.rb +5 -25
- data/tests/2.2.0/abiquo_ciab.rb +30 -0
- data/tests/2.2.0/abiquo_community_hypervisor.rb +52 -0
- data/tests/2.2.0/abiquo_kvm.rb +7 -0
- data/tests/2.2.0/abiquo_lvmiscsi.rb +17 -0
- data/tests/2.2.0/abiquo_monolithic.rb +23 -0
- data/tests/2.2.0/abiquo_nfs_repository.rb +23 -0
- data/tests/2.2.0/abiquo_platform.rb +35 -0
- data/tests/2.2.0/abiquo_remote_services.rb +96 -0
- data/tests/2.2.0/abiquo_server.rb +95 -0
- data/tests/2.2.0/abiquo_v2v.rb +79 -0
- data/tests/2.2.0/abiquo_vbox.rb +7 -0
- data/tests/2.2.0/abiquo_xen.rb +7 -0
- data/tests/2.3.0/abiquo_ciab.rb +30 -0
- data/tests/2.3.0/abiquo_community_hypervisor.rb +52 -0
- data/tests/2.3.0/abiquo_kvm.rb +7 -0
- data/tests/2.3.0/abiquo_lvmiscsi.rb +17 -0
- data/tests/2.3.0/abiquo_monolithic.rb +23 -0
- data/tests/2.3.0/abiquo_nfs_repository.rb +23 -0
- data/tests/2.3.0/abiquo_platform.rb +35 -0
- data/tests/2.3.0/abiquo_remote_services.rb +96 -0
- data/tests/2.3.0/abiquo_server.rb +95 -0
- data/tests/2.3.0/abiquo_v2v.rb +79 -0
- data/tests/2.3.0/abiquo_vbox.rb +7 -0
- data/tests/2.3.0/abiquo_xen.rb +7 -0
- data/tests/abiquo_postinst_test.rb +12 -1
- data/vendor/net-scp-1.0.4/CHANGELOG.rdoc +29 -0
- data/vendor/net-scp-1.0.4/Manifest +17 -0
- data/vendor/net-scp-1.0.4/README.rdoc +98 -0
- data/vendor/net-scp-1.0.4/Rakefile +83 -0
- data/vendor/net-scp-1.0.4/lib/net/scp.rb +432 -0
- data/vendor/net-scp-1.0.4/lib/net/scp/download.rb +150 -0
- data/vendor/net-scp-1.0.4/lib/net/scp/errors.rb +5 -0
- data/vendor/net-scp-1.0.4/lib/net/scp/upload.rb +142 -0
- data/vendor/net-scp-1.0.4/lib/net/scp/version.rb +18 -0
- data/vendor/net-scp-1.0.4/lib/uri/open-scp.rb +18 -0
- data/vendor/net-scp-1.0.4/lib/uri/scp.rb +35 -0
- data/vendor/net-scp-1.0.4/net-scp.gemspec +34 -0
- data/vendor/net-scp-1.0.4/setup.rb +1331 -0
- data/vendor/net-scp-1.0.4/test/common.rb +153 -0
- data/vendor/net-scp-1.0.4/test/test_all.rb +3 -0
- data/vendor/net-scp-1.0.4/test/test_download.rb +170 -0
- data/vendor/net-scp-1.0.4/test/test_scp.rb +60 -0
- data/vendor/net-scp-1.0.4/test/test_upload.rb +269 -0
- data/vendor/net-sftp-2.0.5/CHANGELOG.rdoc +49 -0
- data/vendor/net-sftp-2.0.5/Manifest +55 -0
- data/vendor/net-sftp-2.0.5/README.rdoc +96 -0
- data/vendor/net-sftp-2.0.5/Rakefile +30 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp.rb +70 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/constants.rb +187 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/errors.rb +39 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/dir.rb +93 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/download.rb +364 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/file.rb +176 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/file_factory.rb +60 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/upload.rb +387 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/packet.rb +21 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol.rb +32 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/01/attributes.rb +315 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/01/base.rb +268 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/01/name.rb +43 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/02/base.rb +31 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/03/base.rb +35 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/04/attributes.rb +152 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/04/base.rb +94 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/04/name.rb +67 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/05/base.rb +66 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/06/attributes.rb +107 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/06/base.rb +63 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/base.rb +50 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/request.rb +91 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/response.rb +76 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/session.rb +952 -0
- data/vendor/net-sftp-2.0.5/lib/net/sftp/version.rb +18 -0
- data/vendor/net-sftp-2.0.5/net-sftp.gemspec +34 -0
- data/vendor/net-sftp-2.0.5/setup.rb +1331 -0
- data/vendor/net-sftp-2.0.5/test/common.rb +172 -0
- data/vendor/net-sftp-2.0.5/test/protocol/01/test_attributes.rb +97 -0
- data/vendor/net-sftp-2.0.5/test/protocol/01/test_base.rb +210 -0
- data/vendor/net-sftp-2.0.5/test/protocol/01/test_name.rb +27 -0
- data/vendor/net-sftp-2.0.5/test/protocol/02/test_base.rb +26 -0
- data/vendor/net-sftp-2.0.5/test/protocol/03/test_base.rb +27 -0
- data/vendor/net-sftp-2.0.5/test/protocol/04/test_attributes.rb +148 -0
- data/vendor/net-sftp-2.0.5/test/protocol/04/test_base.rb +74 -0
- data/vendor/net-sftp-2.0.5/test/protocol/04/test_name.rb +53 -0
- data/vendor/net-sftp-2.0.5/test/protocol/05/test_base.rb +62 -0
- data/vendor/net-sftp-2.0.5/test/protocol/06/test_attributes.rb +124 -0
- data/vendor/net-sftp-2.0.5/test/protocol/06/test_base.rb +51 -0
- data/vendor/net-sftp-2.0.5/test/protocol/test_base.rb +42 -0
- data/vendor/net-sftp-2.0.5/test/test_all.rb +7 -0
- data/vendor/net-sftp-2.0.5/test/test_dir.rb +47 -0
- data/vendor/net-sftp-2.0.5/test/test_download.rb +252 -0
- data/vendor/net-sftp-2.0.5/test/test_file.rb +159 -0
- data/vendor/net-sftp-2.0.5/test/test_file_factory.rb +48 -0
- data/vendor/net-sftp-2.0.5/test/test_packet.rb +9 -0
- data/vendor/net-sftp-2.0.5/test/test_protocol.rb +17 -0
- data/vendor/net-sftp-2.0.5/test/test_request.rb +71 -0
- data/vendor/net-sftp-2.0.5/test/test_response.rb +53 -0
- data/vendor/net-sftp-2.0.5/test/test_session.rb +741 -0
- data/vendor/net-sftp-2.0.5/test/test_upload.rb +219 -0
- data/vendor/net-ssh-2.5.2/CHANGELOG.rdoc +295 -0
- data/vendor/net-ssh-2.5.2/LICENSE.rdoc +19 -0
- data/vendor/net-ssh-2.5.2/Manifest +132 -0
- data/vendor/net-ssh-2.5.2/README.rdoc +184 -0
- data/vendor/net-ssh-2.5.2/Rakefile +88 -0
- data/vendor/net-ssh-2.5.2/Rudyfile +96 -0
- data/vendor/net-ssh-2.5.2/THANKS.rdoc +19 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh.rb +223 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/agent.rb +23 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/agent/java_pageant.rb +85 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/agent/socket.rb +170 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/constants.rb +18 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/key_manager.rb +253 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/abstract.rb +60 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/hostbased.rb +75 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/keyboard_interactive.rb +70 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/password.rb +43 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/publickey.rb +96 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/pageant.rb +264 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/session.rb +154 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/buffer.rb +350 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/buffered_io.rb +198 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/config.rb +207 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/channel.rb +630 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/constants.rb +33 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/session.rb +597 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/term.rb +178 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/errors.rb +88 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/key_factory.rb +107 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/known_hosts.rb +141 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/loggable.rb +61 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/packet.rb +102 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/prompt.rb +93 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/command.rb +75 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/errors.rb +14 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/http.rb +94 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/socks4.rb +70 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/socks5.rb +142 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/ruby_compat.rb +51 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/service/forward.rb +298 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test.rb +89 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/channel.rb +129 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/extensions.rb +152 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/kex.rb +44 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/local_packet.rb +51 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/packet.rb +81 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/remote_packet.rb +38 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/script.rb +157 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/test/socket.rb +64 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/algorithms.rb +407 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/cipher_factory.rb +106 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/constants.rb +32 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/ctr.rb +95 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac.rb +45 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/abstract.rb +79 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/md5.rb +12 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/none.rb +15 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/ripemd160.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha1.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_256.rb +15 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_256_96.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_512.rb +14 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_512_96.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/identity_cipher.rb +55 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex.rb +28 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +44 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +216 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +80 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +15 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +93 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +13 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/key_expander.rb +26 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/openssl.rb +237 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/packet_stream.rb +235 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/server_version.rb +71 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/session.rb +278 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/state.rb +206 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/verifiers/lenient.rb +30 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/verifiers/null.rb +12 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/verifiers/strict.rb +53 -0
- data/vendor/net-ssh-2.5.2/lib/net/ssh/version.rb +62 -0
- data/vendor/net-ssh-2.5.2/net-ssh.gemspec +172 -0
- data/vendor/net-ssh-2.5.2/setup.rb +1585 -0
- data/vendor/net-ssh-2.5.2/support/arcfour_check.rb +20 -0
- data/vendor/net-ssh-2.5.2/support/ssh_tunnel_bug.rb +65 -0
- data/vendor/net-ssh-2.5.2/test/README.txt +43 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/common.rb +28 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_abstract.rb +51 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_hostbased.rb +114 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_keyboard_interactive.rb +100 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_password.rb +52 -0
- data/vendor/net-ssh-2.5.2/test/authentication/methods/test_publickey.rb +148 -0
- data/vendor/net-ssh-2.5.2/test/authentication/test_agent.rb +205 -0
- data/vendor/net-ssh-2.5.2/test/authentication/test_key_manager.rb +218 -0
- data/vendor/net-ssh-2.5.2/test/authentication/test_session.rb +106 -0
- data/vendor/net-ssh-2.5.2/test/common.rb +107 -0
- data/vendor/net-ssh-2.5.2/test/configs/eqsign +3 -0
- data/vendor/net-ssh-2.5.2/test/configs/exact_match +8 -0
- data/vendor/net-ssh-2.5.2/test/configs/host_plus +10 -0
- data/vendor/net-ssh-2.5.2/test/configs/multihost +4 -0
- data/vendor/net-ssh-2.5.2/test/configs/nohost +19 -0
- data/vendor/net-ssh-2.5.2/test/configs/numeric_host +4 -0
- data/vendor/net-ssh-2.5.2/test/configs/wild_cards +14 -0
- data/vendor/net-ssh-2.5.2/test/connection/test_channel.rb +467 -0
- data/vendor/net-ssh-2.5.2/test/connection/test_session.rb +488 -0
- data/vendor/net-ssh-2.5.2/test/known_hosts/github +1 -0
- data/vendor/net-ssh-2.5.2/test/manual/test_forward.rb +223 -0
- data/vendor/net-ssh-2.5.2/test/start/test_transport.rb +28 -0
- data/vendor/net-ssh-2.5.2/test/test_all.rb +9 -0
- data/vendor/net-ssh-2.5.2/test/test_buffer.rb +426 -0
- data/vendor/net-ssh-2.5.2/test/test_buffered_io.rb +63 -0
- data/vendor/net-ssh-2.5.2/test/test_config.rb +120 -0
- data/vendor/net-ssh-2.5.2/test/test_key_factory.rb +121 -0
- data/vendor/net-ssh-2.5.2/test/test_known_hosts.rb +13 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_md5.rb +39 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_md5_96.rb +25 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_none.rb +34 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_ripemd160.rb +34 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha1.rb +34 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha1_96.rb +25 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_256.rb +35 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_256_96.rb +25 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_512.rb +35 -0
- data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_512_96.rb +25 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group14_sha1.rb +13 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +33 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_ecdh_sha2_nistp256.rb +161 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_ecdh_sha2_nistp384.rb +37 -0
- data/vendor/net-ssh-2.5.2/test/transport/kex/test_ecdh_sha2_nistp521.rb +37 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_algorithms.rb +330 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_cipher_factory.rb +441 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_hmac.rb +34 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_identity_cipher.rb +40 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_packet_stream.rb +1745 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_server_version.rb +78 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_session.rb +315 -0
- data/vendor/net-ssh-2.5.2/test/transport/test_state.rb +179 -0
- metadata +325 -78
@@ -10,8 +10,12 @@ class String
|
|
10
10
|
include Term::ANSIColor
|
11
11
|
end
|
12
12
|
|
13
|
-
class TestUtils
|
13
|
+
class TestUtils
|
14
14
|
|
15
|
+
#
|
16
|
+
# Should return an array of installer profiles
|
17
|
+
# otherwise the installation is broken
|
18
|
+
#
|
15
19
|
def self.installer_profiles
|
16
20
|
begin
|
17
21
|
buf = File.read '/etc/abiquo-installer'
|
@@ -22,6 +26,10 @@ class TestUtils
|
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
29
|
+
def self.find_abiquo_property(prop_name, prop_file = "/opt/abiquo/config/abiquo.properties")
|
30
|
+
File.read(prop_file).lines.find { |l| l.strip.chomp =~ /^#{prop_name}/ }
|
31
|
+
end
|
32
|
+
|
25
33
|
def self.service_on?(service)
|
26
34
|
ENV['LANG'] = 'POSIX'
|
27
35
|
`/sbin/chkconfig --list #{service}` =~ /3:on/
|
@@ -41,6 +49,7 @@ class TestUtils
|
|
41
49
|
return nil if not File.exist?('/etc/abiquo-release')
|
42
50
|
buf = File.read '/etc/abiquo-release'
|
43
51
|
buf =~ /Version:\s*(([0-9]|\.)+).*$/
|
52
|
+
puts buf
|
44
53
|
$1
|
45
54
|
end
|
46
55
|
|
@@ -97,6 +106,8 @@ else
|
|
97
106
|
end
|
98
107
|
|
99
108
|
puts "\n\n"
|
109
|
+
puts "Abiquo Version #{version.bold} detected"
|
110
|
+
puts
|
100
111
|
puts "Abiquo Installer Test Suite"
|
101
112
|
puts "---------------------------"
|
102
113
|
puts ""
|
@@ -0,0 +1,29 @@
|
|
1
|
+
=== 1.0.4 / 16 Sep 2010
|
2
|
+
|
3
|
+
* maintain filename sanitization compatibility with ruby 1.8.6 [Sung Pae, Tim Charper]
|
4
|
+
|
5
|
+
=== 1.0.3 / 17 Aug 2010
|
6
|
+
|
7
|
+
* replace :sanitize_file_name with a call to String#shellescape [Sung Pae]
|
8
|
+
* Added gemspec file and removed echoe dependency [Miron Cuperman, Delano Mandelbaum]
|
9
|
+
* Removed Hanna dependency in Rakefile [Delano Mandelbaum]
|
10
|
+
|
11
|
+
|
12
|
+
=== 1.0.2 / 4 Feb 2009
|
13
|
+
|
14
|
+
* Escape spaces in file names on remote server [Jamis Buck]
|
15
|
+
|
16
|
+
|
17
|
+
=== 1.0.1 / 29 May 2008
|
18
|
+
|
19
|
+
* Make sure downloads open the file in binary mode to appease Windows [Jamis Buck]
|
20
|
+
|
21
|
+
|
22
|
+
=== 1.0.0 / 1 May 2008
|
23
|
+
|
24
|
+
* Pass the channel object as the first argument to the progress callback [Jamis Buck]
|
25
|
+
|
26
|
+
|
27
|
+
=== 1.0 Preview Release 1 (0.99.0) / 22 Mar 2008
|
28
|
+
|
29
|
+
* Birthday!
|
@@ -0,0 +1,17 @@
|
|
1
|
+
CHANGELOG.rdoc
|
2
|
+
lib/net/scp/download.rb
|
3
|
+
lib/net/scp/errors.rb
|
4
|
+
lib/net/scp/upload.rb
|
5
|
+
lib/net/scp/version.rb
|
6
|
+
lib/net/scp.rb
|
7
|
+
lib/uri/open-scp.rb
|
8
|
+
lib/uri/scp.rb
|
9
|
+
Rakefile
|
10
|
+
README.rdoc
|
11
|
+
setup.rb
|
12
|
+
test/common.rb
|
13
|
+
test/test_all.rb
|
14
|
+
test/test_download.rb
|
15
|
+
test/test_scp.rb
|
16
|
+
test/test_upload.rb
|
17
|
+
Manifest
|
@@ -0,0 +1,98 @@
|
|
1
|
+
= Net::SCP
|
2
|
+
|
3
|
+
* http://github.com/net-ssh/net-scp
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Net::SCP is a pure-Ruby implementation of the SCP protocol. This operates over SSH (and requires the Net::SSH library), and allows files and directory trees to copied to and from a remote server.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Transfer files or entire directory trees to or from a remote host via SCP
|
12
|
+
* Can preserve file attributes across transfers
|
13
|
+
* Can download files in-memory, or direct-to-disk
|
14
|
+
* Support for SCP URI's, and OpenURI
|
15
|
+
|
16
|
+
== SYNOPSIS:
|
17
|
+
|
18
|
+
In a nutshell:
|
19
|
+
|
20
|
+
require 'net/scp'
|
21
|
+
|
22
|
+
# upload a file to a remote server
|
23
|
+
Net::SCP.upload!("remote.host.com", "username",
|
24
|
+
"/local/path", "/remote/path",
|
25
|
+
:password => "password")
|
26
|
+
|
27
|
+
# download a file from a remote server
|
28
|
+
Net::SCP.download!("remote.host.com", "username",
|
29
|
+
"/remote/path", "/local/path",
|
30
|
+
:password => password)
|
31
|
+
|
32
|
+
# download a file to an in-memory buffer
|
33
|
+
data = Net::SCP::download!("remote.host.com", "username", "/remote/path")
|
34
|
+
|
35
|
+
# use a persistent connection to transfer files
|
36
|
+
Net::SCP.start("remote.host.com", "username", :password => "password") do |scp|
|
37
|
+
# upload a file to a remote server
|
38
|
+
scp.upload! "/local/path", "/remote/path"
|
39
|
+
|
40
|
+
# upload from an in-memory buffer
|
41
|
+
scp.upload! StringIO.new("some data to upload"), "/remote/path"
|
42
|
+
|
43
|
+
# run multiple downloads in parallel
|
44
|
+
d1 = scp.download("/remote/path", "/local/path")
|
45
|
+
d2 = scp.download("/remote/path2", "/local/path2")
|
46
|
+
[d1, d2].each { |d| d.wait }
|
47
|
+
end
|
48
|
+
|
49
|
+
# You can also use open-uri to grab data via scp:
|
50
|
+
require 'uri/open-scp'
|
51
|
+
data = open("scp://user@host/path/to/file.txt").read
|
52
|
+
|
53
|
+
For more information, see Net::SCP.
|
54
|
+
|
55
|
+
== REQUIREMENTS:
|
56
|
+
|
57
|
+
* Net::SSH 2
|
58
|
+
|
59
|
+
If you wish to run the tests, you'll also need:
|
60
|
+
|
61
|
+
* Echoe (for Rakefile use)
|
62
|
+
* Mocha (for tests)
|
63
|
+
|
64
|
+
== INSTALL:
|
65
|
+
|
66
|
+
* gem install net-scp (might need sudo privileges)
|
67
|
+
|
68
|
+
Or, you can do it the hard way (without Rubygems):
|
69
|
+
|
70
|
+
* tar xzf net-scp-*.tgz
|
71
|
+
* cd net-scp-*
|
72
|
+
* ruby setup.rb config
|
73
|
+
* ruby setup.rb install (might need sudo privileges)
|
74
|
+
|
75
|
+
== LICENSE:
|
76
|
+
|
77
|
+
(The MIT License)
|
78
|
+
|
79
|
+
Copyright (c) 2008 Jamis Buck <jamis@37signals.com>
|
80
|
+
|
81
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
82
|
+
a copy of this software and associated documentation files (the
|
83
|
+
'Software'), to deal in the Software without restriction, including
|
84
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
85
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
86
|
+
permit persons to whom the Software is furnished to do so, subject to
|
87
|
+
the following conditions:
|
88
|
+
|
89
|
+
The above copyright notice and this permission notice shall be
|
90
|
+
included in all copies or substantial portions of the Software.
|
91
|
+
|
92
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
93
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
94
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
95
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
96
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
97
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
98
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'fileutils'
|
5
|
+
include FileUtils
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'hanna/rdoctask'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :package
|
14
|
+
|
15
|
+
# CONFIG =============================================================
|
16
|
+
|
17
|
+
# Change the following according to your needs
|
18
|
+
README = "README.rdoc"
|
19
|
+
CHANGES = "CHANGELOG.rdoc"
|
20
|
+
|
21
|
+
# Files and directories to be deleted when you run "rake clean"
|
22
|
+
CLEAN.include [ 'pkg', '*.gem', '.config', 'doc']
|
23
|
+
|
24
|
+
name = 'net-scp'
|
25
|
+
|
26
|
+
load "#{name}.gemspec"
|
27
|
+
version = @spec.version
|
28
|
+
|
29
|
+
# That's it! The following defaults should allow you to get started
|
30
|
+
# on other things.
|
31
|
+
|
32
|
+
|
33
|
+
# TESTS/SPECS =========================================================
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# INSTALL =============================================================
|
38
|
+
|
39
|
+
Rake::GemPackageTask.new(@spec) do |p|
|
40
|
+
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
41
|
+
end
|
42
|
+
|
43
|
+
task :release => [ :rdoc, :package ]
|
44
|
+
task :build => [ :package ]
|
45
|
+
task :install => [ :rdoc, :package ] do
|
46
|
+
sh %{sudo gem install pkg/#{name}-#{version}.gem}
|
47
|
+
end
|
48
|
+
task :uninstall => [ :clean ] do
|
49
|
+
sh %{sudo gem uninstall #{name}}
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
# RUBYFORGE RELEASE / PUBLISH TASKS ==================================
|
54
|
+
|
55
|
+
if @spec.rubyforge_project
|
56
|
+
desc 'Publish website to rubyforge'
|
57
|
+
task 'publish:rdoc' => 'doc/index.html' do
|
58
|
+
sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/ssh/v2/api/"
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'Public release to rubyforge'
|
62
|
+
task 'publish:gem' => [:package] do |t|
|
63
|
+
sh <<-end
|
64
|
+
rubyforge add_release -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
|
65
|
+
rubyforge add_file -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
# RUBY DOCS TASK ==================================
|
73
|
+
|
74
|
+
Rake::RDocTask.new do |t|
|
75
|
+
t.rdoc_dir = 'doc'
|
76
|
+
t.title = @spec.summary
|
77
|
+
t.options << '--line-numbers' << '-A cattr_accessor=object'
|
78
|
+
t.options << '--charset' << 'utf-8'
|
79
|
+
t.rdoc_files.include(README)
|
80
|
+
t.rdoc_files.include(CHANGES)
|
81
|
+
t.rdoc_files.include('lib/**/*.rb')
|
82
|
+
end
|
83
|
+
|
@@ -0,0 +1,432 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
require 'shellwords'
|
3
|
+
|
4
|
+
require 'net/ssh'
|
5
|
+
require 'net/scp/errors'
|
6
|
+
require 'net/scp/upload'
|
7
|
+
require 'net/scp/download'
|
8
|
+
|
9
|
+
module Net
|
10
|
+
|
11
|
+
# Net::SCP implements the SCP (Secure CoPy) client protocol, allowing Ruby
|
12
|
+
# programs to securely and programmatically transfer individual files or
|
13
|
+
# entire directory trees to and from remote servers. It provides support for
|
14
|
+
# multiple simultaneous SCP copies working in parallel over the same
|
15
|
+
# connection, as well as for synchronous, serial copies.
|
16
|
+
#
|
17
|
+
# Basic usage:
|
18
|
+
#
|
19
|
+
# require 'net/scp'
|
20
|
+
#
|
21
|
+
# Net::SCP.start("remote.host", "username", :password => "passwd") do |scp|
|
22
|
+
# # synchronous (blocking) upload; call blocks until upload completes
|
23
|
+
# scp.upload! "/local/path", "/remote/path"
|
24
|
+
#
|
25
|
+
# # asynchronous upload; call returns immediately and requires SSH
|
26
|
+
# # event loop to run
|
27
|
+
# channel = scp.upload("/local/path", "/remote/path")
|
28
|
+
# channel.wait
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# Net::SCP also provides an open-uri tie-in, so you can use the Kernel#open
|
32
|
+
# method to open and read a remote file:
|
33
|
+
#
|
34
|
+
# # if you just want to parse SCP URL's:
|
35
|
+
# require 'uri/scp'
|
36
|
+
# url = URI.parse("scp://user@remote.host/path/to/file")
|
37
|
+
#
|
38
|
+
# # if you want to read from a URL voa SCP:
|
39
|
+
# require 'uri/open-scp'
|
40
|
+
# puts open("scp://user@remote.host/path/to/file").read
|
41
|
+
#
|
42
|
+
# Lastly, Net::SCP adds a method to the Net::SSH::Connection::Session class,
|
43
|
+
# allowing you to easily grab a Net::SCP reference from an existing Net::SSH
|
44
|
+
# session:
|
45
|
+
#
|
46
|
+
# require 'net/ssh'
|
47
|
+
# require 'net/scp'
|
48
|
+
#
|
49
|
+
# Net::SSH.start("remote.host", "username", :password => "passwd") do |ssh|
|
50
|
+
# ssh.scp.download! "/remote/path", "/local/path"
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# == Progress Reporting
|
54
|
+
#
|
55
|
+
# By default, uploading and downloading proceed silently, without any
|
56
|
+
# outword indication of their progress. For long running uploads or downloads
|
57
|
+
# (and especially in interactive environments) it is desirable to report
|
58
|
+
# to the user the progress of the current operation.
|
59
|
+
#
|
60
|
+
# To receive progress reports for the current operation, just pass a block
|
61
|
+
# to #upload or #download (or one of their variants):
|
62
|
+
#
|
63
|
+
# scp.upload!("/path/to/local", "/path/to/remote") do |ch, name, sent, total|
|
64
|
+
# puts "#{name}: #{sent}/#{total}"
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# Whenever a new chunk of data is recieved for or sent to a file, the callback
|
68
|
+
# will be invoked, indicating the name of the file (local for downloads,
|
69
|
+
# remote for uploads), the number of bytes that have been sent or received
|
70
|
+
# so far for the file, and the size of the file.
|
71
|
+
#
|
72
|
+
#--
|
73
|
+
# = Protocol Description
|
74
|
+
#
|
75
|
+
# Although this information has zero relevance to consumers of the Net::SCP
|
76
|
+
# library, I'm documenting it here so that anyone else looking for documentation
|
77
|
+
# of the SCP protocol won't be left high-and-dry like I was. The following is
|
78
|
+
# reversed engineered from the OpenSSH SCP implementation, and so may
|
79
|
+
# contain errors. You have been warned!
|
80
|
+
#
|
81
|
+
# The first step is to invoke the "scp" command on the server. It accepts
|
82
|
+
# the following parameters, which must be set correctly to avoid errors:
|
83
|
+
#
|
84
|
+
# * "-t" -- tells the remote scp process that data will be sent "to" it,
|
85
|
+
# e.g., that data will be uploaded and it should initialize itself
|
86
|
+
# accordingly.
|
87
|
+
# * "-f" -- tells the remote scp process that data should come "from" it,
|
88
|
+
# e.g., that data will be downloaded and it should initialize itself
|
89
|
+
# accordingly.
|
90
|
+
# * "-v" -- verbose mode; the remote scp process should chatter about what
|
91
|
+
# it is doing via stderr.
|
92
|
+
# * "-p" -- preserve timestamps. 'T' directives (see below) should be/will
|
93
|
+
# be sent to indicate the modification and access times of each file.
|
94
|
+
# * "-r" -- recursive transfers should be allowed. Without this, it is an
|
95
|
+
# error to upload or download a directory.
|
96
|
+
#
|
97
|
+
# After those flags, the name of the remote file/directory should be passed
|
98
|
+
# as the sole non-switch argument to scp.
|
99
|
+
#
|
100
|
+
# Then the fun begins. If you're doing a download, enter the download_start_state.
|
101
|
+
# Otherwise, look for upload_start_state.
|
102
|
+
#
|
103
|
+
# == Net::SCP::Download#download_start_state
|
104
|
+
#
|
105
|
+
# This is the start state for downloads. It simply sends a 0-byte to the
|
106
|
+
# server. The next state is Net::SCP::Download#read_directive_state.
|
107
|
+
#
|
108
|
+
# == Net::SCP::Upload#upload_start_state
|
109
|
+
#
|
110
|
+
# Sets up the initial upload scaffolding and waits for a 0-byte from the
|
111
|
+
# server, and then switches to Net::SCP::Upload#upload_current_state.
|
112
|
+
#
|
113
|
+
# == Net::SCP::Download#read_directive_state
|
114
|
+
#
|
115
|
+
# Reads a directive line from the input. The following directives are
|
116
|
+
# recognized:
|
117
|
+
#
|
118
|
+
# * T%d %d %d %d -- a "times" packet. Indicates that the next file to be
|
119
|
+
# downloaded must have mtime/usec/atime/usec attributes preserved.
|
120
|
+
# * D%o %d %s -- a directory change. The process is changing to a directory
|
121
|
+
# with the given permissions/size/name, and the recipient should create
|
122
|
+
# a directory with the same name and permissions. Subsequent files and
|
123
|
+
# directories will be children of this directory, until a matching 'E'
|
124
|
+
# directive.
|
125
|
+
# * C%o %d %s -- a file is being sent next. The file will have the given
|
126
|
+
# permissions/size/name. Immediately following this line, +size+ bytes
|
127
|
+
# will be sent, raw.
|
128
|
+
# * E -- terminator directive. Indicates the end of a directory, and subsequent
|
129
|
+
# files and directories should be received by the parent of the current
|
130
|
+
# directory.
|
131
|
+
#
|
132
|
+
# If a 'C' directive is received, we switch over to
|
133
|
+
# Net::SCP::Download#read_data_state. If an 'E' directive is received, and
|
134
|
+
# there is no parent directory, we switch over to Net::SCP#finish_state.
|
135
|
+
#
|
136
|
+
# Regardless of what the next state is, we send a 0-byte to the server
|
137
|
+
# before moving to the next state.
|
138
|
+
#
|
139
|
+
# == Net::SCP::Download#read_data_state
|
140
|
+
#
|
141
|
+
# Bytes are read to satisfy the size of the incoming file. When all pending
|
142
|
+
# data has been read, we wait for the server to send a 0-byte, and then we
|
143
|
+
# switch to the Net::SCP::Download#finish_read_state.
|
144
|
+
#
|
145
|
+
# == Net::SCP::Download#finish_read_state
|
146
|
+
#
|
147
|
+
# We sent a 0-byte to the server to indicate that the file was successfully
|
148
|
+
# received. If there is no parent directory, then we're downloading a single
|
149
|
+
# file and we switch to Net::SCP#finish_state. Otherwise we jump back to the
|
150
|
+
# Net::SCP::Download#read_directive state to see what we get to download next.
|
151
|
+
#
|
152
|
+
# == Net::SCP::Upload#upload_current_state
|
153
|
+
#
|
154
|
+
# If the current item is a file, send a file. Sending a file starts with a
|
155
|
+
# 'T' directive (if :preserve is true), then a wait for the server to respond,
|
156
|
+
# and then a 'C' directive, and then a wait for the server to respond, and
|
157
|
+
# then a jump to Net::SCP::Upload#send_data_state.
|
158
|
+
#
|
159
|
+
# If current item is a directory, send a 'D' directive, and wait for the
|
160
|
+
# server to respond with a 0-byte. Then jump to Net::SCP::Upload#next_item_state.
|
161
|
+
#
|
162
|
+
# == Net::SCP::Upload#send_data_state
|
163
|
+
#
|
164
|
+
# Reads and sends the next chunk of data to the server. The state machine
|
165
|
+
# remains in this state until all data has been sent, at which point we
|
166
|
+
# send a 0-byte to the server, and wait for the server to respond with a
|
167
|
+
# 0-byte of its own. Then we jump back to Net::SCP::Upload#next_item_state.
|
168
|
+
#
|
169
|
+
# == Net::SCP::Upload#next_item_state
|
170
|
+
#
|
171
|
+
# If there is nothing left to upload, and there is no parent directory,
|
172
|
+
# jump to Net::SCP#finish_state.
|
173
|
+
#
|
174
|
+
# If there is nothing left to upload from the current directory, send an
|
175
|
+
# 'E' directive and wait for the server to respond with a 0-byte. Then go
|
176
|
+
# to Net::SCP::Upload#next_item_state.
|
177
|
+
#
|
178
|
+
# Otherwise, set the current upload source and go to
|
179
|
+
# Net::SCP::Upload#upload_current_state.
|
180
|
+
#
|
181
|
+
# == Net::SCP#finish_state
|
182
|
+
#
|
183
|
+
# Tells the server that no more data is forthcoming from this end of the
|
184
|
+
# pipe (via Net::SSH::Connection::Channel#eof!) and leaves the pipe to drain.
|
185
|
+
# It will be terminated when the remote process closes with an exit status
|
186
|
+
# of zero.
|
187
|
+
#++
|
188
|
+
class SCP
|
189
|
+
include Net::SSH::Loggable
|
190
|
+
include Upload, Download
|
191
|
+
|
192
|
+
# Starts up a new SSH connection and instantiates a new SCP session on
|
193
|
+
# top of it. If a block is given, the SCP session is yielded, and the
|
194
|
+
# SSH session is closed automatically when the block terminates. If no
|
195
|
+
# block is given, the SCP session is returned.
|
196
|
+
def self.start(host, username, options={})
|
197
|
+
session = Net::SSH.start(host, username, options)
|
198
|
+
scp = new(session)
|
199
|
+
|
200
|
+
if block_given?
|
201
|
+
begin
|
202
|
+
yield scp
|
203
|
+
session.loop
|
204
|
+
ensure
|
205
|
+
session.close
|
206
|
+
end
|
207
|
+
else
|
208
|
+
return scp
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# Starts up a new SSH connection using the +host+ and +username+ parameters,
|
213
|
+
# instantiates a new SCP session on top of it, and then begins an
|
214
|
+
# upload from +local+ to +remote+. If the +options+ hash includes an
|
215
|
+
# :ssh key, the value for that will be passed to the SSH connection as
|
216
|
+
# options (e.g., to set the password, etc.). All other options are passed
|
217
|
+
# to the #upload! method. If a block is given, it will be used to report
|
218
|
+
# progress (see "Progress Reporting", under Net::SCP).
|
219
|
+
def self.upload!(host, username, local, remote, options={}, &progress)
|
220
|
+
options = options.dup
|
221
|
+
start(host, username, options.delete(:ssh) || {}) do |scp|
|
222
|
+
scp.upload!(local, remote, options, &progress)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
# Starts up a new SSH connection using the +host+ and +username+ parameters,
|
227
|
+
# instantiates a new SCP session on top of it, and then begins a
|
228
|
+
# download from +remote+ to +local+. If the +options+ hash includes an
|
229
|
+
# :ssh key, the value for that will be passed to the SSH connection as
|
230
|
+
# options (e.g., to set the password, etc.). All other options are passed
|
231
|
+
# to the #download! method. If a block is given, it will be used to report
|
232
|
+
# progress (see "Progress Reporting", under Net::SCP).
|
233
|
+
def self.download!(host, username, remote, local=nil, options={}, &progress)
|
234
|
+
options = options.dup
|
235
|
+
start(host, username, options.delete(:ssh) || {}) do |scp|
|
236
|
+
return scp.download!(remote, local, options, &progress)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
# The underlying Net::SSH session that acts as transport for the SCP
|
241
|
+
# packets.
|
242
|
+
attr_reader :session
|
243
|
+
|
244
|
+
# Creates a new Net::SCP session on top of the given Net::SSH +session+
|
245
|
+
# object.
|
246
|
+
def initialize(session)
|
247
|
+
@session = session
|
248
|
+
self.logger = session.logger
|
249
|
+
end
|
250
|
+
|
251
|
+
# Inititiate a synchronous (non-blocking) upload from +local+ to +remote+.
|
252
|
+
# The following options are recognized:
|
253
|
+
#
|
254
|
+
# * :recursive - the +local+ parameter refers to a local directory, which
|
255
|
+
# should be uploaded to a new directory named +remote+ on the remote
|
256
|
+
# server.
|
257
|
+
# * :preserve - the atime and mtime of the file should be preserved.
|
258
|
+
# * :verbose - the process should result in verbose output on the server
|
259
|
+
# end (useful for debugging).
|
260
|
+
# * :chunk_size - the size of each "chunk" that should be sent. Defaults
|
261
|
+
# to 2048. Changing this value may improve throughput at the expense
|
262
|
+
# of decreasing interactivity.
|
263
|
+
#
|
264
|
+
# This method will return immediately, returning the Net::SSH::Connection::Channel
|
265
|
+
# object that will support the upload. To wait for the upload to finish,
|
266
|
+
# you can either call the #wait method on the channel, or otherwise run
|
267
|
+
# the Net::SSH event loop until the channel's #active? method returns false.
|
268
|
+
#
|
269
|
+
# channel = scp.upload("/local/path", "/remote/path")
|
270
|
+
# channel.wait
|
271
|
+
def upload(local, remote, options={}, &progress)
|
272
|
+
start_command(:upload, local, remote, options, &progress)
|
273
|
+
end
|
274
|
+
|
275
|
+
# Same as #upload, but blocks until the upload finishes. Identical to
|
276
|
+
# calling #upload and then calling the #wait method on the channel object
|
277
|
+
# that is returned. The return value is not defined.
|
278
|
+
def upload!(local, remote, options={}, &progress)
|
279
|
+
upload(local, remote, options, &progress).wait
|
280
|
+
end
|
281
|
+
|
282
|
+
# Inititiate a synchronous (non-blocking) download from +remote+ to +local+.
|
283
|
+
# The following options are recognized:
|
284
|
+
#
|
285
|
+
# * :recursive - the +remote+ parameter refers to a remote directory, which
|
286
|
+
# should be downloaded to a new directory named +local+ on the local
|
287
|
+
# machine.
|
288
|
+
# * :preserve - the atime and mtime of the file should be preserved.
|
289
|
+
# * :verbose - the process should result in verbose output on the server
|
290
|
+
# end (useful for debugging).
|
291
|
+
#
|
292
|
+
# This method will return immediately, returning the Net::SSH::Connection::Channel
|
293
|
+
# object that will support the download. To wait for the download to finish,
|
294
|
+
# you can either call the #wait method on the channel, or otherwise run
|
295
|
+
# the Net::SSH event loop until the channel's #active? method returns false.
|
296
|
+
#
|
297
|
+
# channel = scp.download("/remote/path", "/local/path")
|
298
|
+
# channel.wait
|
299
|
+
def download(remote, local, options={}, &progress)
|
300
|
+
start_command(:download, local, remote, options, &progress)
|
301
|
+
end
|
302
|
+
|
303
|
+
# Same as #download, but blocks until the download finishes. Identical to
|
304
|
+
# calling #download and then calling the #wait method on the channel
|
305
|
+
# object that is returned.
|
306
|
+
#
|
307
|
+
# scp.download!("/remote/path", "/local/path")
|
308
|
+
#
|
309
|
+
# If +local+ is nil, and the download is not recursive (e.g., it is downloading
|
310
|
+
# only a single file), the file will be downloaded to an in-memory buffer
|
311
|
+
# and the resulting string returned.
|
312
|
+
#
|
313
|
+
# data = download!("/remote/path")
|
314
|
+
def download!(remote, local=nil, options={}, &progress)
|
315
|
+
destination = local ? local : StringIO.new
|
316
|
+
download(remote, destination, options, &progress).wait
|
317
|
+
local ? true : destination.string
|
318
|
+
end
|
319
|
+
|
320
|
+
private
|
321
|
+
|
322
|
+
# Constructs the scp command line needed to initiate and SCP session
|
323
|
+
# for the given +mode+ (:upload or :download) and with the given options
|
324
|
+
# (:verbose, :recursive, :preserve). Returns the command-line as a
|
325
|
+
# string, ready to execute.
|
326
|
+
def scp_command(mode, options)
|
327
|
+
command = "scp "
|
328
|
+
command << (mode == :upload ? "-t" : "-f")
|
329
|
+
command << " -v" if options[:verbose]
|
330
|
+
command << " -r" if options[:recursive]
|
331
|
+
command << " -p" if options[:preserve]
|
332
|
+
command
|
333
|
+
end
|
334
|
+
|
335
|
+
# Opens a new SSH channel and executes the necessary SCP command over
|
336
|
+
# it (see #scp_command). It then sets up the necessary callbacks, and
|
337
|
+
# sets up a state machine to use to process the upload or download.
|
338
|
+
# (See Net::SCP::Upload and Net::SCP::Download).
|
339
|
+
def start_command(mode, local, remote, options={}, &callback)
|
340
|
+
session.open_channel do |channel|
|
341
|
+
command = "#{scp_command(mode, options)} #{shellescape remote}"
|
342
|
+
channel.exec(command) do |ch, success|
|
343
|
+
if success
|
344
|
+
channel[:local ] = local
|
345
|
+
channel[:remote ] = remote
|
346
|
+
channel[:options ] = options.dup
|
347
|
+
channel[:callback] = callback
|
348
|
+
channel[:buffer ] = Net::SSH::Buffer.new
|
349
|
+
channel[:state ] = "#{mode}_start"
|
350
|
+
channel[:stack ] = []
|
351
|
+
|
352
|
+
channel.on_close { |ch| raise Net::SCP::Error, "SCP did not finish successfully (#{ch[:exit]})" if ch[:exit] != 0 }
|
353
|
+
channel.on_data { |ch, data| channel[:buffer].append(data) }
|
354
|
+
channel.on_extended_data { |ch, type, data| debug { data.chomp } }
|
355
|
+
channel.on_request("exit-status") { |ch, data| channel[:exit] = data.read_long }
|
356
|
+
channel.on_process { send("#{channel[:state]}_state", channel) }
|
357
|
+
else
|
358
|
+
channel.close
|
359
|
+
raise Net::SCP::Error, "could not exec scp on the remote host"
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
# Causes the state machine to enter the "await response" state, where
|
366
|
+
# things just pause until the server replies with a 0 (see
|
367
|
+
# #await_response_state), at which point the state machine will pick up
|
368
|
+
# at +next_state+ and continue processing.
|
369
|
+
def await_response(channel, next_state)
|
370
|
+
channel[:state] = :await_response
|
371
|
+
channel[:next ] = next_state.to_sym
|
372
|
+
# check right away, to see if the response is immediately available
|
373
|
+
await_response_state(channel)
|
374
|
+
end
|
375
|
+
|
376
|
+
# The action invoked while the state machine remains in the "await
|
377
|
+
# response" state. As long as there is no data ready to process, the
|
378
|
+
# machine will remain in this state. As soon as the server replies with
|
379
|
+
# an integer 0 as the only byte, the state machine is kicked into the
|
380
|
+
# next state (see +await_response+). If the response is not a 0, an
|
381
|
+
# exception is raised.
|
382
|
+
def await_response_state(channel)
|
383
|
+
return if channel[:buffer].available == 0
|
384
|
+
c = channel[:buffer].read_byte
|
385
|
+
raise "#{c.chr}#{channel[:buffer].read}" if c != 0
|
386
|
+
channel[:next], channel[:state] = nil, channel[:next]
|
387
|
+
send("#{channel[:state]}_state", channel)
|
388
|
+
end
|
389
|
+
|
390
|
+
# The action invoked when the state machine is in the "finish" state.
|
391
|
+
# It just tells the server not to expect any more data from this end
|
392
|
+
# of the pipe, and allows the pipe to drain until the server closes it.
|
393
|
+
def finish_state(channel)
|
394
|
+
channel.eof!
|
395
|
+
end
|
396
|
+
|
397
|
+
# Invoked to report progress back to the client. If a callback was not
|
398
|
+
# set, this does nothing.
|
399
|
+
def progress_callback(channel, name, sent, total)
|
400
|
+
channel[:callback].call(channel, name, sent, total) if channel[:callback]
|
401
|
+
end
|
402
|
+
|
403
|
+
# Imported from ruby 1.9.2 shellwords.rb
|
404
|
+
def shellescape(str)
|
405
|
+
# ruby 1.8.7+ implements String#shellescape
|
406
|
+
return str.shellescape if str.respond_to? :shellescape
|
407
|
+
|
408
|
+
# An empty argument will be skipped, so return empty quotes.
|
409
|
+
return "''" if str.empty?
|
410
|
+
|
411
|
+
str = str.dup
|
412
|
+
|
413
|
+
# Process as a single byte sequence because not all shell
|
414
|
+
# implementations are multibyte aware.
|
415
|
+
str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
|
416
|
+
|
417
|
+
# A LF cannot be escaped with a backslash because a backslash + LF
|
418
|
+
# combo is regarded as line continuation and simply ignored.
|
419
|
+
str.gsub!(/\n/, "'\n'")
|
420
|
+
|
421
|
+
return str
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
class Net::SSH::Connection::Session
|
427
|
+
# Provides a convenient way to initialize a SCP session given a Net::SSH
|
428
|
+
# session. Returns the Net::SCP instance, ready to use.
|
429
|
+
def scp
|
430
|
+
@scp ||= Net::SCP.new(self)
|
431
|
+
end
|
432
|
+
end
|