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,219 @@
|
|
1
|
+
require 'fog/openstack'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Volume
|
5
|
+
class OpenStack < Fog::Service
|
6
|
+
|
7
|
+
requires :openstack_auth_url
|
8
|
+
recognizes :openstack_auth_token, :openstack_management_url, :persistent,
|
9
|
+
:openstack_service_type, :openstack_service_name, :openstack_tenant,
|
10
|
+
:openstack_api_key, :openstack_username,
|
11
|
+
:current_user, :current_tenant,
|
12
|
+
:openstack_endpoint_type
|
13
|
+
|
14
|
+
model_path 'fog/openstack/models/volume'
|
15
|
+
|
16
|
+
model :volume
|
17
|
+
collection :volumes
|
18
|
+
|
19
|
+
|
20
|
+
request_path 'fog/openstack/requests/volume'
|
21
|
+
|
22
|
+
# Volume
|
23
|
+
request :list_volumes
|
24
|
+
request :create_volume
|
25
|
+
request :get_volume_details
|
26
|
+
request :delete_volume
|
27
|
+
|
28
|
+
request :create_volume_snapshot
|
29
|
+
request :list_snapshots
|
30
|
+
request :get_snapshot_details
|
31
|
+
request :delete_snapshot
|
32
|
+
|
33
|
+
request :set_tenant
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
def self.data
|
37
|
+
@data ||= Hash.new do |hash, key|
|
38
|
+
hash[key] = {
|
39
|
+
:users => {},
|
40
|
+
:tenants => {}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.reset
|
46
|
+
@data = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(options={})
|
50
|
+
require 'multi_json'
|
51
|
+
@openstack_username = options[:openstack_username]
|
52
|
+
@openstack_tenant = options[:openstack_tenant]
|
53
|
+
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
54
|
+
|
55
|
+
@auth_token = Fog::Mock.random_base64(64)
|
56
|
+
@auth_token_expiration = (Time.now.utc + 86400).iso8601
|
57
|
+
|
58
|
+
management_url = URI.parse(options[:openstack_auth_url])
|
59
|
+
management_url.port = 8776
|
60
|
+
management_url.path = '/v1'
|
61
|
+
@openstack_management_url = management_url.to_s
|
62
|
+
|
63
|
+
@data ||= { :users => {} }
|
64
|
+
unless @data[:users].find {|u| u['name'] == options[:openstack_username]}
|
65
|
+
id = Fog::Mock.random_numbers(6).to_s
|
66
|
+
@data[:users][id] = {
|
67
|
+
'id' => id,
|
68
|
+
'name' => options[:openstack_username],
|
69
|
+
'email' => "#{options[:openstack_username]}@mock.com",
|
70
|
+
'tenantId' => Fog::Mock.random_numbers(6).to_s,
|
71
|
+
'enabled' => true
|
72
|
+
}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def data
|
77
|
+
self.class.data[@openstack_username]
|
78
|
+
end
|
79
|
+
|
80
|
+
def reset_data
|
81
|
+
self.class.data.delete(@openstack_username)
|
82
|
+
end
|
83
|
+
|
84
|
+
def credentials
|
85
|
+
{ :provider => 'openstack',
|
86
|
+
:openstack_auth_url => @openstack_auth_uri.to_s,
|
87
|
+
:openstack_auth_token => @auth_token,
|
88
|
+
:openstack_management_url => @openstack_management_url }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class Real
|
93
|
+
attr_reader :current_user
|
94
|
+
attr_reader :current_tenant
|
95
|
+
|
96
|
+
def initialize(options={})
|
97
|
+
require 'multi_json'
|
98
|
+
|
99
|
+
@openstack_auth_token = options[:openstack_auth_token]
|
100
|
+
|
101
|
+
unless @openstack_auth_token
|
102
|
+
missing_credentials = Array.new
|
103
|
+
@openstack_api_key = options[:openstack_api_key]
|
104
|
+
@openstack_username = options[:openstack_username]
|
105
|
+
|
106
|
+
missing_credentials << :openstack_api_key unless @openstack_api_key
|
107
|
+
missing_credentials << :openstack_username unless @openstack_username
|
108
|
+
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
109
|
+
end
|
110
|
+
|
111
|
+
@openstack_tenant = options[:openstack_tenant]
|
112
|
+
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
113
|
+
@openstack_management_url = options[:openstack_management_url]
|
114
|
+
@openstack_must_reauthenticate = false
|
115
|
+
@openstack_service_type = options[:openstack_service_type] || ['volume']
|
116
|
+
@openstack_service_name = options[:openstack_service_name]
|
117
|
+
|
118
|
+
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'
|
119
|
+
@connection_options = options[:connection_options] || {}
|
120
|
+
|
121
|
+
@current_user = options[:current_user]
|
122
|
+
@current_tenant = options[:current_tenant]
|
123
|
+
|
124
|
+
authenticate
|
125
|
+
|
126
|
+
@persistent = options[:persistent] || false
|
127
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
128
|
+
end
|
129
|
+
|
130
|
+
def credentials
|
131
|
+
{ :provider => 'openstack',
|
132
|
+
:openstack_auth_url => @openstack_auth_uri.to_s,
|
133
|
+
:openstack_auth_token => @auth_token,
|
134
|
+
:openstack_management_url => @openstack_management_url,
|
135
|
+
:current_user => @current_user,
|
136
|
+
:current_tenant => @current_tenant }
|
137
|
+
end
|
138
|
+
|
139
|
+
def reload
|
140
|
+
@connection.reset
|
141
|
+
end
|
142
|
+
|
143
|
+
def request(params)
|
144
|
+
begin
|
145
|
+
response = @connection.request(params.merge({
|
146
|
+
:headers => {
|
147
|
+
'Content-Type' => 'application/json',
|
148
|
+
'Accept' => 'application/json',
|
149
|
+
'X-Auth-Token' => @auth_token
|
150
|
+
}.merge!(params[:headers] || {}),
|
151
|
+
:host => @host,
|
152
|
+
:path => "#{@path}/#{params[:path]}"#,
|
153
|
+
# Causes errors for some requests like tenants?limit=1
|
154
|
+
# :query => ('ignore_awful_caching' << Time.now.to_i.to_s)
|
155
|
+
}))
|
156
|
+
rescue Excon::Errors::Unauthorized => error
|
157
|
+
if error.response.body != 'Bad username or password' # token expiration
|
158
|
+
@openstack_must_reauthenticate = true
|
159
|
+
authenticate
|
160
|
+
retry
|
161
|
+
else # bad credentials
|
162
|
+
raise error
|
163
|
+
end
|
164
|
+
rescue Excon::Errors::HTTPStatusError => error
|
165
|
+
raise case error
|
166
|
+
when Excon::Errors::NotFound
|
167
|
+
Fog::Compute::OpenStack::NotFound.slurp(error)
|
168
|
+
else
|
169
|
+
error
|
170
|
+
end
|
171
|
+
end
|
172
|
+
unless response.body.empty?
|
173
|
+
response.body = MultiJson.decode(response.body)
|
174
|
+
end
|
175
|
+
response
|
176
|
+
end
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
def authenticate
|
181
|
+
if !@openstack_management_url || @openstack_must_reauthenticate
|
182
|
+
options = {
|
183
|
+
:openstack_tenant => @openstack_tenant,
|
184
|
+
:openstack_api_key => @openstack_api_key,
|
185
|
+
:openstack_username => @openstack_username,
|
186
|
+
:openstack_auth_uri => @openstack_auth_uri,
|
187
|
+
:openstack_auth_token => @openstack_auth_token,
|
188
|
+
:openstack_service_type => @openstack_service_type,
|
189
|
+
:openstack_service_name => @openstack_service_name,
|
190
|
+
:openstack_endpoint_type => @openstack_endpoint_type
|
191
|
+
}
|
192
|
+
|
193
|
+
credentials = Fog::OpenStack.authenticate_v2(options, @connection_options)
|
194
|
+
|
195
|
+
@current_user = credentials[:user]
|
196
|
+
@current_tenant = credentials[:tenant]
|
197
|
+
|
198
|
+
@openstack_must_reauthenticate = false
|
199
|
+
@auth_token = credentials[:token]
|
200
|
+
@openstack_management_url = credentials[:server_management_url]
|
201
|
+
uri = URI.parse(@openstack_management_url)
|
202
|
+
else
|
203
|
+
@auth_token = @openstack_auth_token
|
204
|
+
uri = URI.parse(@openstack_management_url)
|
205
|
+
end
|
206
|
+
|
207
|
+
@host = uri.host
|
208
|
+
@path = uri.path
|
209
|
+
@path.sub!(/\/$/, '')
|
210
|
+
@port = uri.port
|
211
|
+
@scheme = uri.scheme
|
212
|
+
true
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
@@ -0,0 +1,154 @@
|
|
1
|
+
module Fog
|
2
|
+
module Schema
|
3
|
+
# This validates a data object against a Ruby based schema to see
|
4
|
+
# if they match.
|
5
|
+
#
|
6
|
+
# * An object matches the schema if +==+ or +===+ returns +true+
|
7
|
+
# * Hashes match if all the key's values match the classes given
|
8
|
+
# in the schema as well. This can be configured in the options
|
9
|
+
# * Arrays match when every element in the data matches the case
|
10
|
+
# given in the schema.
|
11
|
+
#
|
12
|
+
# The schema and validation are very simple and probably not
|
13
|
+
# suitable for some cases.
|
14
|
+
#
|
15
|
+
# The following classes can be used to check for special behaviour
|
16
|
+
#
|
17
|
+
# * Fog::Boolean - value may be +true+ or +false+
|
18
|
+
# * Fog::Nullable::Boolean - value may be +true+, +false+ or +nil+
|
19
|
+
# * Fog::Nullable::Integer - value may be an Integer or +nil+
|
20
|
+
# * Fog::Nullable::String
|
21
|
+
# * Fog::Nullable::Time
|
22
|
+
# * Fog::Nullable::Float
|
23
|
+
# * Fog::Nullable::Hash
|
24
|
+
# * Fog::Nullable::Array
|
25
|
+
#
|
26
|
+
# All the "nullable" objects will pass if the value is of the class
|
27
|
+
# or if it is +nil+. This allows you to match APIs that may include
|
28
|
+
# keys when the value is not available in some cases but will
|
29
|
+
# always be a String. Such as an password that is only displayed
|
30
|
+
# on the reset action.
|
31
|
+
#
|
32
|
+
# The keys for "nullable" resources should always be present but
|
33
|
+
# original matcher had a bug that allowed these to also appear to
|
34
|
+
# work as optional keys/values.
|
35
|
+
#
|
36
|
+
# If you need the original behaviour, data with a missing key is
|
37
|
+
# still valid, then you may pass the +:allow_optional_rules+
|
38
|
+
# option to the #validate method.
|
39
|
+
#
|
40
|
+
# That is not recommended because you are describing a schema
|
41
|
+
# with optional keys in a format that does not support it.
|
42
|
+
#
|
43
|
+
# Setting +:allow_extra_keys+ as +true+ allows the data to
|
44
|
+
# contain keys not declared by the schema and still pass. This
|
45
|
+
# is useful if new attributes appear in the API in a backwards
|
46
|
+
# compatible manner and can be ignored.
|
47
|
+
#
|
48
|
+
# This is the behaviour you would have seen with +strict+ being
|
49
|
+
# +false+ in the original test helper.
|
50
|
+
#
|
51
|
+
# @example Schema example
|
52
|
+
# {
|
53
|
+
# "id" => String,
|
54
|
+
# "ram" => Integer,
|
55
|
+
# "disks" => [
|
56
|
+
# "size" => Float
|
57
|
+
# ],
|
58
|
+
# "dns_name" => Fog::Nullable::String,
|
59
|
+
# "active" => Fog::Boolean,
|
60
|
+
# "created" => DateTime
|
61
|
+
# }
|
62
|
+
#
|
63
|
+
class DataValidator
|
64
|
+
|
65
|
+
def initialize
|
66
|
+
@message = nil
|
67
|
+
end
|
68
|
+
|
69
|
+
# Checks if the data structure matches the schema passed in and
|
70
|
+
# returns +true+ if it fits.
|
71
|
+
#
|
72
|
+
# @param [Object] data Hash or Array to check
|
73
|
+
# @param [Object] schema Schema pattern to check against
|
74
|
+
# @param [Boolean] options
|
75
|
+
# @option options [Boolean] :allow_extra_keys
|
76
|
+
# If +true+ does not fail if extra keys are in the data
|
77
|
+
# that are not in the schema.
|
78
|
+
# @option options [Boolean] :allow_optional_rules
|
79
|
+
# If +true+ does not fail if extra keys are in the schema
|
80
|
+
# that do not match the data. Not recommended!
|
81
|
+
#
|
82
|
+
# @return [Boolean] Did the data fit the schema?
|
83
|
+
def validate(data, schema, options = {})
|
84
|
+
valid = validate_value(schema, data, options)
|
85
|
+
|
86
|
+
unless valid
|
87
|
+
@message = "#{data.inspect} does not match #{schema.inspect}"
|
88
|
+
end
|
89
|
+
valid
|
90
|
+
end
|
91
|
+
|
92
|
+
# This returns the last message set by the validator
|
93
|
+
#
|
94
|
+
# @return [String]
|
95
|
+
def message
|
96
|
+
@message
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
# This contains a slightly modified version of the Hashidator gem
|
102
|
+
# but unfortunately the gem does not cope with Array schemas.
|
103
|
+
#
|
104
|
+
# @see https://github.com/vangberg/hashidator/blob/master/lib/hashidator.rb
|
105
|
+
#
|
106
|
+
def validate_value(validator, value, options)
|
107
|
+
Fog::Logger.write :debug, "[yellow][DEBUG] #{value.inspect} against #{validator.inspect}[/]\n"
|
108
|
+
|
109
|
+
case validator
|
110
|
+
when Array
|
111
|
+
return false if value.is_a?(Hash)
|
112
|
+
value.respond_to?(:all?) && value.all? {|x| validate_value(validator[0], x, options)}
|
113
|
+
when Symbol
|
114
|
+
value.respond_to? validator
|
115
|
+
when Hash
|
116
|
+
return false if value.is_a?(Array)
|
117
|
+
|
118
|
+
# When being strict values not specified in the schema are fails
|
119
|
+
unless options[:allow_extra_keys]
|
120
|
+
if value.respond_to?(:empty?)
|
121
|
+
# Validator is empty but values are not
|
122
|
+
return false if !value.empty? && validator.empty?
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
unless options[:allow_optional_rules]
|
127
|
+
if value.respond_to?(:empty?)
|
128
|
+
# Validator has rules left but no more values
|
129
|
+
return false if value.empty? && !validator.empty?
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
validator.all? do |key, sub_validator|
|
134
|
+
Fog::Logger.write :debug, "[blue][DEBUG] #{key.inspect} against #{sub_validator.inspect}[/]\n"
|
135
|
+
validate_value(sub_validator, value[key], options)
|
136
|
+
end
|
137
|
+
else
|
138
|
+
result = validator == value
|
139
|
+
result = validator === value unless result
|
140
|
+
# Repeat unless we have a Boolean already
|
141
|
+
unless (result.is_a?(TrueClass) || result.is_a?(FalseClass))
|
142
|
+
result = validate_value(result, value, options)
|
143
|
+
end
|
144
|
+
if result
|
145
|
+
Fog::Logger.write :debug, "[green][DEBUG] Validation passed: #{value.inspect} against #{validator.inspect}[/]\n"
|
146
|
+
else
|
147
|
+
Fog::Logger.write :debug, "[red][DEBUG] Validation failed: #{value.inspect} against #{validator.inspect}[/]\n"
|
148
|
+
end
|
149
|
+
result
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
|
4
|
+
def self.[](provider)
|
5
|
+
self.new(:provider => provider)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.new(attributes)
|
9
|
+
attributes = attributes.dup # prevent delete from having side effects
|
10
|
+
case provider = attributes.delete(:provider).to_s.downcase.to_sym
|
11
|
+
when :atmos
|
12
|
+
require 'fog/atmos/storage'
|
13
|
+
Fog::Storage::Atmos.new(attributes)
|
14
|
+
when :aws
|
15
|
+
require 'fog/aws/storage'
|
16
|
+
Fog::Storage::AWS.new(attributes)
|
17
|
+
when :google
|
18
|
+
require 'fog/google/storage'
|
19
|
+
Fog::Storage::Google.new(attributes)
|
20
|
+
when :hp
|
21
|
+
require 'fog/hp/storage'
|
22
|
+
Fog::Storage::HP.new(attributes)
|
23
|
+
when :ibm
|
24
|
+
require 'fog/ibm/storage'
|
25
|
+
Fog::Storage::IBM.new(attributes)
|
26
|
+
when :internetarchive
|
27
|
+
require 'fog/internet_archive/storage'
|
28
|
+
Fog::Storage::InternetArchive.new(attributes)
|
29
|
+
when :local
|
30
|
+
require 'fog/local/storage'
|
31
|
+
Fog::Storage::Local.new(attributes)
|
32
|
+
when :ninefold
|
33
|
+
require 'fog/ninefold/storage'
|
34
|
+
Fog::Storage::Ninefold.new(attributes)
|
35
|
+
when :rackspace
|
36
|
+
require 'fog/rackspace/storage'
|
37
|
+
Fog::Storage::Rackspace.new(attributes)
|
38
|
+
when :openstack
|
39
|
+
require 'fog/openstack/storage'
|
40
|
+
Fog::Storage::OpenStack.new(attributes)
|
41
|
+
else
|
42
|
+
raise ArgumentError.new("#{provider} is not a recognized storage provider")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.directories
|
47
|
+
directories = []
|
48
|
+
for provider in self.providers
|
49
|
+
begin
|
50
|
+
directories.concat(self[provider].directories)
|
51
|
+
rescue # ignore any missing credentials/etc
|
52
|
+
end
|
53
|
+
end
|
54
|
+
directories
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.get_body_size(body)
|
58
|
+
if body.respond_to?(:force_encoding)
|
59
|
+
body.force_encoding('BINARY')
|
60
|
+
end
|
61
|
+
if body.respond_to?(:bytesize)
|
62
|
+
body.bytesize
|
63
|
+
elsif body.respond_to?(:size)
|
64
|
+
body.size
|
65
|
+
elsif body.respond_to?(:stat)
|
66
|
+
body.stat.size
|
67
|
+
else
|
68
|
+
0
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.get_content_type(data)
|
73
|
+
if data.respond_to?(:path) and !data.path.nil?
|
74
|
+
filename = ::File.basename(data.path)
|
75
|
+
unless (mime_types = MIME::Types.of(filename)).empty?
|
76
|
+
mime_types.first.content_type
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.parse_data(data)
|
82
|
+
{
|
83
|
+
:body => data,
|
84
|
+
:headers => {
|
85
|
+
'Content-Length' => get_body_size(data),
|
86
|
+
'Content-Type' => get_content_type(data)
|
87
|
+
#'Content-MD5' => Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
88
|
+
}
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.providers
|
93
|
+
Fog.services[:storage]
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|