fog-google 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rubocop.yml +20 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +41 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +55 -0
- data/Rakefile +34 -0
- data/examples/backend_services.rb +22 -0
- data/examples/bootstrap.rb +9 -0
- data/examples/create.rb +49 -0
- data/examples/dns/project.rb +8 -0
- data/examples/dns/zones.rb +43 -0
- data/examples/eric-fail.rb +36 -0
- data/examples/get_list_images.rb +26 -0
- data/examples/get_list_snapshots.rb +18 -0
- data/examples/image_all.rb +6 -0
- data/examples/image_create.rb +17 -0
- data/examples/l7_load_balance.rb +73 -0
- data/examples/launch_micro_instance.rb +29 -0
- data/examples/load-balance.rb +98 -0
- data/examples/metadata.rb +30 -0
- data/examples/monitoring/metric_descriptors.rb +11 -0
- data/examples/monitoring/timeseries_collection.rb +15 -0
- data/examples/monitoring/timeseries_descriptors.rb +15 -0
- data/examples/network.rb +38 -0
- data/examples/precreated_client.rb +14 -0
- data/examples/sql/flags.rb +7 -0
- data/examples/sql/instances.rb +38 -0
- data/examples/sql/operations.rb +20 -0
- data/examples/sql/ssl_certs.rb +28 -0
- data/examples/sql/tiers.rb +7 -0
- data/fog-google.gemspec +37 -0
- data/gemfiles/Gemfile.1.9.2+ +6 -0
- data/gemfiles/Gemfile.1.9.2- +9 -0
- data/lib/fog/bin/google.rb +88 -0
- data/lib/fog/google.rb +226 -0
- data/lib/fog/google/compute.rb +1068 -0
- data/lib/fog/google/dns.rb +96 -0
- data/lib/fog/google/models/compute/address.rb +94 -0
- data/lib/fog/google/models/compute/addresses.rb +40 -0
- data/lib/fog/google/models/compute/backend_service.rb +92 -0
- data/lib/fog/google/models/compute/backend_services.rb +22 -0
- data/lib/fog/google/models/compute/disk.rb +120 -0
- data/lib/fog/google/models/compute/disk_type.rb +28 -0
- data/lib/fog/google/models/compute/disk_types.rb +40 -0
- data/lib/fog/google/models/compute/disks.rb +41 -0
- data/lib/fog/google/models/compute/firewall.rb +46 -0
- data/lib/fog/google/models/compute/firewalls.rb +25 -0
- data/lib/fog/google/models/compute/flavor.rb +33 -0
- data/lib/fog/google/models/compute/flavors.rb +31 -0
- data/lib/fog/google/models/compute/forwarding_rule.rb +86 -0
- data/lib/fog/google/models/compute/forwarding_rules.rb +41 -0
- data/lib/fog/google/models/compute/global_forwarding_rule.rb +86 -0
- data/lib/fog/google/models/compute/global_forwarding_rules.rb +23 -0
- data/lib/fog/google/models/compute/http_health_check.rb +84 -0
- data/lib/fog/google/models/compute/http_health_checks.rb +26 -0
- data/lib/fog/google/models/compute/image.rb +90 -0
- data/lib/fog/google/models/compute/images.rb +73 -0
- data/lib/fog/google/models/compute/network.rb +43 -0
- data/lib/fog/google/models/compute/networks.rb +25 -0
- data/lib/fog/google/models/compute/operation.rb +75 -0
- data/lib/fog/google/models/compute/operations.rb +37 -0
- data/lib/fog/google/models/compute/project.rb +30 -0
- data/lib/fog/google/models/compute/projects.rb +20 -0
- data/lib/fog/google/models/compute/region.rb +32 -0
- data/lib/fog/google/models/compute/regions.rb +25 -0
- data/lib/fog/google/models/compute/resource_view.rb +116 -0
- data/lib/fog/google/models/compute/resource_views.rb +57 -0
- data/lib/fog/google/models/compute/route.rb +50 -0
- data/lib/fog/google/models/compute/routes.rb +25 -0
- data/lib/fog/google/models/compute/server.rb +258 -0
- data/lib/fog/google/models/compute/servers.rb +80 -0
- data/lib/fog/google/models/compute/snapshot.rb +48 -0
- data/lib/fog/google/models/compute/snapshots.rb +26 -0
- data/lib/fog/google/models/compute/target_http_proxies.rb +22 -0
- data/lib/fog/google/models/compute/target_http_proxy.rb +75 -0
- data/lib/fog/google/models/compute/target_instance.rb +74 -0
- data/lib/fog/google/models/compute/target_instances.rb +28 -0
- data/lib/fog/google/models/compute/target_pool.rb +113 -0
- data/lib/fog/google/models/compute/target_pools.rb +41 -0
- data/lib/fog/google/models/compute/url_map.rb +95 -0
- data/lib/fog/google/models/compute/url_maps.rb +22 -0
- data/lib/fog/google/models/compute/zone.rb +23 -0
- data/lib/fog/google/models/compute/zones.rb +24 -0
- data/lib/fog/google/models/dns/change.rb +40 -0
- data/lib/fog/google/models/dns/changes.rb +52 -0
- data/lib/fog/google/models/dns/project.rb +75 -0
- data/lib/fog/google/models/dns/projects.rb +25 -0
- data/lib/fog/google/models/dns/record.rb +112 -0
- data/lib/fog/google/models/dns/records.rb +52 -0
- data/lib/fog/google/models/dns/zone.rb +74 -0
- data/lib/fog/google/models/dns/zones.rb +34 -0
- data/lib/fog/google/models/monitoring/metric_descriptor.rb +20 -0
- data/lib/fog/google/models/monitoring/metric_descriptors.rb +28 -0
- data/lib/fog/google/models/monitoring/timeseries.rb +17 -0
- data/lib/fog/google/models/monitoring/timeseries_collection.rb +31 -0
- data/lib/fog/google/models/monitoring/timeseries_descriptor.rb +20 -0
- data/lib/fog/google/models/monitoring/timeseries_descriptors.rb +31 -0
- data/lib/fog/google/models/sql/backup_run.rb +34 -0
- data/lib/fog/google/models/sql/backup_runs.rb +38 -0
- data/lib/fog/google/models/sql/flag.rb +22 -0
- data/lib/fog/google/models/sql/flags.rb +21 -0
- data/lib/fog/google/models/sql/instance.rb +353 -0
- data/lib/fog/google/models/sql/instances.rb +39 -0
- data/lib/fog/google/models/sql/operation.rb +61 -0
- data/lib/fog/google/models/sql/operations.rb +49 -0
- data/lib/fog/google/models/sql/ssl_cert.rb +73 -0
- data/lib/fog/google/models/sql/ssl_certs.rb +49 -0
- data/lib/fog/google/models/sql/tier.rb +20 -0
- data/lib/fog/google/models/sql/tiers.rb +21 -0
- data/lib/fog/google/models/storage/directories.rb +39 -0
- data/lib/fog/google/models/storage/directory.rb +74 -0
- data/lib/fog/google/models/storage/file.rb +144 -0
- data/lib/fog/google/models/storage/files.rb +104 -0
- data/lib/fog/google/monitoring.rb +87 -0
- data/lib/fog/google/parsers/storage/access_control_list.rb +44 -0
- data/lib/fog/google/parsers/storage/copy_object.rb +18 -0
- data/lib/fog/google/parsers/storage/get_bucket.rb +58 -0
- data/lib/fog/google/parsers/storage/get_bucket_logging.rb +36 -0
- data/lib/fog/google/parsers/storage/get_bucket_object_versions.rb +84 -0
- data/lib/fog/google/parsers/storage/get_bucket_versioning.rb +20 -0
- data/lib/fog/google/parsers/storage/get_request_payment.rb +16 -0
- data/lib/fog/google/parsers/storage/get_service.rb +28 -0
- data/lib/fog/google/requests/compute/add_backend_service_backends.rb +29 -0
- data/lib/fog/google/requests/compute/add_region_view_resources.rb +27 -0
- data/lib/fog/google/requests/compute/add_server_access_config.rb +32 -0
- data/lib/fog/google/requests/compute/add_target_pool_health_checks.rb +27 -0
- data/lib/fog/google/requests/compute/add_target_pool_instances.rb +27 -0
- data/lib/fog/google/requests/compute/add_url_map_host_rules.rb +25 -0
- data/lib/fog/google/requests/compute/add_url_map_path_matchers.rb +29 -0
- data/lib/fog/google/requests/compute/add_zone_view_resources.rb +27 -0
- data/lib/fog/google/requests/compute/attach_disk.rb +34 -0
- data/lib/fog/google/requests/compute/delete_address.rb +24 -0
- data/lib/fog/google/requests/compute/delete_backend_service.rb +43 -0
- data/lib/fog/google/requests/compute/delete_disk.rb +48 -0
- data/lib/fog/google/requests/compute/delete_firewall.rb +23 -0
- data/lib/fog/google/requests/compute/delete_forwarding_rule.rb +49 -0
- data/lib/fog/google/requests/compute/delete_global_forwarding_rule.rb +48 -0
- data/lib/fog/google/requests/compute/delete_global_operation.rb +25 -0
- data/lib/fog/google/requests/compute/delete_http_health_check.rb +41 -0
- data/lib/fog/google/requests/compute/delete_image.rb +42 -0
- data/lib/fog/google/requests/compute/delete_network.rb +23 -0
- data/lib/fog/google/requests/compute/delete_region_operation.rb +29 -0
- data/lib/fog/google/requests/compute/delete_region_view.rb +24 -0
- data/lib/fog/google/requests/compute/delete_route.rb +23 -0
- data/lib/fog/google/requests/compute/delete_server.rb +69 -0
- data/lib/fog/google/requests/compute/delete_server_access_config.rb +26 -0
- data/lib/fog/google/requests/compute/delete_snapshot.rb +23 -0
- data/lib/fog/google/requests/compute/delete_target_http_proxy.rb +43 -0
- data/lib/fog/google/requests/compute/delete_target_instance.rb +48 -0
- data/lib/fog/google/requests/compute/delete_target_pool.rb +49 -0
- data/lib/fog/google/requests/compute/delete_url_map.rb +43 -0
- data/lib/fog/google/requests/compute/delete_zone_operation.rb +29 -0
- data/lib/fog/google/requests/compute/delete_zone_view.rb +24 -0
- data/lib/fog/google/requests/compute/detach_disk.rb +25 -0
- data/lib/fog/google/requests/compute/get_address.rb +24 -0
- data/lib/fog/google/requests/compute/get_backend_service.rb +26 -0
- data/lib/fog/google/requests/compute/get_backend_service_health.rb +27 -0
- data/lib/fog/google/requests/compute/get_backend_services.rb +23 -0
- data/lib/fog/google/requests/compute/get_disk.rb +52 -0
- data/lib/fog/google/requests/compute/get_disk_type.rb +42 -0
- data/lib/fog/google/requests/compute/get_firewall.rb +23 -0
- data/lib/fog/google/requests/compute/get_forwarding_rule.rb +46 -0
- data/lib/fog/google/requests/compute/get_global_forwarding_rule.rb +32 -0
- data/lib/fog/google/requests/compute/get_global_operation.rb +50 -0
- data/lib/fog/google/requests/compute/get_http_health_check.rb +39 -0
- data/lib/fog/google/requests/compute/get_image.rb +36 -0
- data/lib/fog/google/requests/compute/get_machine_type.rb +43 -0
- data/lib/fog/google/requests/compute/get_network.rb +23 -0
- data/lib/fog/google/requests/compute/get_project.rb +22 -0
- data/lib/fog/google/requests/compute/get_region.rb +37 -0
- data/lib/fog/google/requests/compute/get_region_operation.rb +55 -0
- data/lib/fog/google/requests/compute/get_region_view.rb +24 -0
- data/lib/fog/google/requests/compute/get_route.rb +23 -0
- data/lib/fog/google/requests/compute/get_server.rb +75 -0
- data/lib/fog/google/requests/compute/get_server_serial_port_output.rb +24 -0
- data/lib/fog/google/requests/compute/get_snapshot.rb +27 -0
- data/lib/fog/google/requests/compute/get_target_http_proxy.rb +27 -0
- data/lib/fog/google/requests/compute/get_target_instance.rb +32 -0
- data/lib/fog/google/requests/compute/get_target_pool.rb +40 -0
- data/lib/fog/google/requests/compute/get_target_pool_health.rb +29 -0
- data/lib/fog/google/requests/compute/get_url_map.rb +27 -0
- data/lib/fog/google/requests/compute/get_zone.rb +36 -0
- data/lib/fog/google/requests/compute/get_zone_operation.rb +55 -0
- data/lib/fog/google/requests/compute/get_zone_view.rb +24 -0
- data/lib/fog/google/requests/compute/insert_address.rb +25 -0
- data/lib/fog/google/requests/compute/insert_backend_service.rb +63 -0
- data/lib/fog/google/requests/compute/insert_disk.rb +113 -0
- data/lib/fog/google/requests/compute/insert_firewall.rb +43 -0
- data/lib/fog/google/requests/compute/insert_forwarding_rule.rb +60 -0
- data/lib/fog/google/requests/compute/insert_global_forwarding_rule.rb +56 -0
- data/lib/fog/google/requests/compute/insert_http_health_check.rb +59 -0
- data/lib/fog/google/requests/compute/insert_image.rb +64 -0
- data/lib/fog/google/requests/compute/insert_network.rb +29 -0
- data/lib/fog/google/requests/compute/insert_region_view.rb +25 -0
- data/lib/fog/google/requests/compute/insert_route.rb +35 -0
- data/lib/fog/google/requests/compute/insert_server.rb +191 -0
- data/lib/fog/google/requests/compute/insert_snapshot.rb +40 -0
- data/lib/fog/google/requests/compute/insert_target_http_proxy.rb +52 -0
- data/lib/fog/google/requests/compute/insert_target_instance.rb +55 -0
- data/lib/fog/google/requests/compute/insert_target_pool.rb +58 -0
- data/lib/fog/google/requests/compute/insert_url_map.rb +55 -0
- data/lib/fog/google/requests/compute/insert_zone_view.rb +27 -0
- data/lib/fog/google/requests/compute/list_addresses.rb +23 -0
- data/lib/fog/google/requests/compute/list_aggregated_addresses.rb +23 -0
- data/lib/fog/google/requests/compute/list_aggregated_disk_types.rb +40 -0
- data/lib/fog/google/requests/compute/list_aggregated_disks.rb +40 -0
- data/lib/fog/google/requests/compute/list_aggregated_machine_types.rb +22 -0
- data/lib/fog/google/requests/compute/list_aggregated_servers.rb +40 -0
- data/lib/fog/google/requests/compute/list_backend_services.rb +29 -0
- data/lib/fog/google/requests/compute/list_disk_types.rb +46 -0
- data/lib/fog/google/requests/compute/list_disks.rb +29 -0
- data/lib/fog/google/requests/compute/list_firewalls.rb +22 -0
- data/lib/fog/google/requests/compute/list_forwarding_rules.rb +29 -0
- data/lib/fog/google/requests/compute/list_global_forwarding_rules.rb +30 -0
- data/lib/fog/google/requests/compute/list_global_operations.rb +24 -0
- data/lib/fog/google/requests/compute/list_http_health_checks.rb +29 -0
- data/lib/fog/google/requests/compute/list_images.rb +29 -0
- data/lib/fog/google/requests/compute/list_machine_types.rb +30 -0
- data/lib/fog/google/requests/compute/list_networks.rb +22 -0
- data/lib/fog/google/requests/compute/list_region_operations.rb +25 -0
- data/lib/fog/google/requests/compute/list_region_view_resources.rb +25 -0
- data/lib/fog/google/requests/compute/list_region_views.rb +23 -0
- data/lib/fog/google/requests/compute/list_regions.rb +85 -0
- data/lib/fog/google/requests/compute/list_routes.rb +22 -0
- data/lib/fog/google/requests/compute/list_servers.rb +31 -0
- data/lib/fog/google/requests/compute/list_snapshots.rb +23 -0
- data/lib/fog/google/requests/compute/list_target_http_proxies.rb +30 -0
- data/lib/fog/google/requests/compute/list_target_instances.rb +30 -0
- data/lib/fog/google/requests/compute/list_target_pools.rb +29 -0
- data/lib/fog/google/requests/compute/list_url_maps.rb +29 -0
- data/lib/fog/google/requests/compute/list_zone_operations.rb +25 -0
- data/lib/fog/google/requests/compute/list_zone_view_resources.rb +25 -0
- data/lib/fog/google/requests/compute/list_zone_views.rb +23 -0
- data/lib/fog/google/requests/compute/list_zones.rb +28 -0
- data/lib/fog/google/requests/compute/remove_target_pool_health_checks.rb +27 -0
- data/lib/fog/google/requests/compute/remove_target_pool_instance.rb +27 -0
- data/lib/fog/google/requests/compute/remove_target_pool_instances.rb +27 -0
- data/lib/fog/google/requests/compute/reset_server.rb +24 -0
- data/lib/fog/google/requests/compute/set_common_instance_metadata.rb +26 -0
- data/lib/fog/google/requests/compute/set_forwarding_rule_target.rb +27 -0
- data/lib/fog/google/requests/compute/set_global_forwarding_rule_target.rb +27 -0
- data/lib/fog/google/requests/compute/set_metadata.rb +39 -0
- data/lib/fog/google/requests/compute/set_server_disk_auto_delete.rb +26 -0
- data/lib/fog/google/requests/compute/set_server_scheduling.rb +29 -0
- data/lib/fog/google/requests/compute/set_tags.rb +24 -0
- data/lib/fog/google/requests/compute/set_target_http_proxy_url_map.rb +27 -0
- data/lib/fog/google/requests/compute/start_server.rb +24 -0
- data/lib/fog/google/requests/compute/stop_server.rb +24 -0
- data/lib/fog/google/requests/compute/update_url_map.rb +39 -0
- data/lib/fog/google/requests/compute/validate_url_map.rb +24 -0
- data/lib/fog/google/requests/dns/create_change.rb +64 -0
- data/lib/fog/google/requests/dns/create_managed_zone.rb +82 -0
- data/lib/fog/google/requests/dns/delete_managed_zone.rb +35 -0
- data/lib/fog/google/requests/dns/get_change.rb +42 -0
- data/lib/fog/google/requests/dns/get_managed_zone.rb +37 -0
- data/lib/fog/google/requests/dns/get_project.rb +42 -0
- data/lib/fog/google/requests/dns/list_changes.rb +41 -0
- data/lib/fog/google/requests/dns/list_managed_zones.rb +31 -0
- data/lib/fog/google/requests/dns/list_resource_record_sets.rb +50 -0
- data/lib/fog/google/requests/monitoring/list_metric_descriptors.rb +191 -0
- data/lib/fog/google/requests/monitoring/list_timeseries.rb +68 -0
- data/lib/fog/google/requests/monitoring/list_timeseries_descriptors.rb +87 -0
- data/lib/fog/google/requests/sql/clone_instance.rb +84 -0
- data/lib/fog/google/requests/sql/delete_instance.rb +67 -0
- data/lib/fog/google/requests/sql/delete_ssl_cert.rb +68 -0
- data/lib/fog/google/requests/sql/export_instance.rb +56 -0
- data/lib/fog/google/requests/sql/get_backup_run.rb +30 -0
- data/lib/fog/google/requests/sql/get_instance.rb +48 -0
- data/lib/fog/google/requests/sql/get_operation.rb +66 -0
- data/lib/fog/google/requests/sql/get_ssl_cert.rb +66 -0
- data/lib/fog/google/requests/sql/import_instance.rb +55 -0
- data/lib/fog/google/requests/sql/insert_instance.rb +165 -0
- data/lib/fog/google/requests/sql/insert_ssl_cert.rb +80 -0
- data/lib/fog/google/requests/sql/list_backup_runs.rb +30 -0
- data/lib/fog/google/requests/sql/list_flags.rb +143 -0
- data/lib/fog/google/requests/sql/list_instances.rb +32 -0
- data/lib/fog/google/requests/sql/list_operations.rb +52 -0
- data/lib/fog/google/requests/sql/list_ssl_certs.rb +51 -0
- data/lib/fog/google/requests/sql/list_tiers.rb +82 -0
- data/lib/fog/google/requests/sql/reset_instance_ssl_config.rb +49 -0
- data/lib/fog/google/requests/sql/restart_instance.rb +47 -0
- data/lib/fog/google/requests/sql/restore_instance_backup.rb +30 -0
- data/lib/fog/google/requests/sql/set_instance_root_password.rb +54 -0
- data/lib/fog/google/requests/sql/update_instance.rb +132 -0
- data/lib/fog/google/requests/storage/copy_object.rb +68 -0
- data/lib/fog/google/requests/storage/delete_bucket.rb +41 -0
- data/lib/fog/google/requests/storage/delete_object.rb +46 -0
- data/lib/fog/google/requests/storage/get_bucket.rb +106 -0
- data/lib/fog/google/requests/storage/get_bucket_acl.rb +59 -0
- data/lib/fog/google/requests/storage/get_object.rb +108 -0
- data/lib/fog/google/requests/storage/get_object_acl.rb +70 -0
- data/lib/fog/google/requests/storage/get_object_http_url.rb +44 -0
- data/lib/fog/google/requests/storage/get_object_https_url.rb +44 -0
- data/lib/fog/google/requests/storage/get_object_torrent.rb +45 -0
- data/lib/fog/google/requests/storage/get_object_url.rb +33 -0
- data/lib/fog/google/requests/storage/get_service.rb +48 -0
- data/lib/fog/google/requests/storage/head_object.rb +60 -0
- data/lib/fog/google/requests/storage/put_bucket.rb +71 -0
- data/lib/fog/google/requests/storage/put_bucket_acl.rb +58 -0
- data/lib/fog/google/requests/storage/put_object.rb +89 -0
- data/lib/fog/google/requests/storage/put_object_acl.rb +51 -0
- data/lib/fog/google/requests/storage/put_object_url.rb +50 -0
- data/lib/fog/google/sql.rb +130 -0
- data/lib/fog/google/storage.rb +298 -0
- data/lib/fog/google/version.rb +5 -0
- data/spec/minitest_helper.rb +31 -0
- data/tests/credentials_tests.rb +73 -0
- data/tests/helper.rb +126 -0
- data/tests/helpers/collection_helper.rb +97 -0
- data/tests/helpers/compute/flavors_helper.rb +32 -0
- data/tests/helpers/compute/server_helper.rb +25 -0
- data/tests/helpers/compute/servers_helper.rb +10 -0
- data/tests/helpers/formats_helper.rb +98 -0
- data/tests/helpers/formats_helper_tests.rb +110 -0
- data/tests/helpers/mock_helper.rb +18 -0
- data/tests/helpers/model_helper.rb +31 -0
- data/tests/helpers/responds_to_helper.rb +11 -0
- data/tests/helpers/schema_validator_tests.rb +107 -0
- data/tests/helpers/succeeds_helper.rb +9 -0
- data/tests/lorem.txt +1 -0
- data/tests/models/compute/backend_service_tests.rb +6 -0
- data/tests/models/compute/backend_services_tests.rb +8 -0
- data/tests/models/compute/disk_tests.rb +9 -0
- data/tests/models/compute/disk_types_tests.rb +22 -0
- data/tests/models/compute/disks_tests.rb +9 -0
- data/tests/models/compute/forwarding_rule_tests.rb +8 -0
- data/tests/models/compute/forwarding_rules_tests.rb +8 -0
- data/tests/models/compute/global_forwarding_rule_tests.rb +7 -0
- data/tests/models/compute/global_forwarding_rules_tests.rb +7 -0
- data/tests/models/compute/http_health_check_tests.rb +5 -0
- data/tests/models/compute/http_health_checks_tests.rb +5 -0
- data/tests/models/compute/image_tests.rb +6 -0
- data/tests/models/compute/images_tests.rb +6 -0
- data/tests/models/compute/region_tests.rb +10 -0
- data/tests/models/compute/regions_tests.rb +19 -0
- data/tests/models/compute/server_tests.rb +37 -0
- data/tests/models/compute/servers_tests.rb +14 -0
- data/tests/models/compute/target_http_proxies_tests.rb +7 -0
- data/tests/models/compute/target_http_proxy_test.rb +6 -0
- data/tests/models/compute/target_instance_tests.rb +7 -0
- data/tests/models/compute/target_instances_tests.rb +7 -0
- data/tests/models/compute/target_pool_tests.rb +12 -0
- data/tests/models/compute/target_pools_tests.rb +11 -0
- data/tests/models/compute/url_map_tests.rb +6 -0
- data/tests/models/compute/url_maps_tests.rb +7 -0
- data/tests/models/dns/change_tests.rb +28 -0
- data/tests/models/dns/changes_tests.rb +36 -0
- data/tests/models/dns/projects_tests.rb +12 -0
- data/tests/models/dns/record_tests.rb +42 -0
- data/tests/models/dns/records_tests.rb +36 -0
- data/tests/models/dns/zone_tests.rb +28 -0
- data/tests/models/dns/zones_tests.rb +14 -0
- data/tests/models/monitoring/metric_descriptors_tests.rb +12 -0
- data/tests/models/monitoring/timeseries_collection_tests.rb +12 -0
- data/tests/models/monitoring/timeseries_descriptors_tests.rb +13 -0
- data/tests/models/sql/flags_tests.rb +12 -0
- data/tests/models/sql/instance_tests.rb +56 -0
- data/tests/models/sql/instances_tests.rb +32 -0
- data/tests/models/sql/operation_tests.rb +25 -0
- data/tests/models/sql/operations_tests.rb +38 -0
- data/tests/models/sql/ssl_cert_tests.rb +24 -0
- data/tests/models/sql/ssl_certs_tests.rb +39 -0
- data/tests/models/sql/tiers_tests.rb +12 -0
- data/tests/requests/compute/backend_service_tests.rb +83 -0
- data/tests/requests/compute/disk_tests.rb +74 -0
- data/tests/requests/compute/disk_type_tests.rb +45 -0
- data/tests/requests/compute/firewall_tests.rb +88 -0
- data/tests/requests/compute/forwarding_rules_tests.rb +83 -0
- data/tests/requests/compute/global_forwarding_rules_tests.rb +83 -0
- data/tests/requests/compute/http_health_checks_tests.rb +83 -0
- data/tests/requests/compute/image_tests.rb +83 -0
- data/tests/requests/compute/network_tests.rb +75 -0
- data/tests/requests/compute/operation_tests.rb +20 -0
- data/tests/requests/compute/region_tests.rb +39 -0
- data/tests/requests/compute/server_tests.rb +84 -0
- data/tests/requests/compute/target_http_proxies_test.rb +79 -0
- data/tests/requests/compute/target_instances_tests.rb +83 -0
- data/tests/requests/compute/target_pools_tests.rb +82 -0
- data/tests/requests/compute/url_maps_tests.rb +82 -0
- data/tests/requests/compute/zone_tests.rb +37 -0
- data/tests/requests/dns/change_tests.rb +86 -0
- data/tests/requests/dns/managed_zone_tests.rb +66 -0
- data/tests/requests/dns/project_tests.rb +29 -0
- data/tests/requests/dns/record_tests.rb +49 -0
- data/tests/requests/monitoring/metric_descriptor_tests.rb +25 -0
- data/tests/requests/monitoring/timeseries_collection_tests.rb +25 -0
- data/tests/requests/monitoring/timeseries_descriptor_tests.rb +26 -0
- data/tests/requests/sql/flag_tests.rb +27 -0
- data/tests/requests/sql/instance_tests.rb +129 -0
- data/tests/requests/sql/operation_tests.rb +42 -0
- data/tests/requests/sql/ssl_cert_tests.rb +61 -0
- data/tests/requests/sql/tier_tests.rb +25 -0
- data/tests/requests/storage/bucket_tests.rb +77 -0
- data/tests/requests/storage/object_tests.rb +84 -0
- metadata +625 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/google/models/compute/operation'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Google
|
7
|
+
class Operations < Fog::Collection
|
8
|
+
model Fog::Compute::Google::Operation
|
9
|
+
|
10
|
+
def all(filters = {})
|
11
|
+
if filters['zone']
|
12
|
+
data = service.list_zone_operations(filters['zone']).body
|
13
|
+
elsif filters['region']
|
14
|
+
data = service.list_region_operations(filters['region']).body
|
15
|
+
else
|
16
|
+
data = service.list_global_operations.body
|
17
|
+
end
|
18
|
+
load(data['items'] || [])
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(identity, zone=nil, region=nil)
|
22
|
+
if not zone.nil?
|
23
|
+
response = service.get_zone_operation(zone, identity)
|
24
|
+
elsif not region.nil?
|
25
|
+
response = service.get_region_operation(region, identity)
|
26
|
+
else
|
27
|
+
response = service.get_global_operation(identity)
|
28
|
+
end
|
29
|
+
return nil if response.nil?
|
30
|
+
new(response.body)
|
31
|
+
rescue Fog::Errors::NotFound
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Google
|
6
|
+
##
|
7
|
+
# Represents a Project resource
|
8
|
+
#
|
9
|
+
# @see https://developers.google.com/compute/docs/reference/latest/projects
|
10
|
+
class Project < Fog::Model
|
11
|
+
identity :name
|
12
|
+
|
13
|
+
attribute :kind
|
14
|
+
attribute :id
|
15
|
+
attribute :common_instance_metadata, :aliases => 'commonInstanceMetadata'
|
16
|
+
attribute :creation_timestamp, :aliases => 'creationTimestamp'
|
17
|
+
attribute :description
|
18
|
+
attribute :quotas
|
19
|
+
attribute :self_link, :aliases => 'selfLink'
|
20
|
+
|
21
|
+
def set_metadata(metadata = {})
|
22
|
+
requires :identity
|
23
|
+
|
24
|
+
data = service.set_common_instance_metadata(identity, self.common_instance_metadata['fingerprint'], metadata)
|
25
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/google/models/compute/project'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Google
|
7
|
+
class Projects < Fog::Collection
|
8
|
+
model Fog::Compute::Google::Project
|
9
|
+
|
10
|
+
def get(identity)
|
11
|
+
if project = service.get_project(identity).body
|
12
|
+
new(project)
|
13
|
+
end
|
14
|
+
rescue Fog::Errors::NotFound
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Google
|
6
|
+
##
|
7
|
+
# Represents a Region resource
|
8
|
+
#
|
9
|
+
# @see https://developers.google.com/compute/docs/reference/latest/regions
|
10
|
+
class Region < Fog::Model
|
11
|
+
identity :name
|
12
|
+
|
13
|
+
attribute :kind
|
14
|
+
attribute :id
|
15
|
+
attribute :creation_timestamp, :aliases => 'creationTimestamp'
|
16
|
+
attribute :deprecated
|
17
|
+
attribute :description
|
18
|
+
attribute :quotas
|
19
|
+
attribute :self_link, :aliases => 'selfLink'
|
20
|
+
attribute :status
|
21
|
+
attribute :zones
|
22
|
+
|
23
|
+
DOWN_STATE = 'DOWN'
|
24
|
+
UP_STATE = 'UP'
|
25
|
+
|
26
|
+
def up?
|
27
|
+
self.status == UP_STATE
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/google/models/compute/region'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Google
|
7
|
+
class Regions < Fog::Collection
|
8
|
+
model Fog::Compute::Google::Region
|
9
|
+
|
10
|
+
def all
|
11
|
+
data = service.list_regions.body
|
12
|
+
load(data['items'] || [])
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(identity)
|
16
|
+
if region = service.get_region(identity).body
|
17
|
+
new(region)
|
18
|
+
end
|
19
|
+
rescue Fog::Errors::NotFound
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
# the resource view model creates either a region view or zone view depending on which is parameter is passed
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Google
|
7
|
+
class ResourceView < Fog::Model
|
8
|
+
identity :name
|
9
|
+
|
10
|
+
attribute :kind, :aliases => 'kind'
|
11
|
+
attribute :self_link, :aliases => 'selfLink'
|
12
|
+
attribute :id, :aliases => 'id'
|
13
|
+
attribute :creation_timestamp, :aliases => 'creationTimestamp'
|
14
|
+
attribute :description, :aliases => 'description'
|
15
|
+
attribute :region, :aliases => "region" # string, required for region views
|
16
|
+
attribute :labels, :aliases => "labels" # array of hashes including 'key' and 'value' as keys
|
17
|
+
attribute :zone, :aliases => "zone" # string, required for zone views
|
18
|
+
attribute :last_modified, :aliases => "lastModified"
|
19
|
+
attribute :members, :aliases => "members" # array of members of resource view
|
20
|
+
attribute :num_members, :aliases => "numMemebers" # integer
|
21
|
+
|
22
|
+
def save
|
23
|
+
requires :name
|
24
|
+
labels ||= []
|
25
|
+
members ||= []
|
26
|
+
|
27
|
+
if region then
|
28
|
+
options = {
|
29
|
+
'description' => description,
|
30
|
+
'labels' => labels,
|
31
|
+
'lastModified' => last_modified,
|
32
|
+
'members' => members,
|
33
|
+
'numMembers' => num_members
|
34
|
+
}
|
35
|
+
@region = region
|
36
|
+
data = service.insert_region_view(name, region, options).body
|
37
|
+
operation = service.get_region_view(data['resource']['name'],nil, @region).body
|
38
|
+
end
|
39
|
+
|
40
|
+
if zone then
|
41
|
+
options = {
|
42
|
+
'description' => description,
|
43
|
+
'labels' => labels,
|
44
|
+
'lastModified' => last_modified,
|
45
|
+
'members' => members,
|
46
|
+
'numMembers' => num_members
|
47
|
+
}
|
48
|
+
@zone = zone
|
49
|
+
data = service.insert_zone_view(name, zone, options).body
|
50
|
+
operation = service.get_zone_view(data['resource']['name'], @zone).body
|
51
|
+
end
|
52
|
+
reload
|
53
|
+
end
|
54
|
+
|
55
|
+
def destroy(async=false)
|
56
|
+
requires :name
|
57
|
+
# parse the self link to get the zone or region
|
58
|
+
selflink = self.self_link.split('/')
|
59
|
+
if selflink[7]=='regions' then
|
60
|
+
operation = service.delete_region_view(name, selflink[8])
|
61
|
+
end
|
62
|
+
|
63
|
+
if selflink[7]== 'zones' then
|
64
|
+
operation= service.delete_zone_view(name, selflink[8])
|
65
|
+
end
|
66
|
+
|
67
|
+
if not async
|
68
|
+
# wait until "DONE" to ensure the operation doesn't fail, raises
|
69
|
+
# exception on error
|
70
|
+
Fog.wait_for do
|
71
|
+
operation.body == nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
operation
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_resources resources
|
78
|
+
resources = [resources] unless resources.class == Array
|
79
|
+
resources.map { |resource| resource.class == String ? resource : resource.self_link }
|
80
|
+
if @zone then
|
81
|
+
service.add_zone_view_resources(self, resources, @zone)
|
82
|
+
end
|
83
|
+
if @region then
|
84
|
+
service.add_region_view_resources(self, reources, @region)
|
85
|
+
end
|
86
|
+
reload
|
87
|
+
end
|
88
|
+
|
89
|
+
def ready?
|
90
|
+
begin
|
91
|
+
if @zone then service.get_zone_view(self.name, @zone) end
|
92
|
+
if @region then service.get_region_view(self.name, @region) end
|
93
|
+
true
|
94
|
+
rescue Fog::Errors::NotFound
|
95
|
+
false
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def reload
|
100
|
+
requires :name
|
101
|
+
|
102
|
+
return unless data = begin
|
103
|
+
collection.get(name, region, zone)
|
104
|
+
rescue Excon::Errors::SocketError
|
105
|
+
nil
|
106
|
+
end
|
107
|
+
|
108
|
+
new_attributes = data.attributes
|
109
|
+
merge_attributes(new_attributes)
|
110
|
+
self
|
111
|
+
end
|
112
|
+
RUNNING_STATE = "READY"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/google/models/compute/resource_view'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Google
|
7
|
+
class ResourceViews < Fog::Collection
|
8
|
+
model Fog::Compute::Google::ResourceView
|
9
|
+
|
10
|
+
def all(filters={})
|
11
|
+
if fliters['region'].nil? && filters['zone'].nil?
|
12
|
+
data = []
|
13
|
+
service.list_regions.body['items'].each do |region|
|
14
|
+
data += service.list_region_views(region['name']).body['items'] || []
|
15
|
+
end
|
16
|
+
service.list_zones.body['items'].each do |zone|
|
17
|
+
data += service.list_zone_views(zone['name']).body['items'] || []
|
18
|
+
end
|
19
|
+
elsif filters['zone']
|
20
|
+
data = service.list_zone_views(fliters['zone']).body['items'] || []
|
21
|
+
else
|
22
|
+
data = service.list_region_views(filters['region']).body['items'] || []
|
23
|
+
end
|
24
|
+
load(data)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get(identity, region=nil, zone=nil)
|
28
|
+
response = nil
|
29
|
+
|
30
|
+
if region.nil? & zone.nil?
|
31
|
+
service.list_regions.body['items'].each do |region|
|
32
|
+
begin
|
33
|
+
response = service.get_region_view(identity, region['name'])
|
34
|
+
break if response.status == 200
|
35
|
+
rescue Fog::Errors::Error
|
36
|
+
end
|
37
|
+
end
|
38
|
+
service.list_zones.body['items'].each do |zone|
|
39
|
+
begin
|
40
|
+
response = service.get_zone_view(identity, zone['name'])
|
41
|
+
break if response.status == 200
|
42
|
+
rescue Fog::Errors::Error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
elsif region
|
46
|
+
response = service.get_region_view(identity, region)
|
47
|
+
else
|
48
|
+
response = service.get_zone_view(identity, zone)
|
49
|
+
end
|
50
|
+
|
51
|
+
return nil if response.nil?
|
52
|
+
new(response.body)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Google
|
6
|
+
##
|
7
|
+
# Represents a Route resource
|
8
|
+
#
|
9
|
+
# @see https://developers.google.com/compute/docs/reference/latest/routes
|
10
|
+
class Route < Fog::Model
|
11
|
+
identity :name
|
12
|
+
|
13
|
+
attribute :kind
|
14
|
+
attribute :id
|
15
|
+
attribute :creation_timestamp, :aliases => 'creationTimestamp'
|
16
|
+
attribute :description
|
17
|
+
attribute :dest_range, :aliases => 'destRange'
|
18
|
+
attribute :network
|
19
|
+
attribute :next_hop_gateway, :aliases => 'nextHopGateway'
|
20
|
+
attribute :next_hop_instance, :aliases => 'nextHopInstance'
|
21
|
+
attribute :next_hop_ip, :aliases => 'nextHopIp'
|
22
|
+
attribute :next_hop_network, :aliases => 'nextHopNetwork'
|
23
|
+
attribute :priority
|
24
|
+
attribute :self_link, :aliases => 'selfLink'
|
25
|
+
attribute :tags
|
26
|
+
attribute :warnings
|
27
|
+
|
28
|
+
def save
|
29
|
+
requires :identity, :network, :dest_range, :priority
|
30
|
+
|
31
|
+
data = service.insert_route(identity, self.network, self.dest_range, self.priority, self.attributes)
|
32
|
+
operation = Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'])
|
33
|
+
operation.wait_for { !pending? }
|
34
|
+
reload
|
35
|
+
end
|
36
|
+
|
37
|
+
def destroy(async=true)
|
38
|
+
requires :identity
|
39
|
+
|
40
|
+
data = service.delete_route(identity)
|
41
|
+
operation = Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'])
|
42
|
+
unless async
|
43
|
+
operation.wait_for { ready? }
|
44
|
+
end
|
45
|
+
operation
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/google/models/compute/route'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Google
|
7
|
+
class Routes < Fog::Collection
|
8
|
+
model Fog::Compute::Google::Route
|
9
|
+
|
10
|
+
def all
|
11
|
+
data = service.list_routes.body
|
12
|
+
load(data['items'] || [])
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(identity)
|
16
|
+
if route = service.get_route(identity).body
|
17
|
+
new(route)
|
18
|
+
end
|
19
|
+
rescue Fog::Errors::NotFound
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,258 @@
|
|
1
|
+
require 'fog/compute/models/server'
|
2
|
+
require 'net/ssh/proxy/command'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Google
|
7
|
+
class Server < Fog::Compute::Server
|
8
|
+
identity :name
|
9
|
+
|
10
|
+
attribute :kind
|
11
|
+
attribute :id
|
12
|
+
attribute :can_ip_forward, :aliases => 'canIpForward'
|
13
|
+
attribute :creation_timestamp, :aliases => 'creationTimestamp'
|
14
|
+
attribute :description
|
15
|
+
attribute :disks
|
16
|
+
attribute :machine_type, :aliases => 'machineType'
|
17
|
+
attribute :metadata
|
18
|
+
attribute :network_interfaces, :aliases => 'networkInterfaces'
|
19
|
+
attribute :scheduling
|
20
|
+
attribute :self_link, :aliases => 'selfLink'
|
21
|
+
attribute :service_accounts, :aliases => 'serviceAccounts'
|
22
|
+
attribute :state, :aliases => 'status'
|
23
|
+
attribute :status_message, :aliases => 'statusMessage'
|
24
|
+
attribute :tags
|
25
|
+
attribute :zone, :aliases => :zone_name
|
26
|
+
|
27
|
+
# These attributes are not available in the representation of an 'instance' returned by the GCE API.
|
28
|
+
# They are useful only for the create process
|
29
|
+
attribute :network, :aliases => 'network'
|
30
|
+
attribute :external_ip, :aliases => 'externalIP'
|
31
|
+
attribute :auto_restart
|
32
|
+
attribute :on_host_maintenance
|
33
|
+
|
34
|
+
def image_name=(args)
|
35
|
+
Fog::Logger.deprecation("image_name= is no longer used [light_black](#{caller.first})[/]")
|
36
|
+
end
|
37
|
+
|
38
|
+
def image_name
|
39
|
+
boot_disk = disks.first
|
40
|
+
unless boot_disk.is_a?(Disk)
|
41
|
+
source = boot_disk['source']
|
42
|
+
match = source.match(%r{/zones/(.*)/disks/(.*)$})
|
43
|
+
boot_disk = service.disks.get match[2], match[1]
|
44
|
+
end
|
45
|
+
boot_disk.source_image.nil? ? nil : boot_disk.source_image
|
46
|
+
end
|
47
|
+
|
48
|
+
def kernel=(args)
|
49
|
+
Fog::Logger.deprecation("kernel= is no longer used [light_black](#{caller.first})[/]")
|
50
|
+
end
|
51
|
+
|
52
|
+
def kernel
|
53
|
+
Fog::Logger.deprecation("kernel is no longer used [light_black](#{caller.first})[/]")
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def flavor_id
|
58
|
+
machine_type
|
59
|
+
end
|
60
|
+
|
61
|
+
def flavor_id=(flavor_id)
|
62
|
+
machine_type=flavor_id
|
63
|
+
end
|
64
|
+
|
65
|
+
def destroy(async=true)
|
66
|
+
requires :name, :zone
|
67
|
+
|
68
|
+
data = service.delete_server(name, zone_name)
|
69
|
+
operation = Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
70
|
+
unless async
|
71
|
+
operation.wait_for { ready? }
|
72
|
+
end
|
73
|
+
operation
|
74
|
+
end
|
75
|
+
|
76
|
+
# not used since v1
|
77
|
+
def image
|
78
|
+
Fog::Logger.deprecation("Server.image is deprecated, get source_image from boot disk")
|
79
|
+
service.get_image(self.image_name.split('/')[-1])
|
80
|
+
end
|
81
|
+
|
82
|
+
def public_ip_address
|
83
|
+
ip = nil
|
84
|
+
if self.network_interfaces.respond_to? :each
|
85
|
+
self.network_interfaces.each do |netif|
|
86
|
+
if netif["accessConfigs"].respond_to? :each
|
87
|
+
netif["accessConfigs"].each do |access_config|
|
88
|
+
if access_config["name"] == "External NAT"
|
89
|
+
ip = access_config['natIP']
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
ip
|
97
|
+
end
|
98
|
+
|
99
|
+
def private_ip_address
|
100
|
+
ip = nil
|
101
|
+
if self.network_interfaces.respond_to? :first
|
102
|
+
ip = self.network_interfaces.first['networkIP']
|
103
|
+
end
|
104
|
+
ip
|
105
|
+
end
|
106
|
+
|
107
|
+
def addresses
|
108
|
+
[private_ip_address, public_ip_address]
|
109
|
+
end
|
110
|
+
|
111
|
+
def attach_disk(disk, options = {})
|
112
|
+
requires :identity, :zone
|
113
|
+
|
114
|
+
data = service.attach_disk(identity, zone_name, disk, options)
|
115
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
116
|
+
end
|
117
|
+
|
118
|
+
def detach_disk(device_name)
|
119
|
+
requires :identity, :zone
|
120
|
+
|
121
|
+
data = service.detach_disk(identity, zone, device_name)
|
122
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
123
|
+
end
|
124
|
+
|
125
|
+
def reboot
|
126
|
+
requires :identity, :zone
|
127
|
+
|
128
|
+
data = service.reset_server(identity, zone_name)
|
129
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
130
|
+
end
|
131
|
+
|
132
|
+
def start
|
133
|
+
requires :identity, :zone
|
134
|
+
|
135
|
+
data = service.start_server(identity, zone_name)
|
136
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
137
|
+
end
|
138
|
+
|
139
|
+
def stop
|
140
|
+
requires :identity, :zone
|
141
|
+
|
142
|
+
data = service.stop_server(identity, zone_name)
|
143
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
144
|
+
end
|
145
|
+
|
146
|
+
def serial_port_output
|
147
|
+
requires :identity, :zone
|
148
|
+
|
149
|
+
data = service.get_server_serial_port_output(identity, zone_name)
|
150
|
+
data.body['contents']
|
151
|
+
end
|
152
|
+
|
153
|
+
def set_disk_auto_delete(auto_delete, device_name)
|
154
|
+
requires :identity, :zone
|
155
|
+
|
156
|
+
data = service.set_server_disk_auto_delete(identity, zone_name, auto_delete, device_name)
|
157
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
158
|
+
end
|
159
|
+
|
160
|
+
def set_scheduling(on_host_maintenance, automatic_restart)
|
161
|
+
requires :identity, :zone
|
162
|
+
|
163
|
+
data = service.set_server_scheduling(identity, zone_name, on_host_maintenance, automatic_restart)
|
164
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
165
|
+
end
|
166
|
+
|
167
|
+
def set_metadata(metadata = {})
|
168
|
+
requires :identity, :zone
|
169
|
+
|
170
|
+
data = service.set_metadata(identity, zone_name, self.metadata['fingerprint'], metadata)
|
171
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
172
|
+
end
|
173
|
+
|
174
|
+
def set_tags(tags = [])
|
175
|
+
requires :identity, :zone
|
176
|
+
|
177
|
+
data = service.set_tags(identity, zone_name, self.tags['fingerprint'], tags)
|
178
|
+
Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
179
|
+
end
|
180
|
+
|
181
|
+
def ready?
|
182
|
+
self.state == RUNNING
|
183
|
+
end
|
184
|
+
|
185
|
+
def zone_name
|
186
|
+
zone.nil? ? nil : zone.split('/')[-1]
|
187
|
+
end
|
188
|
+
|
189
|
+
def add_ssh_key username, key
|
190
|
+
if self.metadata.nil?
|
191
|
+
self.metadata = Hash.new("")
|
192
|
+
end
|
193
|
+
|
194
|
+
# You can have multiple SSH keys, seperated by newlines.
|
195
|
+
# https://developers.google.com/compute/docs/console?hl=en#sshkeys
|
196
|
+
if !self.metadata["sshKeys"]
|
197
|
+
self.metadata["sshKeys"] = ""
|
198
|
+
end
|
199
|
+
|
200
|
+
if !self.metadata["sshKeys"].empty?
|
201
|
+
self.metadata["sshKeys"] += "\n"
|
202
|
+
end
|
203
|
+
|
204
|
+
self.metadata["sshKeys"] += "#{username}:#{key.strip}"
|
205
|
+
|
206
|
+
return self.metadata
|
207
|
+
end
|
208
|
+
|
209
|
+
def reload
|
210
|
+
data = service.get_server(self.name, zone_name).body
|
211
|
+
self.merge_attributes(data)
|
212
|
+
end
|
213
|
+
|
214
|
+
def save
|
215
|
+
requires :name
|
216
|
+
requires :machine_type
|
217
|
+
requires :zone_name
|
218
|
+
requires :disks
|
219
|
+
|
220
|
+
if not service.zones.find{ |zone| zone.name == self.zone_name }
|
221
|
+
raise ArgumentError.new "#{self.zone_name.inspect} is either down or you don't have permission to use it."
|
222
|
+
end
|
223
|
+
|
224
|
+
self.add_ssh_key(self.username, self.public_key) if self.public_key
|
225
|
+
|
226
|
+
options = {
|
227
|
+
'machineType' => machine_type,
|
228
|
+
'networkInterfaces' => network_interfaces,
|
229
|
+
'network' => network,
|
230
|
+
'externalIp' => external_ip,
|
231
|
+
'disks' => disks,
|
232
|
+
'metadata' => metadata,
|
233
|
+
'serviceAccounts' => service_accounts,
|
234
|
+
'tags' => tags,
|
235
|
+
'auto_restart' => auto_restart,
|
236
|
+
'on_host_maintenance' => on_host_maintenance,
|
237
|
+
'can_ip_forward' => can_ip_forward
|
238
|
+
}.delete_if {|key, value| value.nil?}
|
239
|
+
|
240
|
+
if service_accounts
|
241
|
+
options['serviceAccounts'] = [{
|
242
|
+
"kind" => "compute#serviceAccount",
|
243
|
+
"email" => "default",
|
244
|
+
"scopes" => service_accounts.map {
|
245
|
+
|w| w.start_with?("https://") ? w : "https://www.googleapis.com/auth/#{w}"
|
246
|
+
}
|
247
|
+
}]
|
248
|
+
end
|
249
|
+
|
250
|
+
data = service.insert_server(name, zone_name, options)
|
251
|
+
operation = Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
|
252
|
+
operation.wait_for { !pending? }
|
253
|
+
reload
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|