cifrado 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +18 -0
- data/CHANGELOG.md +44 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +247 -0
- data/RELEASE.md +10 -0
- data/Rakefile +21 -0
- data/TODO.md +6 -0
- data/bin/cifrado +7 -0
- data/cifrado.gemspec +31 -0
- data/gem-public_cert.pem +20 -0
- data/lib/cifrado.rb +48 -0
- data/lib/cifrado/cli.rb +140 -0
- data/lib/cifrado/cli/cinema.rb +81 -0
- data/lib/cifrado/cli/delete.rb +36 -0
- data/lib/cifrado/cli/download.rb +54 -0
- data/lib/cifrado/cli/jukebox.rb +94 -0
- data/lib/cifrado/cli/list.rb +64 -0
- data/lib/cifrado/cli/post.rb +10 -0
- data/lib/cifrado/cli/progressbar.rb +86 -0
- data/lib/cifrado/cli/saio.rb +11 -0
- data/lib/cifrado/cli/saio/base.rb +20 -0
- data/lib/cifrado/cli/saio/bootstrap.rb +118 -0
- data/lib/cifrado/cli/saio/destroy.rb +16 -0
- data/lib/cifrado/cli/saio/scripts/saio.sh.erb +445 -0
- data/lib/cifrado/cli/set_acl.rb +10 -0
- data/lib/cifrado/cli/setup.rb +64 -0
- data/lib/cifrado/cli/stat.rb +41 -0
- data/lib/cifrado/cli/upload.rb +269 -0
- data/lib/cifrado/config.rb +18 -0
- data/lib/cifrado/core_ext/ruby18_base64.rb +15 -0
- data/lib/cifrado/crypto_services.rb +218 -0
- data/lib/cifrado/file_splitter.rb +67 -0
- data/lib/cifrado/rate_limit.rb +23 -0
- data/lib/cifrado/streaming_downloader.rb +49 -0
- data/lib/cifrado/streaming_uploader.rb +57 -0
- data/lib/cifrado/swift_client.rb +313 -0
- data/lib/cifrado/utils.rb +59 -0
- data/lib/cifrado/version.rb +3 -0
- data/tests/cli/list_tests.rb +28 -0
- data/tests/cli/upload_multi_tests.rb +94 -0
- data/tests/cli/upload_tests.rb +167 -0
- data/tests/cli_tests.rb +2 -0
- data/tests/crypto_services_tests.rb +145 -0
- data/tests/file_splitter_tests.rb +61 -0
- data/tests/helper.rb +117 -0
- data/tests/swift_client/create_directory.rb +14 -0
- data/tests/swift_client/download_tests.rb +208 -0
- data/tests/swift_client/file_available.rb +25 -0
- data/tests/swift_client/head_tests.rb +34 -0
- data/tests/swift_client/match_tests.rb +29 -0
- data/tests/swift_client/upload_tests.rb +70 -0
- data/tests/swift_client_tests.rb +29 -0
- data/tests/utils_tests.rb +33 -0
- data/vendor/fog/.document +3 -0
- data/vendor/fog/.gitignore +23 -0
- data/vendor/fog/.irbrc +82 -0
- data/vendor/fog/.travis.yml +21 -0
- data/vendor/fog/README.cifrado +3 -0
- data/vendor/fog/README.md +156 -0
- data/vendor/fog/RELEASE.md +39 -0
- data/vendor/fog/changelog.txt +4156 -0
- data/vendor/fog/fog.gemspec +70 -0
- data/vendor/fog/lib/fog.rb +17 -0
- data/vendor/fog/lib/fog/cdn.rb +30 -0
- data/vendor/fog/lib/fog/compute.rb +127 -0
- data/vendor/fog/lib/fog/compute/models/server.rb +73 -0
- data/vendor/fog/lib/fog/core.rb +38 -0
- data/vendor/fog/lib/fog/core/attributes.rb +221 -0
- data/vendor/fog/lib/fog/core/collection.rb +145 -0
- data/vendor/fog/lib/fog/core/connection.rb +36 -0
- data/vendor/fog/lib/fog/core/credentials.rb +65 -0
- data/vendor/fog/lib/fog/core/current_machine.rb +34 -0
- data/vendor/fog/lib/fog/core/deprecated_connection_accessors.rb +41 -0
- data/vendor/fog/lib/fog/core/deprecation.rb +23 -0
- data/vendor/fog/lib/fog/core/errors.rb +108 -0
- data/vendor/fog/lib/fog/core/hmac.rb +48 -0
- data/vendor/fog/lib/fog/core/json.rb +34 -0
- data/vendor/fog/lib/fog/core/logger.rb +45 -0
- data/vendor/fog/lib/fog/core/mock.rb +92 -0
- data/vendor/fog/lib/fog/core/model.rb +79 -0
- data/vendor/fog/lib/fog/core/parser.rb +116 -0
- data/vendor/fog/lib/fog/core/provider.rb +35 -0
- data/vendor/fog/lib/fog/core/scp.rb +96 -0
- data/vendor/fog/lib/fog/core/service.rb +223 -0
- data/vendor/fog/lib/fog/core/ssh.rb +137 -0
- data/vendor/fog/lib/fog/core/time.rb +32 -0
- data/vendor/fog/lib/fog/core/timeout.rb +11 -0
- data/vendor/fog/lib/fog/core/wait_for.rb +15 -0
- data/vendor/fog/lib/fog/digitalocean.rb +9 -0
- data/vendor/fog/lib/fog/digitalocean/compute.rb +100 -0
- data/vendor/fog/lib/fog/digitalocean/examples/getting_started.md +106 -0
- data/vendor/fog/lib/fog/digitalocean/models/compute/flavor.rb +14 -0
- data/vendor/fog/lib/fog/digitalocean/models/compute/flavors.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/models/compute/image.rb +15 -0
- data/vendor/fog/lib/fog/digitalocean/models/compute/images.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/models/compute/region.rb +14 -0
- data/vendor/fog/lib/fog/digitalocean/models/compute/regions.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/models/compute/server.rb +150 -0
- data/vendor/fog/lib/fog/digitalocean/models/compute/servers.rb +27 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/create_server.rb +49 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/create_ssh_key.rb +26 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/destroy_server.rb +28 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/get_server_details.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/list_flavors.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/list_images.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/list_regions.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/list_servers.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/list_ssh_keys.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/power_cycle_server.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/power_off_server.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/power_on_server.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/reboot_server.rb +25 -0
- data/vendor/fog/lib/fog/digitalocean/requests/compute/shutdown_server.rb +25 -0
- data/vendor/fog/lib/fog/dns.rb +59 -0
- data/vendor/fog/lib/fog/identity.rb +27 -0
- data/vendor/fog/lib/fog/image.rb +24 -0
- data/vendor/fog/lib/fog/local.rb +11 -0
- data/vendor/fog/lib/fog/local/models/storage/directories.rb +33 -0
- data/vendor/fog/lib/fog/local/models/storage/directory.rb +57 -0
- data/vendor/fog/lib/fog/local/models/storage/file.rb +131 -0
- data/vendor/fog/lib/fog/local/models/storage/files.rb +87 -0
- data/vendor/fog/lib/fog/local/storage.rb +103 -0
- data/vendor/fog/lib/fog/network.rb +26 -0
- data/vendor/fog/lib/fog/openstack.rb +214 -0
- data/vendor/fog/lib/fog/openstack/README.identity.md +69 -0
- data/vendor/fog/lib/fog/openstack/compute.rb +423 -0
- data/vendor/fog/lib/fog/openstack/identity.rb +299 -0
- data/vendor/fog/lib/fog/openstack/image.rb +217 -0
- data/vendor/fog/lib/fog/openstack/models/compute/address.rb +71 -0
- data/vendor/fog/lib/fog/openstack/models/compute/addresses.rb +33 -0
- data/vendor/fog/lib/fog/openstack/models/compute/flavor.rb +45 -0
- data/vendor/fog/lib/fog/openstack/models/compute/flavors.rb +28 -0
- data/vendor/fog/lib/fog/openstack/models/compute/host.rb +29 -0
- data/vendor/fog/lib/fog/openstack/models/compute/hosts.rb +32 -0
- data/vendor/fog/lib/fog/openstack/models/compute/image.rb +58 -0
- data/vendor/fog/lib/fog/openstack/models/compute/images.rb +33 -0
- data/vendor/fog/lib/fog/openstack/models/compute/key_pair.rb +60 -0
- data/vendor/fog/lib/fog/openstack/models/compute/key_pairs.rb +31 -0
- data/vendor/fog/lib/fog/openstack/models/compute/metadata.rb +68 -0
- data/vendor/fog/lib/fog/openstack/models/compute/metadatum.rb +29 -0
- data/vendor/fog/lib/fog/openstack/models/compute/network.rb +13 -0
- data/vendor/fog/lib/fog/openstack/models/compute/networks.rb +29 -0
- data/vendor/fog/lib/fog/openstack/models/compute/security_group.rb +44 -0
- data/vendor/fog/lib/fog/openstack/models/compute/security_groups.rb +27 -0
- data/vendor/fog/lib/fog/openstack/models/compute/server.rb +278 -0
- data/vendor/fog/lib/fog/openstack/models/compute/servers.rb +44 -0
- data/vendor/fog/lib/fog/openstack/models/compute/snapshot.rb +44 -0
- data/vendor/fog/lib/fog/openstack/models/compute/snapshots.rb +26 -0
- data/vendor/fog/lib/fog/openstack/models/compute/tenant.rb +24 -0
- data/vendor/fog/lib/fog/openstack/models/compute/tenants.rb +24 -0
- data/vendor/fog/lib/fog/openstack/models/compute/volume.rb +59 -0
- data/vendor/fog/lib/fog/openstack/models/compute/volumes.rb +26 -0
- data/vendor/fog/lib/fog/openstack/models/identity/ec2_credential.rb +44 -0
- data/vendor/fog/lib/fog/openstack/models/identity/ec2_credentials.rb +53 -0
- data/vendor/fog/lib/fog/openstack/models/identity/role.rb +50 -0
- data/vendor/fog/lib/fog/openstack/models/identity/roles.rb +21 -0
- data/vendor/fog/lib/fog/openstack/models/identity/tenant.rb +62 -0
- data/vendor/fog/lib/fog/openstack/models/identity/tenants.rb +29 -0
- data/vendor/fog/lib/fog/openstack/models/identity/user.rb +70 -0
- data/vendor/fog/lib/fog/openstack/models/identity/users.rb +32 -0
- data/vendor/fog/lib/fog/openstack/models/image/image.rb +91 -0
- data/vendor/fog/lib/fog/openstack/models/image/images.rb +60 -0
- data/vendor/fog/lib/fog/openstack/models/meta_parent.rb +33 -0
- data/vendor/fog/lib/fog/openstack/models/network/floating_ip.rb +52 -0
- data/vendor/fog/lib/fog/openstack/models/network/floating_ips.rb +34 -0
- data/vendor/fog/lib/fog/openstack/models/network/network.rb +47 -0
- data/vendor/fog/lib/fog/openstack/models/network/networks.rb +34 -0
- data/vendor/fog/lib/fog/openstack/models/network/port.rb +53 -0
- data/vendor/fog/lib/fog/openstack/models/network/ports.rb +34 -0
- data/vendor/fog/lib/fog/openstack/models/network/subnet.rb +56 -0
- data/vendor/fog/lib/fog/openstack/models/network/subnets.rb +34 -0
- data/vendor/fog/lib/fog/openstack/models/storage/directories.rb +39 -0
- data/vendor/fog/lib/fog/openstack/models/storage/directory.rb +50 -0
- data/vendor/fog/lib/fog/openstack/models/storage/file.rb +152 -0
- data/vendor/fog/lib/fog/openstack/models/storage/files.rb +94 -0
- data/vendor/fog/lib/fog/openstack/models/volume/volume.rb +47 -0
- data/vendor/fog/lib/fog/openstack/models/volume/volumes.rb +27 -0
- data/vendor/fog/lib/fog/openstack/network.rb +247 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/add_fixed_ip.rb +29 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/allocate_address.rb +42 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/associate_address.rb +27 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/attach_volume.rb +38 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/boot_from_snapshot.rb +41 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/change_server_password.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/confirm_resize_server.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/create_flavor.rb +85 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb +49 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/create_key_pair.rb +49 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/create_security_group.rb +52 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/create_security_group_rule.rb +59 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/create_server.rb +131 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/create_volume.rb +54 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/create_volume_snapshot.rb +47 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/delete_flavor.rb +28 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/delete_image.rb +40 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/delete_key_pair.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/delete_metadata.rb +28 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/delete_security_group.rb +33 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/delete_security_group_rule.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/delete_server.rb +38 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/delete_snapshot.rb +26 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/delete_volume.rb +26 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/detach_volume.rb +26 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/disassociate_address.rb +27 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_address.rb +41 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_console_output.rb +28 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_flavor_details.rb +43 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_host_details.rb +74 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_image_details.rb +33 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_limits.rb +93 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_metadata.rb +29 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_quota.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_quota_defaults.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_security_group.rb +49 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_server_details.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_server_volumes.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_snapshot_details.rb +39 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_usage.rb +53 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_vnc_console.rb +40 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/get_volume_details.rb +42 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_address_pools.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_addresses.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_all_addresses.rb +64 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_flavors.rb +38 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_flavors_detail.rb +38 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_hosts.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_images.rb +33 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_images_detail.rb +39 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_key_pairs.rb +39 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_metadata.rb +28 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_private_addresses.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_public_addresses.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_security_groups.rb +50 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_servers.rb +37 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_servers_detail.rb +44 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_snapshots.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_tenants.rb +45 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_usages.rb +43 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/list_volumes.rb +51 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/live_migrate_server.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/migrate_server.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/pause_server.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/reboot_server.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/rebuild_server.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/release_address.rb +34 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/remove_fixed_ip.rb +29 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/rescue_server.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/reset_server_state.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/resize_server.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/resume_server.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/revert_resize_server.rb +30 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/server_action.rb +18 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/server_actions.rb +27 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/server_diagnostics.rb +25 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/set_metadata.rb +45 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/set_tenant.rb +21 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/suspend_server.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/unpause_server.rb +24 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/update_metadata.rb +46 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/update_quota.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/compute/update_server.rb +35 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/add_user_to_tenant.rb +34 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/check_token.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/create_ec2_credential.rb +58 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/create_role.rb +37 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/create_tenant.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/create_user.rb +47 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/create_user_role.rb +26 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/delete_ec2_credential.rb +44 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/delete_role.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/delete_tenant.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/delete_user.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/delete_user_role.rb +26 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/get_ec2_credential.rb +49 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/get_role.rb +28 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/get_tenant.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/get_tenants_by_id.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/get_tenants_by_name.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/get_user_by_id.rb +34 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/get_user_by_name.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/list_ec2_credentials.rb +44 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/list_endpoints_for_token.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/list_roles.rb +36 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/list_roles_for_user_on_tenant.rb +30 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/list_tenants.rb +45 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/list_user_global_roles.rb +22 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/list_users.rb +34 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/remove_user_from_tenant.rb +20 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/set_tenant.rb +21 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/update_tenant.rb +28 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/update_user.rb +36 -0
- data/vendor/fog/lib/fog/openstack/requests/identity/validate_token.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/image/add_member_to_image.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/image/create_image.rb +79 -0
- data/vendor/fog/lib/fog/openstack/requests/image/delete_image.rb +25 -0
- data/vendor/fog/lib/fog/openstack/requests/image/get_image.rb +45 -0
- data/vendor/fog/lib/fog/openstack/requests/image/get_image_by_id.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/image/get_image_members.rb +29 -0
- data/vendor/fog/lib/fog/openstack/requests/image/get_shared_images.rb +29 -0
- data/vendor/fog/lib/fog/openstack/requests/image/list_public_images.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/image/list_public_images_detailed.rb +31 -0
- data/vendor/fog/lib/fog/openstack/requests/image/remove_member_from_image.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/image/set_tenant.rb +21 -0
- data/vendor/fog/lib/fog/openstack/requests/image/update_image.rb +70 -0
- data/vendor/fog/lib/fog/openstack/requests/image/update_image_members.rb +37 -0
- data/vendor/fog/lib/fog/openstack/requests/network/associate_floating_ip.rb +49 -0
- data/vendor/fog/lib/fog/openstack/requests/network/create_floating_ip.rb +50 -0
- data/vendor/fog/lib/fog/openstack/requests/network/create_network.rb +44 -0
- data/vendor/fog/lib/fog/openstack/requests/network/create_port.rb +52 -0
- data/vendor/fog/lib/fog/openstack/requests/network/create_subnet.rb +56 -0
- data/vendor/fog/lib/fog/openstack/requests/network/delete_floating_ip.rb +30 -0
- data/vendor/fog/lib/fog/openstack/requests/network/delete_network.rb +30 -0
- data/vendor/fog/lib/fog/openstack/requests/network/delete_port.rb +30 -0
- data/vendor/fog/lib/fog/openstack/requests/network/delete_subnet.rb +30 -0
- data/vendor/fog/lib/fog/openstack/requests/network/disassociate_floating_ip.rb +49 -0
- data/vendor/fog/lib/fog/openstack/requests/network/get_floating_ip.rb +42 -0
- data/vendor/fog/lib/fog/openstack/requests/network/get_network.rb +42 -0
- data/vendor/fog/lib/fog/openstack/requests/network/get_port.rb +48 -0
- data/vendor/fog/lib/fog/openstack/requests/network/get_subnet.rb +49 -0
- data/vendor/fog/lib/fog/openstack/requests/network/list_floating_ips.rb +27 -0
- data/vendor/fog/lib/fog/openstack/requests/network/list_networks.rb +27 -0
- data/vendor/fog/lib/fog/openstack/requests/network/list_ports.rb +27 -0
- data/vendor/fog/lib/fog/openstack/requests/network/list_subnets.rb +27 -0
- data/vendor/fog/lib/fog/openstack/requests/network/set_tenant.rb +21 -0
- data/vendor/fog/lib/fog/openstack/requests/network/update_network.rb +41 -0
- data/vendor/fog/lib/fog/openstack/requests/network/update_port.rb +44 -0
- data/vendor/fog/lib/fog/openstack/requests/network/update_subnet.rb +44 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/copy_object.rb +27 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/delete_container.rb +22 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/delete_object.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/get_container.rb +44 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/get_containers.rb +33 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/get_object.rb +29 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/get_object_https_url.rb +51 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/head_container.rb +28 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/head_containers.rb +25 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/head_object.rb +23 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/post_set_meta_temp_url_key.rb +37 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/put_container.rb +22 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/put_object.rb +30 -0
- data/vendor/fog/lib/fog/openstack/requests/storage/put_object_manifest.rb +25 -0
- data/vendor/fog/lib/fog/openstack/requests/volume/create_volume.rb +54 -0
- data/vendor/fog/lib/fog/openstack/requests/volume/create_volume_snapshot.rb +47 -0
- data/vendor/fog/lib/fog/openstack/requests/volume/delete_snapshot.rb +26 -0
- data/vendor/fog/lib/fog/openstack/requests/volume/delete_volume.rb +26 -0
- data/vendor/fog/lib/fog/openstack/requests/volume/get_snapshot_details.rb +39 -0
- data/vendor/fog/lib/fog/openstack/requests/volume/get_volume_details.rb +42 -0
- data/vendor/fog/lib/fog/openstack/requests/volume/list_snapshots.rb +32 -0
- data/vendor/fog/lib/fog/openstack/requests/volume/list_volumes.rb +55 -0
- data/vendor/fog/lib/fog/openstack/requests/volume/set_tenant.rb +21 -0
- data/vendor/fog/lib/fog/openstack/storage.rb +162 -0
- data/vendor/fog/lib/fog/openstack/volume.rb +219 -0
- data/vendor/fog/lib/fog/providers.rb +2 -0
- data/vendor/fog/lib/fog/schema/data_validator.rb +154 -0
- data/vendor/fog/lib/fog/storage.rb +97 -0
- data/vendor/fog/lib/fog/version.rb +3 -0
- data/vendor/fog/lib/fog/volume.rb +25 -0
- metadata +576 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
module Cifrado
|
2
|
+
|
3
|
+
class FileSplitter
|
4
|
+
include Utils
|
5
|
+
|
6
|
+
attr_reader :cache_dir
|
7
|
+
attr_accessor :chunk_suffix
|
8
|
+
|
9
|
+
# FileSplitter.new("elfari.webm", 10).split
|
10
|
+
#
|
11
|
+
# @param [String] file path to split
|
12
|
+
# @param [Integer] number of chunks
|
13
|
+
# @param [String] Destination directory of the chunks
|
14
|
+
def initialize(filename,
|
15
|
+
chunk_number = nil,
|
16
|
+
cache_dir = File.join(ENV['HOME'], '.cache/cifrado') )
|
17
|
+
raise ArgumentError.new unless File.exist?(filename)
|
18
|
+
@filename = File.basename filename
|
19
|
+
@source = filename
|
20
|
+
@chunk_number = chunk_number || calculate_chunks(filename)
|
21
|
+
|
22
|
+
# when we are splitting a file into a given number of chunks,
|
23
|
+
# the last chunk could be bigger than the others
|
24
|
+
@each_size, @extra = File.size(filename).divmod(@chunk_number)
|
25
|
+
@cache_dir = File.expand_path cache_dir
|
26
|
+
@chunk_suffix = "/segments/#{'%.2f' % File.mtime(filename).to_f}/#{File.size(filename)}/"
|
27
|
+
end
|
28
|
+
|
29
|
+
def split
|
30
|
+
file = File.new(@source, "rb")
|
31
|
+
# create cache directory
|
32
|
+
unless File.directory?(@cache_dir)
|
33
|
+
Log.debug "Creating cache dir: #{@cache_dir}"
|
34
|
+
FileUtils.mkdir_p(@cache_dir)
|
35
|
+
end
|
36
|
+
|
37
|
+
chunks = []
|
38
|
+
byte_count = 0
|
39
|
+
chunk_n = 1
|
40
|
+
chunk_name = @filename + "#{@chunk_suffix.gsub('/','-')}"
|
41
|
+
chunk = File.join(@cache_dir, "#{chunk_name}#{'%08d' % chunk_n}")
|
42
|
+
chunk_f = File.open(chunk, "wb")
|
43
|
+
while read = file.read(4096) do
|
44
|
+
if byte_count >= @each_size
|
45
|
+
chunk_f.close
|
46
|
+
chunks << chunk
|
47
|
+
yield chunk_n, chunk if block_given?
|
48
|
+
chunk_n += 1
|
49
|
+
chunk = File.join(@cache_dir, "#{chunk_name}#{'%08d' % chunk_n}")
|
50
|
+
chunk_f = File.open(chunk, "wb")
|
51
|
+
byte_count = 0
|
52
|
+
end
|
53
|
+
chunk_f << read
|
54
|
+
byte_count += 4096
|
55
|
+
end
|
56
|
+
chunk_f.flush
|
57
|
+
yield chunk_n, chunk if block_given?
|
58
|
+
chunks << chunk
|
59
|
+
chunks
|
60
|
+
ensure
|
61
|
+
chunk_f.close unless chunk_f.closed?
|
62
|
+
file.close unless file.closed?
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Cifrado
|
2
|
+
class RateLimit
|
3
|
+
|
4
|
+
def initialize(bwlimit)
|
5
|
+
@time = Time.now.to_f
|
6
|
+
@read = 0
|
7
|
+
@sleep_time = 0.01
|
8
|
+
@bwlimit = bwlimit
|
9
|
+
end
|
10
|
+
|
11
|
+
def limit(read)
|
12
|
+
bps = @read/(Time.now.to_f - @time)
|
13
|
+
if bps > @bwlimit
|
14
|
+
Log.debug 'limiting rate'
|
15
|
+
sleep @sleep_time
|
16
|
+
@sleep_time += 0.01
|
17
|
+
else
|
18
|
+
@sleep_time -= 0.01 if @sleep_time >= 0.02
|
19
|
+
end
|
20
|
+
@read += read
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
|
4
|
+
module Cifrado
|
5
|
+
class StreamingDownloader
|
6
|
+
|
7
|
+
def self.get url, output, options = {}
|
8
|
+
if output.nil? and !options[:stream]
|
9
|
+
raise ArgumentError.new('Invalid output file')
|
10
|
+
end
|
11
|
+
uri = URI.parse url
|
12
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
13
|
+
http.use_ssl = true if uri.scheme == "https"
|
14
|
+
copts = options[:connection_options]
|
15
|
+
if copts[:ssl_verify_peer] == false
|
16
|
+
Log.debug "SSL verification DISABLED"
|
17
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
18
|
+
end
|
19
|
+
#http.open_timeout = 10 # seconds
|
20
|
+
#http.read_timeout = 10 # seconds
|
21
|
+
Log.debug "Request URL #{uri.request_uri}"
|
22
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
23
|
+
|
24
|
+
headers = options[:headers]
|
25
|
+
request.initialize_http_header headers
|
26
|
+
|
27
|
+
rate_limit = nil
|
28
|
+
rate_limit = Cifrado::RateLimit.new(options[:bwlimit]) if options[:bwlimit]
|
29
|
+
|
30
|
+
unless options[:stream]
|
31
|
+
file = File.open(output, "wb")
|
32
|
+
Log.debug "Downloading file to #{output}"
|
33
|
+
end
|
34
|
+
callback = options[:progress_callback]
|
35
|
+
|
36
|
+
http.request(request) do |response|
|
37
|
+
clength = response['Content-Length'].to_i
|
38
|
+
response.read_body do |segment|
|
39
|
+
rate_limit.limit(segment.size) if rate_limit
|
40
|
+
callback.call(clength, segment.length, segment) if callback
|
41
|
+
file.write(segment) if file
|
42
|
+
end
|
43
|
+
end
|
44
|
+
ensure
|
45
|
+
file.close if file
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Cifrado
|
2
|
+
|
3
|
+
# StreamingUploader Adapted by Sergio Rubio <rubiojr@frameos.org>
|
4
|
+
#
|
5
|
+
# inspired by Opscode Chef StreamingCookbookUploader chef/streaming_cookbook_uploader.rb
|
6
|
+
# http://opscode.com
|
7
|
+
#
|
8
|
+
# inspired by/cargo-culted from http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html
|
9
|
+
# On Apr 6, 2010, at 3:00 PM, Stanislav Vitvitskiy wrote:
|
10
|
+
#
|
11
|
+
# It's free to use / modify / distribute. No need to mention anything. Just copy/paste and use.
|
12
|
+
#
|
13
|
+
# Regards,
|
14
|
+
# Stan
|
15
|
+
|
16
|
+
|
17
|
+
require 'net/http'
|
18
|
+
require 'net/https'
|
19
|
+
require 'cifrado/rate_limit'
|
20
|
+
|
21
|
+
class StreamingUploader
|
22
|
+
|
23
|
+
class << self
|
24
|
+
|
25
|
+
def put(to_url, params = {})
|
26
|
+
|
27
|
+
file = params[:file]
|
28
|
+
headers = params[:headers] || {}
|
29
|
+
chunker = nil
|
30
|
+
rate_limit = nil
|
31
|
+
rate_limit = Cifrado::RateLimit.new(params[:bwlimit]) if params[:bwlimit]
|
32
|
+
|
33
|
+
if file
|
34
|
+
headers.merge!({ 'Content-Length' => File.size(file.path).to_s })
|
35
|
+
|
36
|
+
chunker = lambda do
|
37
|
+
chunk = file.read(4096).to_s
|
38
|
+
|
39
|
+
rate_limit.limit(chunk.size) if rate_limit
|
40
|
+
|
41
|
+
if block_given? and chunk.size > 0
|
42
|
+
yield chunk.size
|
43
|
+
end
|
44
|
+
chunk
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Excon.put to_url,
|
49
|
+
:headers => headers,
|
50
|
+
:request_block => chunker
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,313 @@
|
|
1
|
+
require 'cifrado/streaming_uploader'
|
2
|
+
require 'cifrado/streaming_downloader'
|
3
|
+
|
4
|
+
module Cifrado
|
5
|
+
|
6
|
+
class SwiftClient
|
7
|
+
|
8
|
+
include Cifrado::Utils
|
9
|
+
attr_reader :api_key
|
10
|
+
attr_reader :username
|
11
|
+
attr_reader :auth_url
|
12
|
+
|
13
|
+
def initialize(auth_data = {})
|
14
|
+
@username = auth_data[:username]
|
15
|
+
@api_key = auth_data[:api_key]
|
16
|
+
@auth_url = auth_data[:auth_url]
|
17
|
+
@tenant = auth_data[:tenant]
|
18
|
+
@region = auth_data[:region]
|
19
|
+
@connection_options = auth_data[:connection_options] || {}
|
20
|
+
@service_type = auth_data[:service_type] || 'object-store'
|
21
|
+
@endpoint_type = auth_data[:endpoint_type] || 'publicURL'
|
22
|
+
@password_salt = auth_data[:password_salt]
|
23
|
+
|
24
|
+
@connection_options.each do |k, v|
|
25
|
+
Excon.defaults[k] = v
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_connection
|
30
|
+
authenticate_v2
|
31
|
+
end
|
32
|
+
|
33
|
+
def head(container = nil, object = nil)
|
34
|
+
begin
|
35
|
+
if container and object
|
36
|
+
service.head_object(container, object).headers
|
37
|
+
elsif container
|
38
|
+
service.head_container(container).headers
|
39
|
+
else
|
40
|
+
(service.request :method => 'HEAD').headers
|
41
|
+
end
|
42
|
+
rescue Fog::Storage::OpenStack::NotFound
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def file_available?(container, object)
|
48
|
+
!head(container, object).nil?
|
49
|
+
end
|
50
|
+
|
51
|
+
def service
|
52
|
+
@service ||= authenticate_v2
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_acl(acl, container, object = nil)
|
56
|
+
if object
|
57
|
+
raise NotImplementedError.new
|
58
|
+
else
|
59
|
+
service.request :path => Fog::OpenStack.escape(container),
|
60
|
+
:headers => { 'X-Container-Read' => acl },
|
61
|
+
:expects => [201, 202],
|
62
|
+
:method => 'PUT'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_directory(container, wait_for_it = false)
|
67
|
+
create_container container, wait_for_it
|
68
|
+
end
|
69
|
+
|
70
|
+
def encrypted_upload(container, object, options = {})
|
71
|
+
cipher = CryptoEngineAES.new @api_key
|
72
|
+
encrypted_name = cipher.encrypt object
|
73
|
+
options[:headers] ||= {}
|
74
|
+
options[:headers]['X-Object-Meta-Encrypted-Name'] = encrypted_name
|
75
|
+
upload container, object, options
|
76
|
+
end
|
77
|
+
|
78
|
+
def upload(container, object, options = {})
|
79
|
+
|
80
|
+
raise ArgumentError.new("Invalid container") if container.nil?
|
81
|
+
raise ArgumentError.new("Invalid object") if object.nil?
|
82
|
+
|
83
|
+
# if :source_file present, object may be the destination
|
84
|
+
# path of the object and may not be the path to the
|
85
|
+
# real file
|
86
|
+
object_path = clean_object_name(options[:object_path] || object)
|
87
|
+
object_size = File.size(object)
|
88
|
+
|
89
|
+
Log.debug "Object size: #{humanize_bytes(object_size)}"
|
90
|
+
|
91
|
+
path = File.join('/', container, object_path)
|
92
|
+
|
93
|
+
Log.debug "X-Storage-Url: #{@storage_url}"
|
94
|
+
|
95
|
+
create_container container, true
|
96
|
+
|
97
|
+
Log.debug "Destination URI: " + @storage_url + path
|
98
|
+
|
99
|
+
pcallback = options[:progress_callback]
|
100
|
+
nchunk = 0
|
101
|
+
headers = { 'X-Auth-Token' => @auth_token }
|
102
|
+
if mime = mime_type(object)
|
103
|
+
headers['Content-Type'] = mime
|
104
|
+
end
|
105
|
+
if options[:headers]
|
106
|
+
headers = headers.merge options[:headers]
|
107
|
+
end
|
108
|
+
if pcallback
|
109
|
+
res = Cifrado::StreamingUploader.put(
|
110
|
+
@storage_url + Fog::OpenStack.escape(path),
|
111
|
+
:headers => headers,
|
112
|
+
:file => File.open(object),
|
113
|
+
:ssl_verify_peer => @connection_options[:ssl_verify_peer],
|
114
|
+
:bwlimit => options[:bwlimit]
|
115
|
+
) { |bytes| pcallback.call(object_size, bytes) }
|
116
|
+
else
|
117
|
+
res = Cifrado::StreamingUploader.put(
|
118
|
+
@storage_url + Fog::OpenStack.escape(path),
|
119
|
+
:headers => headers,
|
120
|
+
:file => File.open(object),
|
121
|
+
:ssl_verify_peer => @connection_options[:ssl_verify_peer],
|
122
|
+
:bwlimit => options[:bwlimit]
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
126
|
+
Log.debug "Upload response #{res.class}"
|
127
|
+
res
|
128
|
+
end
|
129
|
+
|
130
|
+
def user_agent
|
131
|
+
"Cifrado #{Cifrado::VERSION}"
|
132
|
+
end
|
133
|
+
|
134
|
+
def stream(container, object, options = {})
|
135
|
+
raise ArgumentError.new "Invalid object" unless object
|
136
|
+
|
137
|
+
storage_url = service.credentials[:server_management_url]
|
138
|
+
storage_url << "/" unless storage_url =~ /\/$/
|
139
|
+
|
140
|
+
path = File.join(container, clean_object_name(object))
|
141
|
+
|
142
|
+
headers = {
|
143
|
+
"User-Agent" => "#{user_agent}",
|
144
|
+
"X-Auth-Token" => @auth_token
|
145
|
+
}
|
146
|
+
res = StreamingDownloader.get storage_url + Fog::OpenStack.escape(path),
|
147
|
+
nil,
|
148
|
+
:progress_callback => options[:progress_callback],
|
149
|
+
:connection_options => @connection_options,
|
150
|
+
:headers => headers,
|
151
|
+
:bwlimit => options[:bwlimit],
|
152
|
+
:stream => true
|
153
|
+
end
|
154
|
+
|
155
|
+
def download(container, object = nil, options = {})
|
156
|
+
if object
|
157
|
+
download_object container, object, options
|
158
|
+
else
|
159
|
+
dir = service.directories.get container
|
160
|
+
unless dir
|
161
|
+
Log.debug "Container #{container} not found"
|
162
|
+
raise "Container #{container} not found"
|
163
|
+
end
|
164
|
+
dest_dir = options[:output] || Dir.pwd
|
165
|
+
unless File.directory?(dest_dir)
|
166
|
+
raise ArgumentError.new "Directory #{dest_dir} does not exist"
|
167
|
+
end
|
168
|
+
dir.files.each do |f|
|
169
|
+
# Skip segments from segmented uploads
|
170
|
+
if f.key =~ /segments\/\d+\.\d{2}\/\d+/
|
171
|
+
Log.debug "Skipping segment #{f.key}"
|
172
|
+
next
|
173
|
+
end
|
174
|
+
unless options[:decrypt] == true
|
175
|
+
options[:output] = File.join(dest_dir, f.key)
|
176
|
+
end
|
177
|
+
download_object container, f.key, options
|
178
|
+
end
|
179
|
+
Excon::Response.new :status => 200
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
#
|
184
|
+
# @returns [Integer]
|
185
|
+
# * 0 if not available
|
186
|
+
# * 1 if available
|
187
|
+
# * 2 if available but MD5 does not match
|
188
|
+
def match(source_file, container, object_path = nil)
|
189
|
+
obj = object_path || source_file
|
190
|
+
headers = head container, clean_object_name(obj)
|
191
|
+
if headers
|
192
|
+
md5 = Digest::MD5.file(source_file).to_s
|
193
|
+
(md5 == headers['Etag']) ? 1 : 2
|
194
|
+
else
|
195
|
+
0
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
private
|
200
|
+
def download_object(container, object, options = {})
|
201
|
+
storage_url = service.credentials[:server_management_url]
|
202
|
+
storage_url << "/" unless storage_url =~ /\/$/
|
203
|
+
object = object[1..-1] if object =~ /^\//
|
204
|
+
|
205
|
+
raise ArgumentError.new "Invalid object" unless object
|
206
|
+
path = File.join(container, object)
|
207
|
+
|
208
|
+
dest_file = options[:output]
|
209
|
+
if dest_file
|
210
|
+
if File.directory?(dest_file)
|
211
|
+
dest_file = File.join dest_file, object
|
212
|
+
end
|
213
|
+
else
|
214
|
+
Log.debug ":output option not specified, using current dir"
|
215
|
+
dest_file = File.join Dir.pwd, object
|
216
|
+
end
|
217
|
+
|
218
|
+
tmp_file = File.join Config.instance.cache_dir, "#{Time.now.to_f}.download"
|
219
|
+
Log.debug "Downloading tmp file to #{tmp_file}"
|
220
|
+
|
221
|
+
headers = {
|
222
|
+
"User-Agent" => "#{user_agent}",
|
223
|
+
"X-Auth-Token" => @auth_token
|
224
|
+
}
|
225
|
+
res = StreamingDownloader.get storage_url + Fog::OpenStack.escape(path),
|
226
|
+
tmp_file,
|
227
|
+
:progress_callback => options[:progress_callback],
|
228
|
+
:connection_options => @connection_options,
|
229
|
+
:headers => headers,
|
230
|
+
:bwlimit => options[:bwlimit]
|
231
|
+
|
232
|
+
#
|
233
|
+
# Try to decrypt the file if it was encrypted
|
234
|
+
#
|
235
|
+
if options[:decrypt]
|
236
|
+
encrypted_name = res['X-Object-Meta-Encrypted-Name']
|
237
|
+
if encrypted_name
|
238
|
+
Log.debug 'Encrypted filename found, decrypting'
|
239
|
+
if @password_salt
|
240
|
+
decrypted_name = decrypt_filename encrypted_name, @api_key + @password_salt
|
241
|
+
else
|
242
|
+
decrypted_name = decrypt_filename encrypted_name, @api_key
|
243
|
+
end
|
244
|
+
Log.debug "Decrypted filename: #{decrypted_name}"
|
245
|
+
if options[:output].nil?
|
246
|
+
dest_file = File.join(Dir.pwd, decrypted_name)
|
247
|
+
elsif File.directory?(options[:output])
|
248
|
+
dest_file = File.join(options[:output], decrypted_name)
|
249
|
+
else
|
250
|
+
end
|
251
|
+
Log.debug "Decrypted file output: #{dest_file}"
|
252
|
+
cs = CryptoServices.new :passphrase => options[:passphrase]
|
253
|
+
tmp_file = cs.decrypt tmp_file, tmp_file + '.decrypted'
|
254
|
+
else
|
255
|
+
Log.warn 'X-Object-Meta-Encrypted-Name header not found in object'
|
256
|
+
Log.warn 'Trying to decrypt anyways'
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
# if download is OK, move the file from cache to :output
|
261
|
+
# or to the current directory
|
262
|
+
if res.is_a? Net::HTTPOK
|
263
|
+
Log.debug "Moving download tmp file to #{dest_file}"
|
264
|
+
# Object name may have a path, create target directory
|
265
|
+
# if not available
|
266
|
+
target_dir = File.dirname(dest_file)
|
267
|
+
unless File.directory?(target_dir)
|
268
|
+
Log.debug "Creating target directory #{target_dir}"
|
269
|
+
FileUtils.mkdir_p(target_dir)
|
270
|
+
end
|
271
|
+
FileUtils.mv tmp_file, dest_file
|
272
|
+
else
|
273
|
+
Log.debug "Download failed, deleting tmp file"
|
274
|
+
FileUtils.rm tmp_file
|
275
|
+
end
|
276
|
+
Excon::Response.new :body => res.body,
|
277
|
+
:headers => res.to_hash,
|
278
|
+
:status => res.code.to_i
|
279
|
+
end
|
280
|
+
|
281
|
+
def create_container(container, wait_for_it = false )
|
282
|
+
dir = service.directories.create :key => container
|
283
|
+
# Wait for the new container to be available
|
284
|
+
dir.wait_for { !service.directories.get(container).nil? } if wait_for_it
|
285
|
+
dir
|
286
|
+
end
|
287
|
+
|
288
|
+
def add_manifest(container, object)
|
289
|
+
create_container container
|
290
|
+
service.put_object_manifest container, object
|
291
|
+
end
|
292
|
+
def authenticate_v2
|
293
|
+
return if @service
|
294
|
+
|
295
|
+
Log.debug "Using keystone authentication"
|
296
|
+
@service = Fog::Storage.new :provider => 'OpenStack',
|
297
|
+
:openstack_auth_url => @auth_url,
|
298
|
+
:openstack_username => @username,
|
299
|
+
:openstack_api_key => @api_key,
|
300
|
+
:openstack_tenant => @tenant,
|
301
|
+
:openstack_service_type => @service_type,
|
302
|
+
:openstack_endpoint_type => @endpoint_type,
|
303
|
+
:openstack_region => @region
|
304
|
+
@storage_url = @service.credentials[:server_management_url]
|
305
|
+
@auth_token = @service.credentials[:token]
|
306
|
+
@service
|
307
|
+
end
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
end
|