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,299 @@
|
|
1
|
+
require 'fog/openstack'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Identity
|
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, :openstack_current_user_id,
|
11
|
+
:current_user, :current_tenant,
|
12
|
+
:openstack_endpoint_type
|
13
|
+
|
14
|
+
model_path 'fog/openstack/models/identity'
|
15
|
+
model :tenant
|
16
|
+
collection :tenants
|
17
|
+
model :user
|
18
|
+
collection :users
|
19
|
+
model :role
|
20
|
+
collection :roles
|
21
|
+
model :ec2_credential
|
22
|
+
collection :ec2_credentials
|
23
|
+
|
24
|
+
request_path 'fog/openstack/requests/identity'
|
25
|
+
|
26
|
+
request :check_token
|
27
|
+
request :validate_token
|
28
|
+
|
29
|
+
request :list_tenants
|
30
|
+
request :create_tenant
|
31
|
+
request :get_tenant
|
32
|
+
request :get_tenants_by_id
|
33
|
+
request :get_tenants_by_name
|
34
|
+
request :update_tenant
|
35
|
+
request :delete_tenant
|
36
|
+
|
37
|
+
request :list_users
|
38
|
+
request :create_user
|
39
|
+
request :update_user
|
40
|
+
request :delete_user
|
41
|
+
request :get_user_by_id
|
42
|
+
request :get_user_by_name
|
43
|
+
request :add_user_to_tenant
|
44
|
+
request :remove_user_from_tenant
|
45
|
+
|
46
|
+
request :list_endpoints_for_token
|
47
|
+
request :list_roles_for_user_on_tenant
|
48
|
+
request :list_user_global_roles
|
49
|
+
|
50
|
+
request :create_role
|
51
|
+
request :delete_role
|
52
|
+
request :delete_user_role
|
53
|
+
request :create_user_role
|
54
|
+
request :get_role
|
55
|
+
request :list_roles
|
56
|
+
|
57
|
+
request :set_tenant
|
58
|
+
|
59
|
+
request :create_ec2_credential
|
60
|
+
request :delete_ec2_credential
|
61
|
+
request :get_ec2_credential
|
62
|
+
request :list_ec2_credentials
|
63
|
+
|
64
|
+
class Mock
|
65
|
+
attr_reader :auth_token
|
66
|
+
attr_reader :unscoped_token
|
67
|
+
attr_reader :auth_token_expiration
|
68
|
+
attr_reader :current_user
|
69
|
+
attr_reader :current_tenant
|
70
|
+
attr_reader :unscoped_token
|
71
|
+
|
72
|
+
def self.data
|
73
|
+
@users ||= {}
|
74
|
+
@roles ||= {}
|
75
|
+
@tenants ||= {}
|
76
|
+
@ec2_credentials ||= Hash.new { |hash, key| hash[key] = {} }
|
77
|
+
@user_tenant_membership ||= {}
|
78
|
+
|
79
|
+
@data ||= Hash.new do |hash, key|
|
80
|
+
hash[key] = {
|
81
|
+
:users => @users,
|
82
|
+
:roles => @roles,
|
83
|
+
:tenants => @tenants,
|
84
|
+
:ec2_credentials => @ec2_credentials,
|
85
|
+
:user_tenant_membership => @user_tenant_membership
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.reset!
|
91
|
+
@data = nil
|
92
|
+
@users = nil
|
93
|
+
@roles = nil
|
94
|
+
@tenants = nil
|
95
|
+
@ec2_credentials = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
def initialize(options={})
|
99
|
+
require 'multi_json'
|
100
|
+
@openstack_username = options[:openstack_username] || 'admin'
|
101
|
+
@openstack_tenant = options[:openstack_tenant] || 'admin'
|
102
|
+
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
103
|
+
@openstack_management_url = @openstack_auth_uri.to_s
|
104
|
+
|
105
|
+
@auth_token = Fog::Mock.random_base64(64)
|
106
|
+
@auth_token_expiration = (Time.now.utc + 86400).iso8601
|
107
|
+
|
108
|
+
@admin_tenant = self.data[:tenants].values.find do |u|
|
109
|
+
u['name'] == 'admin'
|
110
|
+
end
|
111
|
+
|
112
|
+
if @openstack_tenant
|
113
|
+
@current_tenant = self.data[:tenants].values.find do |u|
|
114
|
+
u['name'] == @openstack_tenant
|
115
|
+
end
|
116
|
+
|
117
|
+
unless @current_tenant
|
118
|
+
@current_tenant_id = Fog::Mock.random_hex(32)
|
119
|
+
@current_tenant = self.data[:tenants][@current_tenant_id] = {
|
120
|
+
'id' => @current_tenant_id,
|
121
|
+
'name' => @openstack_tenant
|
122
|
+
}
|
123
|
+
else
|
124
|
+
@current_tenant_id = @current_tenant['id']
|
125
|
+
end
|
126
|
+
else
|
127
|
+
@current_tenant = @admin_tenant
|
128
|
+
end
|
129
|
+
|
130
|
+
@current_user = self.data[:users].values.find do |u|
|
131
|
+
u['name'] == @openstack_username
|
132
|
+
end
|
133
|
+
@current_tenant_id = Fog::Mock.random_hex(32)
|
134
|
+
|
135
|
+
unless @current_user
|
136
|
+
@current_user_id = Fog::Mock.random_hex(32)
|
137
|
+
@current_user = self.data[:users][@current_user_id] = {
|
138
|
+
'id' => @current_user_id,
|
139
|
+
'name' => @openstack_username,
|
140
|
+
'email' => "#{@openstack_username}@mock.com",
|
141
|
+
'tenantId' => Fog::Mock.random_numbers(6).to_s,
|
142
|
+
'enabled' => true
|
143
|
+
}
|
144
|
+
else
|
145
|
+
@current_user_id = @current_user['id']
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def data
|
150
|
+
self.class.data[@openstack_username]
|
151
|
+
end
|
152
|
+
|
153
|
+
def reset_data
|
154
|
+
self.class.data.delete(@openstack_username)
|
155
|
+
end
|
156
|
+
|
157
|
+
def credentials
|
158
|
+
{ :provider => 'openstack',
|
159
|
+
:openstack_auth_url => @openstack_auth_uri.to_s,
|
160
|
+
:openstack_auth_token => @auth_token,
|
161
|
+
:openstack_management_url => @openstack_management_url,
|
162
|
+
:openstack_current_user_id => @openstack_current_user_id,
|
163
|
+
:current_user => @current_user,
|
164
|
+
:current_tenant => @current_tenant}
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
class Real
|
169
|
+
attr_reader :current_user
|
170
|
+
attr_reader :current_tenant
|
171
|
+
attr_reader :unscoped_token
|
172
|
+
|
173
|
+
def initialize(options={})
|
174
|
+
@openstack_auth_token = options[:openstack_auth_token]
|
175
|
+
|
176
|
+
unless @openstack_auth_token
|
177
|
+
missing_credentials = Array.new
|
178
|
+
@openstack_api_key = options[:openstack_api_key]
|
179
|
+
@openstack_username = options[:openstack_username]
|
180
|
+
|
181
|
+
missing_credentials << :openstack_api_key unless @openstack_api_key
|
182
|
+
missing_credentials << :openstack_username unless @openstack_username
|
183
|
+
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
184
|
+
end
|
185
|
+
|
186
|
+
@openstack_tenant = options[:openstack_tenant]
|
187
|
+
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
188
|
+
@openstack_management_url = options[:openstack_management_url]
|
189
|
+
@openstack_must_reauthenticate = false
|
190
|
+
@openstack_service_type = options[:openstack_service_type] || ['identity']
|
191
|
+
@openstack_service_name = options[:openstack_service_name]
|
192
|
+
|
193
|
+
@connection_options = options[:connection_options] || {}
|
194
|
+
|
195
|
+
@openstack_current_user_id = options[:openstack_current_user_id]
|
196
|
+
|
197
|
+
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'
|
198
|
+
|
199
|
+
@current_user = options[:current_user]
|
200
|
+
@current_tenant = options[:current_tenant]
|
201
|
+
|
202
|
+
authenticate
|
203
|
+
|
204
|
+
@persistent = options[:persistent] || false
|
205
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
206
|
+
end
|
207
|
+
|
208
|
+
def credentials
|
209
|
+
{ :provider => 'openstack',
|
210
|
+
:openstack_auth_url => @openstack_auth_uri.to_s,
|
211
|
+
:openstack_auth_token => @auth_token,
|
212
|
+
:openstack_management_url => @openstack_management_url,
|
213
|
+
:openstack_current_user_id => @openstack_current_user_id,
|
214
|
+
:current_user => @current_user,
|
215
|
+
:current_tenant => @current_tenant }
|
216
|
+
end
|
217
|
+
|
218
|
+
def reload
|
219
|
+
@connection.reset
|
220
|
+
end
|
221
|
+
|
222
|
+
def request(params)
|
223
|
+
retried = false
|
224
|
+
begin
|
225
|
+
response = @connection.request(params.merge({
|
226
|
+
:headers => {
|
227
|
+
'Content-Type' => 'application/json',
|
228
|
+
'Accept' => 'application/json',
|
229
|
+
'X-Auth-Token' => @auth_token
|
230
|
+
}.merge!(params[:headers] || {}),
|
231
|
+
:host => @host,
|
232
|
+
:path => "#{@path}/#{params[:path]}"#,
|
233
|
+
# Causes errors for some requests like tenants?limit=1
|
234
|
+
# :query => ('ignore_awful_caching' << Time.now.to_i.to_s)
|
235
|
+
}))
|
236
|
+
rescue Excon::Errors::Unauthorized => error
|
237
|
+
raise if retried
|
238
|
+
retried = true
|
239
|
+
|
240
|
+
@openstack_must_reauthenticate = true
|
241
|
+
authenticate
|
242
|
+
retry
|
243
|
+
rescue Excon::Errors::HTTPStatusError => error
|
244
|
+
raise case error
|
245
|
+
when Excon::Errors::NotFound
|
246
|
+
Fog::Identity::OpenStack::NotFound.slurp(error)
|
247
|
+
else
|
248
|
+
error
|
249
|
+
end
|
250
|
+
end
|
251
|
+
unless response.body.empty?
|
252
|
+
response.body = MultiJson.decode(response.body)
|
253
|
+
end
|
254
|
+
response
|
255
|
+
end
|
256
|
+
|
257
|
+
private
|
258
|
+
|
259
|
+
def authenticate
|
260
|
+
if !@openstack_management_url || @openstack_must_reauthenticate
|
261
|
+
options = {
|
262
|
+
:openstack_api_key => @openstack_api_key,
|
263
|
+
:openstack_username => @openstack_username,
|
264
|
+
:openstack_auth_token => @openstack_auth_token,
|
265
|
+
:openstack_auth_uri => @openstack_auth_uri,
|
266
|
+
:openstack_tenant => @openstack_tenant,
|
267
|
+
:openstack_service_type => @openstack_service_type,
|
268
|
+
:openstack_service_name => @openstack_service_name,
|
269
|
+
:openstack_endpoint_type => @openstack_endpoint_type
|
270
|
+
}
|
271
|
+
|
272
|
+
credentials = Fog::OpenStack.authenticate_v2(options, @connection_options)
|
273
|
+
|
274
|
+
@current_user = credentials[:user]
|
275
|
+
@current_tenant = credentials[:tenant]
|
276
|
+
|
277
|
+
@openstack_must_reauthenticate = false
|
278
|
+
@auth_token = credentials[:token]
|
279
|
+
@openstack_management_url = credentials[:server_management_url]
|
280
|
+
@openstack_current_user_id = credentials[:current_user_id]
|
281
|
+
@unscoped_token = credentials[:unscoped_token]
|
282
|
+
uri = URI.parse(@openstack_management_url)
|
283
|
+
else
|
284
|
+
@auth_token = @openstack_auth_token
|
285
|
+
uri = URI.parse(@openstack_management_url)
|
286
|
+
end
|
287
|
+
|
288
|
+
@host = uri.host
|
289
|
+
@path = uri.path
|
290
|
+
@path.sub!(/\/$/, '')
|
291
|
+
@port = uri.port
|
292
|
+
@scheme = uri.scheme
|
293
|
+
true
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
require 'fog/openstack'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Image
|
5
|
+
class OpenStack < Fog::Service
|
6
|
+
requires :openstack_auth_url
|
7
|
+
recognizes :openstack_auth_token, :openstack_management_url, :persistent,
|
8
|
+
:openstack_service_type, :openstack_service_name, :openstack_tenant,
|
9
|
+
:openstack_api_key, :openstack_username,
|
10
|
+
:current_user, :current_tenant, :openstack_endpoint_type, :openstack_region
|
11
|
+
|
12
|
+
model_path 'fog/openstack/models/image'
|
13
|
+
|
14
|
+
model :image
|
15
|
+
collection :images
|
16
|
+
|
17
|
+
request_path 'fog/openstack/requests/image'
|
18
|
+
|
19
|
+
request :list_public_images
|
20
|
+
request :list_public_images_detailed
|
21
|
+
request :get_image
|
22
|
+
request :create_image
|
23
|
+
request :update_image
|
24
|
+
request :get_image_members
|
25
|
+
request :update_image_members
|
26
|
+
request :get_shared_images
|
27
|
+
request :add_member_to_image
|
28
|
+
request :remove_member_from_image
|
29
|
+
request :delete_image
|
30
|
+
request :get_image_by_id
|
31
|
+
request :set_tenant
|
32
|
+
|
33
|
+
class Mock
|
34
|
+
def self.data
|
35
|
+
@data ||= Hash.new do |hash, key|
|
36
|
+
hash[key] = {
|
37
|
+
:images => {}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.reset
|
43
|
+
@data = nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize(options={})
|
47
|
+
require 'multi_json'
|
48
|
+
@openstack_username = options[:openstack_username]
|
49
|
+
@openstack_tenant = options[:openstack_tenant]
|
50
|
+
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
51
|
+
|
52
|
+
@auth_token = Fog::Mock.random_base64(64)
|
53
|
+
@auth_token_expiration = (Time.now.utc + 86400).iso8601
|
54
|
+
|
55
|
+
management_url = URI.parse(options[:openstack_auth_url])
|
56
|
+
management_url.port = 9292
|
57
|
+
management_url.path = '/v1'
|
58
|
+
@openstack_management_url = management_url.to_s
|
59
|
+
|
60
|
+
@data ||= { :users => {} }
|
61
|
+
unless @data[:users].find {|u| u['name'] == options[:openstack_username]}
|
62
|
+
id = Fog::Mock.random_numbers(6).to_s
|
63
|
+
@data[:users][id] = {
|
64
|
+
'id' => id,
|
65
|
+
'name' => options[:openstack_username],
|
66
|
+
'email' => "#{options[:openstack_username]}@mock.com",
|
67
|
+
'tenantId' => Fog::Mock.random_numbers(6).to_s,
|
68
|
+
'enabled' => true
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def data
|
74
|
+
self.class.data[@openstack_username]
|
75
|
+
end
|
76
|
+
|
77
|
+
def reset_data
|
78
|
+
self.class.data.delete(@openstack_username)
|
79
|
+
end
|
80
|
+
|
81
|
+
def credentials
|
82
|
+
{ :provider => 'openstack',
|
83
|
+
:openstack_auth_url => @openstack_auth_uri.to_s,
|
84
|
+
:openstack_auth_token => @auth_token,
|
85
|
+
:openstack_region => @openstack_region,
|
86
|
+
:openstack_management_url => @openstack_management_url }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class Real
|
91
|
+
attr_reader :current_user
|
92
|
+
attr_reader :current_tenant
|
93
|
+
|
94
|
+
def initialize(options={})
|
95
|
+
require 'multi_json'
|
96
|
+
|
97
|
+
@openstack_auth_token = options[:openstack_auth_token]
|
98
|
+
|
99
|
+
unless @openstack_auth_token
|
100
|
+
missing_credentials = Array.new
|
101
|
+
@openstack_api_key = options[:openstack_api_key]
|
102
|
+
@openstack_username = options[:openstack_username]
|
103
|
+
|
104
|
+
missing_credentials << :openstack_api_key unless @openstack_api_key
|
105
|
+
missing_credentials << :openstack_username unless @openstack_username
|
106
|
+
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
107
|
+
end
|
108
|
+
|
109
|
+
@openstack_tenant = options[:openstack_tenant]
|
110
|
+
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
111
|
+
@openstack_management_url = options[:openstack_management_url]
|
112
|
+
@openstack_must_reauthenticate = false
|
113
|
+
@openstack_service_type = options[:openstack_service_type] || ['image']
|
114
|
+
@openstack_service_name = options[:openstack_service_name]
|
115
|
+
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'
|
116
|
+
@openstack_region = options[:openstack_region]
|
117
|
+
|
118
|
+
@connection_options = options[:connection_options] || {}
|
119
|
+
|
120
|
+
@current_user = options[:current_user]
|
121
|
+
@current_tenant = options[:current_tenant]
|
122
|
+
|
123
|
+
authenticate
|
124
|
+
|
125
|
+
@persistent = options[:persistent] || false
|
126
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
127
|
+
end
|
128
|
+
|
129
|
+
def credentials
|
130
|
+
{ :provider => 'openstack',
|
131
|
+
:openstack_auth_url => @openstack_auth_uri.to_s,
|
132
|
+
:openstack_auth_token => @auth_token,
|
133
|
+
:openstack_management_url => @openstack_management_url,
|
134
|
+
:current_user => @current_user,
|
135
|
+
:current_tenant => @current_tenant }
|
136
|
+
end
|
137
|
+
|
138
|
+
def reload
|
139
|
+
@connection.reset
|
140
|
+
end
|
141
|
+
|
142
|
+
def request(params)
|
143
|
+
begin
|
144
|
+
response = @connection.request(params.merge({
|
145
|
+
:headers => {
|
146
|
+
'Content-Type' => 'application/json',
|
147
|
+
'X-Auth-Token' => @auth_token
|
148
|
+
}.merge!(params[:headers] || {}),
|
149
|
+
:host => @host,
|
150
|
+
:path => "#{@path}/#{params[:path]}"#,
|
151
|
+
# Causes errors for some requests like tenants?limit=1
|
152
|
+
# :query => ('ignore_awful_caching' << Time.now.to_i.to_s)
|
153
|
+
}))
|
154
|
+
rescue Excon::Errors::Unauthorized => error
|
155
|
+
if error.response.body != 'Bad username or password' # token expiration
|
156
|
+
@openstack_must_reauthenticate = true
|
157
|
+
authenticate
|
158
|
+
retry
|
159
|
+
else # bad credentials
|
160
|
+
raise error
|
161
|
+
end
|
162
|
+
rescue Excon::Errors::HTTPStatusError => error
|
163
|
+
raise case error
|
164
|
+
when Excon::Errors::NotFound
|
165
|
+
Fog::Compute::OpenStack::NotFound.slurp(error)
|
166
|
+
else
|
167
|
+
error
|
168
|
+
end
|
169
|
+
end
|
170
|
+
unless response.body.empty?
|
171
|
+
response.body = MultiJson.decode(response.body)
|
172
|
+
end
|
173
|
+
response
|
174
|
+
end
|
175
|
+
|
176
|
+
private
|
177
|
+
|
178
|
+
def authenticate
|
179
|
+
if !@openstack_management_url || @openstack_must_reauthenticate
|
180
|
+
options = {
|
181
|
+
:openstack_tenant => @openstack_tenant,
|
182
|
+
:openstack_api_key => @openstack_api_key,
|
183
|
+
:openstack_username => @openstack_username,
|
184
|
+
:openstack_auth_uri => @openstack_auth_uri,
|
185
|
+
:openstack_region => @openstack_region,
|
186
|
+
:openstack_auth_token => @openstack_auth_token,
|
187
|
+
:openstack_service_type => @openstack_service_type,
|
188
|
+
:openstack_service_name => @openstack_service_name,
|
189
|
+
:openstack_endpoint_type => @openstack_endpoint_type
|
190
|
+
}
|
191
|
+
|
192
|
+
credentials = Fog::OpenStack.authenticate_v2(options, @connection_options)
|
193
|
+
|
194
|
+
@current_user = credentials[:user]
|
195
|
+
@current_tenant = credentials[:tenant]
|
196
|
+
|
197
|
+
@openstack_must_reauthenticate = false
|
198
|
+
@auth_token = credentials[:token]
|
199
|
+
@openstack_management_url = credentials[:server_management_url]
|
200
|
+
uri = URI.parse(@openstack_management_url)
|
201
|
+
else
|
202
|
+
@auth_token = @openstack_auth_token
|
203
|
+
uri = URI.parse(@openstack_management_url)
|
204
|
+
end
|
205
|
+
|
206
|
+
@host = uri.host
|
207
|
+
@path = uri.path
|
208
|
+
@path.sub!(/\/$/, '')
|
209
|
+
@port = uri.port
|
210
|
+
@scheme = uri.scheme
|
211
|
+
true
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|