fog-google 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CONTRIBUTING.md +66 -1
  4. data/CONTRIBUTORS.md +1 -0
  5. data/README.md +24 -7
  6. data/Rakefile +14 -5
  7. data/examples/image_create.rb +1 -1
  8. data/examples/launch_micro_instance.rb +1 -1
  9. data/lib/fog/google/compute.rb +6 -2
  10. data/lib/fog/google/models/compute/addresses.rb +13 -0
  11. data/lib/fog/google/models/compute/backend_services.rb +3 -4
  12. data/lib/fog/google/models/compute/global_forwarding_rules.rb +5 -3
  13. data/lib/fog/google/models/compute/images.rb +8 -2
  14. data/lib/fog/google/models/compute/resource_views.rb +2 -2
  15. data/lib/fog/google/models/compute/server.rb +37 -3
  16. data/lib/fog/google/models/compute/target_http_proxies.rb +5 -2
  17. data/lib/fog/google/models/compute/target_http_proxy.rb +1 -1
  18. data/lib/fog/google/models/compute/target_instance.rb +2 -2
  19. data/lib/fog/google/models/compute/target_instances.rb +21 -8
  20. data/lib/fog/google/models/compute/url_map.rb +1 -1
  21. data/lib/fog/google/models/compute/url_maps.rb +5 -2
  22. data/lib/fog/google/requests/compute/insert_target_instance.rb +1 -1
  23. data/lib/fog/google/requests/compute/list_aggregated_target_instances.rb +42 -0
  24. data/lib/fog/google/version.rb +1 -1
  25. data/test/helpers/integration_test_helper.rb +22 -0
  26. data/test/helpers/test_collection.rb +37 -0
  27. data/test/helpers/test_helper.rb +19 -0
  28. data/test/integration/compute/test_backend_services.rb +11 -0
  29. data/test/integration/compute/test_disk_types.rb +39 -0
  30. data/test/integration/compute/test_disks.rb +11 -0
  31. data/test/integration/compute/test_forwarding_rules.rb +11 -0
  32. data/test/integration/compute/test_global_forwarding_rules.rb +11 -0
  33. data/test/integration/compute/test_http_health_checks.rb +11 -0
  34. data/test/integration/compute/test_images.rb +11 -0
  35. data/test/integration/compute/test_regions.rb +33 -0
  36. data/test/integration/compute/test_servers.rb +28 -0
  37. data/test/integration/compute/test_target_http_proxies.rb +11 -0
  38. data/test/integration/compute/test_target_instances.rb +11 -0
  39. data/test/integration/compute/test_target_pools.rb +11 -0
  40. data/test/integration/compute/test_url_maps.rb +11 -0
  41. data/test/integration/factories/backend_services_factory.rb +19 -0
  42. data/test/integration/factories/collection_factory.rb +27 -0
  43. data/test/integration/factories/disks_factory.rb +13 -0
  44. data/test/integration/factories/forwarding_rules_factory.rb +21 -0
  45. data/test/integration/factories/global_forwarding_rules_factory.rb +19 -0
  46. data/test/integration/factories/http_health_checks_factory.rb +11 -0
  47. data/test/integration/factories/images_factory.rb +12 -0
  48. data/test/integration/factories/servers_factory.rb +21 -0
  49. data/test/integration/factories/target_http_proxies_factory.rb +19 -0
  50. data/test/integration/factories/target_instances_factory.rb +20 -0
  51. data/test/integration/factories/target_pools_factory.rb +24 -0
  52. data/test/integration/factories/url_maps_factory.rb +19 -0
  53. data/test/integration/test_authentication.rb +59 -0
  54. data/tests/helpers/collection_helper.rb +2 -0
  55. data/tests/helpers/model_helper.rb +2 -0
  56. metadata +61 -31
  57. data/.ruby-version +0 -1
  58. data/spec/minitest_helper.rb +0 -15
  59. data/tests/credentials_tests.rb +0 -73
  60. data/tests/models/compute/backend_service_tests.rb +0 -7
  61. data/tests/models/compute/backend_services_tests.rb +0 -8
  62. data/tests/models/compute/disk_tests.rb +0 -9
  63. data/tests/models/compute/disk_types_tests.rb +0 -22
  64. data/tests/models/compute/disks_tests.rb +0 -9
  65. data/tests/models/compute/forwarding_rule_tests.rb +0 -8
  66. data/tests/models/compute/forwarding_rules_tests.rb +0 -8
  67. data/tests/models/compute/global_forwarding_rule_tests.rb +0 -7
  68. data/tests/models/compute/global_forwarding_rules_tests.rb +0 -7
  69. data/tests/models/compute/http_health_check_tests.rb +0 -5
  70. data/tests/models/compute/http_health_checks_tests.rb +0 -5
  71. data/tests/models/compute/image_tests.rb +0 -6
  72. data/tests/models/compute/images_tests.rb +0 -6
  73. data/tests/models/compute/region_tests.rb +0 -10
  74. data/tests/models/compute/regions_tests.rb +0 -19
  75. data/tests/models/compute/server_tests.rb +0 -37
  76. data/tests/models/compute/servers_tests.rb +0 -14
  77. data/tests/models/compute/target_http_proxies_tests.rb +0 -7
  78. data/tests/models/compute/target_http_proxy_test.rb +0 -6
  79. data/tests/models/compute/target_instance_tests.rb +0 -7
  80. data/tests/models/compute/target_instances_tests.rb +0 -7
  81. data/tests/models/compute/target_pool_tests.rb +0 -12
  82. data/tests/models/compute/target_pools_tests.rb +0 -11
  83. data/tests/models/compute/url_map_tests.rb +0 -6
  84. data/tests/models/compute/url_maps_tests.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d34bfdbe9d48d888a666b8097dafa7246fc8ab6f
4
- data.tar.gz: 3319d90e425fdf1f9d53d3f3ff06e5b5473f8558
3
+ metadata.gz: a924fff0c53902ab17cf84ba699c35cfb2139898
4
+ data.tar.gz: f2a1df01bb2be2dccf652d477c80b38fd20ce86d
5
5
  SHA512:
6
- metadata.gz: 14805dd5f5e1e0d4411c971b43b6c5cce08692be4a512f5e07c008462f26e6f1dbaa5791110fde190115b5a481c8ef7029a2345c7248c42b156ac48a3ebf0b4a
7
- data.tar.gz: a23a1dc7faaa20c0887fe4419a6b6f15d21b96094aa41a31826eb7895ae7295b35d241d6dee14436baf4ca8451be524fb498edfdffc654dc32a1bf1d287a2d81
6
+ metadata.gz: ab467619990b86e9dd1d9144e928434f9343516a12f589f815879471b841372b2b3b020dea667336d0f5473b8a5f7e813bc5d798a5f72d67208a1fbf89111522
7
+ data.tar.gz: 1a640d9fd9479034e6445febe59eff84ff22a7033502f4bbf24c9a953210546578a84ccd89fd55707e2c99c9fe17119607b5c5a079aa5b88065624ed3e60745a
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ .ruby-version
data/CONTRIBUTING.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  New contributors are always welcome, and when in doubt please ask questions! We strive to be an open and welcoming community. Please be nice to one another.
4
4
 
5
+ I recommend heading over to fog's [CONTRIBUTING](https://github.com/fog/fog/blob/master/CONTRIBUTING.md) and having a look around as well. It has information and context about the state of the `fog` project as a whole.
6
+
5
7
  ### Coding
6
8
 
7
9
  * Pick a task:
@@ -9,6 +11,11 @@ New contributors are always welcome, and when in doubt please ask questions! We
9
11
  * Review open [issues](https://github.com/fog/fog-google/issues) for things to help on.
10
12
  * [Create an issue](https://github.com/fog/fog-google/issues/new) to start a discussion on additions or features.
11
13
  * Fork the project, add your changes and tests to cover them in a topic branch.
14
+ * [Fork](https://github.com/fog/fog-google/fork)
15
+ * Create your feature branch (`git checkout -b my-new-feature`)
16
+ * Commit your changes (`git commit -am 'Add some feature'`)
17
+ * Push to the branch (`git push origin my-new-feature`)
18
+ * Create a new pull request
12
19
  * Commit your changes and rebase against `fog/fog-google` to ensure everything is up to date.
13
20
  * [Submit a pull request](https://github.com/fog/fog-google/compare/)
14
21
 
@@ -17,4 +24,62 @@ New contributors are always welcome, and when in doubt please ask questions! We
17
24
  * Offer feedback on open [issues](https://github.com/fog/fog-google/issues).
18
25
  * Organize or volunteer at events.
19
26
 
20
- I recommend heading over to fog's [CONTRIBUTING](https://github.com/fog/fog/blob/master/CONTRIBUTING.md) and having a look around as well. It has information and context about the state of the `fog` project as a whole.
27
+ ## Contributing Code
28
+
29
+ This document is very much a work in progress. Sorry about that.
30
+
31
+ It's worth noting that, if you're looking through the code, and you'd like to know the history of a line, you may not find it in the history of this repository, since most of the code was extracted from [fog/fog](https://github.com/fog/fog). So, you can look at the history from commit [fog/fog#c596e](https://github.com/fog/fog/tree/c596e710952aa9c90713da3fbfb3027db0608413) backward for more information.
32
+
33
+ ### Development environment
34
+
35
+ If you're going to be doing any kind of modifications, I highly recommend using [rbenv](https://github.com/sstephenson/rbenv), [ruby-build](https://github.com/sstephenson/ruby-build), (don't forget the [dependencies](https://github.com/sstephenson/ruby-build/wiki#suggested-build-environment)!) and [bundler](http://bundler.io/).
36
+
37
+ Once you've got that all installed, run
38
+
39
+ ```shell
40
+ $ bundle install
41
+ ```
42
+
43
+ to install the required gems. You might have to [fight a bit](http://www.nokogiri.org/tutorials/installing_nokogiri.html) to get Nokogiri installed.
44
+
45
+ Then, you should be ready to go! If you'd like to drop into an interactive shell, configured with your `:test` credential, use
46
+
47
+ ```shell
48
+ rake console
49
+ ```
50
+
51
+ ### Testing
52
+
53
+ This module is tested with [Minitest](https://github.com/seattlerb/minitest). Right now, the only tests that exist are live integration tests, found in `test/integration/`. After completing the installation in the README, (including setting up your credentials and keys,) make sure you have a `:test` credential in `~/.fog`, something like:
54
+
55
+ ```
56
+ test:
57
+ google_project: my-project
58
+ google_client_email: xxxxxxxxxxxxx-xxxxxxxxxxxxx@developer.gserviceaccount.com
59
+ google_key_location: /path/to/my-project-xxxxxxxxxxxxx.p12
60
+ google_json_key_location: /path/to/my-project-xxxxxxxxxxxxx.json
61
+ ```
62
+
63
+ Note that you need both a `.p12` and a `.json` key file for all the tests to pass.
64
+
65
+ Then you can run all the live tests:
66
+
67
+ ```shell
68
+ $ rake test
69
+ ```
70
+
71
+ or just one:
72
+
73
+ ```shell
74
+ $ rake test TEST=test/integration/compute/test_servers.rb TESTOPTS="--name=TestServers#test_bootstrap_ssh_destroy"
75
+ ```
76
+
77
+ #### Some notes about the tests as they stand
78
+
79
+ The live integration tests for resources, (servers, disks, etc.,) have a few components:
80
+
81
+ - The `TestCollection` **mixin module** lives in `test/helpers/test_collection.rb` and contains the standard tests to run for all resources, (e.g. `test_lifecycle`). It also calls `cleanup` on the resource's factory during teardown, to make sure that resources are getting destroyed before the next test run.
82
+ - The **factory**, (e.g. `ServersFactory`, in `test/integration/factories/servers_factory.rb`,) automates the creation of resources and/or supplies parameters for explicit creation of resources. For example, `ServersFactory` initializes a `DisksFactory` to supply disks in order to create servers, and implements the `params` method so that tests can create servers with unique names, correct zones and machine types, and automatically-created disks. `ServersFactory` inherits the `create` method from `CollectionFactory`, which allows tests to create servers on-demand.
83
+ - The **main test**, (e.g. `TestServers`, in `test/integration/compute/test_servers.rb`,) is the test that actually runs. It mixes in the `TestCollection` module in order to run the tests in that module, it supplies the `setup` method in which it initializes a `ServersFactory`, and it includes any other tests specific to this collection, (e.g. `test_bootstrap_ssh_destroy`).
84
+
85
+ If you want to create another resource, you should add live integration tests; all you need to do is create a factory in `test/integration/factories/my_resource_factory.rb` and a main test in `test/integration/compute/test_my_resource.rb` that mixes in `TestCollection`.
data/CONTRIBUTORS.md CHANGED
@@ -39,3 +39,4 @@
39
39
  * Timur Alperovich <timur.alperovich@gmail.com>
40
40
  * unknown <bturner_2@pibuk-lp71.pibenchmark.com>
41
41
  * Wesley Beary <geemus@gmail.com>
42
+ * Google Inc.
data/README.md CHANGED
@@ -40,16 +40,33 @@ gem 'fog-google'
40
40
 
41
41
  And then execute:
42
42
 
43
- $ bundle
43
+ ```shell
44
+ $ bundle
45
+ ```
44
46
 
45
47
  Or install it yourself as:
46
48
 
47
- $ gem install fog-google
49
+ ```shell
50
+ $ gem install fog-google
51
+ ```
52
+
53
+ ### Setup
54
+
55
+ #### Credentials
56
+
57
+ Follow the [instructions to generate a private key](https://cloud.google.com/storage/docs/authentication#generating-a-private-key). You can then create a fog credentials file at `~/.fog`, which will look something like this:
58
+
59
+ ```
60
+ my_credential:
61
+ google_project: my-project
62
+ google_client_email: xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com
63
+ google_json_key_location: /path/to/my-project-xxxxxxxxxxxx.json
64
+ ```
65
+
66
+ #### SSH-ing into instances
67
+
68
+ If you want to be able to bootstrap SSH-able instances, (using `servers.bootstrap`,) be sure you have a key in `~/.ssh/id_rsa` and `~/.ssh/id_rsa.pub`.
48
69
 
49
70
  ## Contributing
50
71
 
51
- 1. Fork it ( https://github.com/fog/fog-google/fork )
52
- 2. Create your feature branch (`git checkout -b my-new-feature`)
53
- 3. Commit your changes (`git commit -am 'Add some feature'`)
54
- 4. Push to the branch (`git push origin my-new-feature`)
55
- 5. Create a new Pull Request
72
+ See `CONTRIBUTING.md` in this repository.
data/Rakefile CHANGED
@@ -1,15 +1,13 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
- require 'fog/google'
4
3
 
5
4
  Rake::TestTask.new do |t|
6
- t.libs.push %w(spec)
7
- t.test_files = FileList['spec/**/*_spec.rb']
8
- t.verbose = true
5
+ t.libs << "test"
6
+ t.pattern = File.join("test", "**", "test_*.rb")
9
7
  end
10
8
 
11
9
  desc 'Default Task'
12
- task :default => [ :test, 'test:travis' ]
10
+ task :default => [ 'test:travis' ]
13
11
 
14
12
  namespace :test do
15
13
  mock = ENV['FOG_MOCK'] || 'true'
@@ -32,3 +30,14 @@ namespace :google do
32
30
  end
33
31
  end
34
32
  end
33
+
34
+ # From http://erniemiller.org/2014/02/05/7-lines-every-gems-rakefile-should-have/
35
+ # with some modification.
36
+ task :console do
37
+ require 'irb'
38
+ require 'irb/completion'
39
+ require 'fog/google'
40
+ Fog.credential = :test
41
+ ARGV.clear
42
+ IRB.start
43
+ end
@@ -2,7 +2,7 @@ def test
2
2
  connection = Fog::Compute.new({ :provider => "Google" })
3
3
 
4
4
  rawdisk = {
5
- :source => nil, # 'http://some_valid_url_to_rootfs_tarball'
5
+ :source => nil, # Google Cloud Storage URL pointing to the disk image. (e.g. http://storage.googleapis.com/test/test.tar.gz)
6
6
  :container_type => 'TAR',
7
7
  }
8
8
 
@@ -14,7 +14,7 @@ def test
14
14
  :machine_type => "f1-micro",
15
15
  :zone_name => "us-central1-a",
16
16
  :disks => [ disk.get_as_boot_disk(true) ],
17
- :user => ENV['USER']
17
+ :username => ENV['USER']
18
18
  }
19
19
 
20
20
  server = connection.servers.bootstrap params
@@ -3,7 +3,7 @@ module Fog
3
3
  class Google < Fog::Service
4
4
  requires :google_project
5
5
  recognizes :app_name, :app_version, :google_client_email, :google_key_location, :google_key_string,
6
- :google_client, :google_json_key_location, :google_json_key_string
6
+ :google_client, :google_json_key_location, :google_json_key_string, :google_extra_global_projects
7
7
 
8
8
  GOOGLE_COMPUTE_API_VERSION = 'v1'
9
9
  GOOGLE_COMPUTE_BASE_URL = 'https://www.googleapis.com/compute/'
@@ -46,6 +46,7 @@ module Fog
46
46
  request :list_region_view_resources
47
47
  request :list_zone_view_resources
48
48
  request :list_target_instances
49
+ request :list_aggregated_target_instances
49
50
 
50
51
  request :get_server
51
52
  request :get_address
@@ -220,9 +221,11 @@ module Fog
220
221
 
221
222
  class Mock
222
223
  include Fog::Google::Shared
224
+ attr_reader :extra_global_projects
223
225
 
224
226
  def initialize(options)
225
227
  shared_initialize(options[:google_project], GOOGLE_COMPUTE_API_VERSION, GOOGLE_COMPUTE_BASE_URL)
228
+ @extra_global_projects = options[:google_extra_global_projects] || []
226
229
  end
227
230
 
228
231
  def self.data(api_version)
@@ -1050,7 +1053,7 @@ module Fog
1050
1053
  include Fog::Google::Shared
1051
1054
 
1052
1055
  attr_accessor :client
1053
- attr_reader :compute
1056
+ attr_reader :compute, :extra_global_projects
1054
1057
 
1055
1058
  def initialize(options)
1056
1059
  shared_initialize(options[:google_project], GOOGLE_COMPUTE_API_VERSION, GOOGLE_COMPUTE_BASE_URL)
@@ -1059,6 +1062,7 @@ module Fog
1059
1062
  @client = initialize_google_client(options)
1060
1063
  @compute = @client.discovered_api('compute', api_version)
1061
1064
  @resourceviews = @client.discovered_api('resourceviews', 'v1beta1')
1065
+ @extra_global_projects = options[:google_extra_global_projects] || []
1062
1066
  end
1063
1067
  end
1064
1068
 
@@ -34,6 +34,19 @@ module Fog
34
34
  return nil if address.empty?
35
35
  new(address.first['addresses'].first)
36
36
  end
37
+
38
+ def get_by_name(ip_name)
39
+ names = service.list_aggregated_addresses(:filter => "name eq .*#{ip_name}").body['items']
40
+ name = names.each_value.select { |region| region.key?('addresses') }
41
+
42
+ return nil if name.empty?
43
+ new(name.first['addresses'].first)
44
+ end
45
+
46
+ def get_by_ip_address_or_name(ip_address_or_name)
47
+ get_by_ip_address(ip_address_or_name) or get_by_name(ip_address_or_name)
48
+ end
49
+
37
50
  end
38
51
  end
39
52
  end
@@ -13,10 +13,9 @@ module Fog
13
13
  end
14
14
 
15
15
  def get(identity)
16
- response = nil
17
- response = service.get_backend_service(identity)
18
- return nil if response.nil?
19
- new(response.body)
16
+ if backend_service = service.get_backend_service(identity).body
17
+ new(backend_service)
18
+ end
20
19
  rescue Fog::Errors::NotFound
21
20
  nil
22
21
  end
@@ -13,9 +13,11 @@ module Fog
13
13
  end
14
14
 
15
15
  def get(identity, region='global')
16
- response = service.get_global_forwarding_rule(identity, region)
17
- return nil if response.nil?
18
- new(response.body)
16
+ if global_forwarding_rule = service.get_global_forwarding_rule(identity, region).body
17
+ new(global_forwarding_rule)
18
+ end
19
+ rescue Fog::Errors::NotFound
20
+ nil
19
21
  end
20
22
  end
21
23
  end
@@ -23,7 +23,7 @@ module Fog
23
23
 
24
24
  def all
25
25
  data = []
26
- all_projects = GLOBAL_PROJECTS + [ self.service.project ]
26
+ all_projects = [ self.service.project ] + global_projects
27
27
 
28
28
  all_projects.each do |project|
29
29
  begin
@@ -44,7 +44,7 @@ module Fog
44
44
 
45
45
  def get(identity)
46
46
  # Search own project before global projects
47
- all_projects = [ self.service.project ] + GLOBAL_PROJECTS
47
+ all_projects = [ self.service.project ] + global_projects
48
48
 
49
49
  data = nil
50
50
  all_projects.each do |project|
@@ -60,6 +60,12 @@ module Fog
60
60
  return nil if data.nil?
61
61
  new(data)
62
62
  end
63
+
64
+ private
65
+
66
+ def global_projects
67
+ GLOBAL_PROJECTS + self.service.extra_global_projects
68
+ end
63
69
  end
64
70
  end
65
71
  end
@@ -8,7 +8,7 @@ module Fog
8
8
  model Fog::Compute::Google::ResourceView
9
9
 
10
10
  def all(filters={})
11
- if fliters['region'].nil? && filters['zone'].nil?
11
+ if filters['region'].nil? && filters['zone'].nil?
12
12
  data = []
13
13
  service.list_regions.body['items'].each do |region|
14
14
  data += service.list_region_views(region['name']).body['items'] || []
@@ -17,7 +17,7 @@ module Fog
17
17
  data += service.list_zone_views(zone['name']).body['items'] || []
18
18
  end
19
19
  elsif filters['zone']
20
- data = service.list_zone_views(fliters['zone']).body['items'] || []
20
+ data = service.list_zone_views(filters['zone']).body['items'] || []
21
21
  else
22
22
  data = service.list_region_views(filters['region']).body['items'] || []
23
23
  end
@@ -31,6 +31,21 @@ module Fog
31
31
  attribute :auto_restart
32
32
  attribute :on_host_maintenance
33
33
 
34
+ # Security account scope aliases used by official gcloud utility
35
+ # List derived from 'gcloud compute instances create --help'
36
+ GCE_SCOPE_ALIASES = {
37
+ 'compute-ro' => 'compute.readonly',
38
+ 'compute-rw' => 'compute',
39
+ 'computeaccounts-ro' => 'computeaccounts.readonly',
40
+ 'computeaccounts-rw' => 'computeaccounts',
41
+ 'logging-write' => 'logging.write',
42
+ 'sql' => 'sqlservice',
43
+ 'sql-admin' => 'sqlservice.admin',
44
+ 'storage-full' => 'devstorage.full_control',
45
+ 'storage-ro' => 'devstorage.read_only',
46
+ 'storage-rw' => 'devstorage.read_write'
47
+ }
48
+
34
49
  def image_name=(args)
35
50
  Fog::Logger.deprecation("image_name= is no longer used [light_black](#{caller.first})[/]")
36
51
  end
@@ -206,6 +221,27 @@ module Fog
206
221
  return self.metadata
207
222
  end
208
223
 
224
+ def map_service_accounts(scope_array)
225
+
226
+ scope_array_expanded = scope_array.map do |e|
227
+ if GCE_SCOPE_ALIASES[e]
228
+ GCE_SCOPE_ALIASES[e]
229
+ else
230
+ e
231
+ end
232
+ end
233
+
234
+ scope_array_finalized = scope_array_expanded.map do |e|
235
+ if e.start_with?("https://")
236
+ e
237
+ else
238
+ "https://www.googleapis.com/auth/#{e}"
239
+ end
240
+ end
241
+
242
+ return scope_array_finalized
243
+ end
244
+
209
245
  def reload
210
246
  data = service.get_server(self.name, zone_name).body
211
247
  self.merge_attributes(data)
@@ -241,9 +277,7 @@ module Fog
241
277
  options['serviceAccounts'] = [{
242
278
  "kind" => "compute#serviceAccount",
243
279
  "email" => "default",
244
- "scopes" => service_accounts.map {
245
- |w| w.start_with?("https://") ? w : "https://www.googleapis.com/auth/#{w}"
246
- }
280
+ "scopes" => self.map_service_accounts(service_accounts)
247
281
  }]
248
282
  end
249
283
 
@@ -13,8 +13,11 @@ module Fog
13
13
  end
14
14
 
15
15
  def get(identity)
16
- response = service.get_target_http_proxy(identity)
17
- new(response.body) unless response.nil?
16
+ if target_http_proxy = service.get_target_http_proxy(identity).body
17
+ new(target_http_proxy)
18
+ end
19
+ rescue Fog::Errors::NotFound
20
+ nil
18
21
  end
19
22
  end
20
23
  end
@@ -11,7 +11,7 @@ module Fog
11
11
  attribute :id, :aliases => 'id'
12
12
  attribute :creation_timestamp, :aliases => 'creationTimestamp'
13
13
  attribute :description, :aliases => 'description'
14
- attribute :urlMap, :aliases => "urlMap"
14
+ attribute :urlMap, :aliases => ["urlMap", :url_map]
15
15
 
16
16
  def save
17
17
  requires :name
@@ -25,8 +25,8 @@ module Fog
25
25
  'instance' => instance,
26
26
  }
27
27
 
28
- data = service.insert_target_instance(name, zone, options).body
29
- operation = Fog::Compute::Google::Operations.new(:service => service).get(data['name'])
28
+ data = service.insert_target_instance(name, zone, options)
29
+ operation = Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'], data.body['zone'])
30
30
  operation.wait_for { !pending? }
31
31
  reload
32
32
  end