fog-google 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/examples/get_list_snapshots.rb +1 -1
  3. data/examples/load-balance.rb +23 -4
  4. data/fog-google.gemspec +1 -1
  5. data/lib/fog/compute/google.rb +113 -112
  6. data/lib/fog/compute/google/models/images.rb +21 -6
  7. data/lib/fog/compute/google/models/instance_group.rb +38 -2
  8. data/lib/fog/compute/google/models/instance_groups.rb +13 -7
  9. data/lib/fog/compute/google/models/resource_view.rb +1 -1
  10. data/lib/fog/compute/google/requests/{add_instance_group_instance.rb → add_instance_group_instances.rb} +11 -7
  11. data/lib/fog/compute/google/requests/get_image_from_family.rb +35 -0
  12. data/lib/fog/compute/google/requests/insert_server.rb +4 -0
  13. data/lib/fog/compute/google/requests/list_instance_group_instances.rb +3 -3
  14. data/lib/fog/compute/google/requests/{remove_instance_group_instance.rb → remove_instance_group_instances.rb} +11 -7
  15. data/lib/fog/google/version.rb +1 -1
  16. data/lib/fog/storage/google_json.rb +1 -2
  17. data/lib/fog/storage/google_json/models/directories.rb +4 -5
  18. data/lib/fog/storage/google_json/models/file.rb +2 -2
  19. data/lib/fog/storage/google_json/real.rb +6 -7
  20. data/lib/fog/storage/google_json/requests/get_object_http_url.rb +1 -1
  21. data/lib/fog/storage/google_json/requests/get_object_url.rb +1 -1
  22. data/lib/fog/storage/google_json/requests/list_buckets.rb +32 -0
  23. data/lib/fog/storage/google_json/requests/put_bucket.rb +12 -6
  24. data/lib/fog/storage/google_xml.rb +0 -1
  25. data/lib/fog/storage/google_xml/models/file.rb +2 -2
  26. data/lib/fog/storage/google_xml/real.rb +1 -1
  27. data/lib/fog/storage/google_xml/requests/get_object_http_url.rb +1 -4
  28. data/lib/fog/storage/google_xml/requests/get_object_https_url.rb +0 -3
  29. data/lib/fog/storage/google_xml/requests/get_object_url.rb +0 -3
  30. data/lib/fog/storage/google_xml/requests/put_bucket.rb +1 -1
  31. data/tasks/console.rake +3 -5
  32. data/test/integration/compute/test_servers.rb +1 -1
  33. data/test/integration/factories/backend_services_factory.rb +2 -2
  34. data/test/integration/factories/forwarding_rules_factory.rb +3 -3
  35. data/test/integration/factories/global_forwarding_rules_factory.rb +2 -2
  36. data/test/integration/factories/images_factory.rb +2 -2
  37. data/test/integration/factories/servers_factory.rb +4 -4
  38. data/test/integration/factories/target_http_proxies_factory.rb +2 -2
  39. data/test/integration/factories/target_pools_factory.rb +4 -4
  40. data/test/integration/factories/url_maps_factory.rb +2 -2
  41. data/test/integration/storage/test_buckets.rb +2 -3
  42. data/test/integration/storage/test_directories.rb +3 -3
  43. data/test/integration/storage/test_objects.rb +5 -9
  44. metadata +9 -10
  45. data/lib/fog/storage/google_json/requests/get_object_torrent.rb +0 -13
  46. data/lib/fog/storage/google_json/requests/get_service.rb +0 -54
  47. data/lib/fog/storage/google_xml/requests/get_object_torrent.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b27707eb484f217aad6c9cc51dcbfeb831ed9fcd
4
- data.tar.gz: af62778fe526e0d2b52e78b77cc7551e1a7357cf
3
+ metadata.gz: 8a4aac1948c7ed0d3f7248b351c6140f9a08b3de
4
+ data.tar.gz: 4db3c146ba5402041ce46aac9b72504977b9a361
5
5
  SHA512:
6
- metadata.gz: 4efa40522165a909fe905fdf7c3a3026e07744b4b006c2ac7d07e7c32eec32f3b3db2fd86c621a15ac814ec5d3656e8e3ea70fbb391a2bf371c6c5e81dc0a1e4
7
- data.tar.gz: 8eab5d7ca82a571d9622ec7ff24821bb1c6bb4e5fd8d5dcb6fb44c6540afad9a400ddf8c50ca522bc7fc89b03c186077d8aa6f3db3af60de5b4c3de25d28fecc
6
+ metadata.gz: 079ccb37684b05947be1e6c8637d2955484202744e2ad43d72890e1edeec3e70e386238271cfc003bd000b829f0ff42d03e4fdf74380fb7ff21a79361c685b40
7
+ data.tar.gz: f41c1a0bbcee5788678ff0610f1dc886af968a7508c9a76cf48cbbcfb01d9e6cf15c413becebec2d4e1c022b5eb06f2b88ec64b7a0d0e25021c827ecde0a71e3
@@ -16,7 +16,7 @@ def test
16
16
  puts snapshots.inspect
17
17
 
18
18
  puts "Fetching a single snapshot..."
19
- puts "------------------------------------------------"
19
+ puts "---------------------------------"
20
20
  snap = snapshots.first
21
21
  unless snap.nil?
22
22
  snap = connection.snapshots.get(snap)
@@ -1,21 +1,30 @@
1
+ # All examples presume that you have a ~/.fog credentials file set up.
2
+ # More info on it can be found here: http://fog.io/about/getting_started.html
3
+
4
+ require "bundler"
5
+ Bundler.require(:default, :development)
6
+ # Uncomment this if you want to make real requests to GCE (you _will_ be billed!)
7
+ # WebMock.disable!
1
8
 
2
9
  def test
3
10
  # Config
4
11
  name = "fog-lb-test-#{Time.now.to_i}"
5
- zone = "us-central1-b"
6
- region = "us-central1"
12
+ zone = "europe-west1-d"
13
+ region = "europe-west1"
7
14
 
8
15
  # Setup
9
16
  gce = Fog::Compute.new :provider => "Google"
10
17
  servers = []
11
18
 
19
+ puts "Creating instances..."
20
+ puts "--------------------------------"
12
21
  (1..3).each do |i|
13
22
  begin
14
23
  disk = gce.disks.create(
15
24
  :name => "#{name}-#{i}",
16
25
  :size_gb => 10,
17
26
  :zone_name => zone,
18
- :source_image => "debian-7-wheezy-v20131120"
27
+ :source_image => "debian-8-jessie-v20160718"
19
28
  )
20
29
  disk.wait_for { disk.ready? }
21
30
  rescue
@@ -35,6 +44,8 @@ def test
35
44
  end
36
45
  end
37
46
 
47
+ puts "Creating health checks..."
48
+ puts "--------------------------------"
38
49
  begin
39
50
  health = gce.http_health_checks.new(:name => name)
40
51
  health.save
@@ -42,11 +53,13 @@ def test
42
53
  puts "Failed to create health check #{name}"
43
54
  end
44
55
 
56
+ puts "Creating a target pool..."
57
+ puts "--------------------------------"
45
58
  begin
46
59
  pool = gce.target_pools.new(
47
60
  :name => name,
48
61
  :region => region,
49
- :health_checks => health.self_link,
62
+ :health_checks => [health.self_link],
50
63
  :instances => servers.map(&:self_link)
51
64
  )
52
65
  pool.save
@@ -54,6 +67,8 @@ def test
54
67
  puts "Failed to create target pool #{name}"
55
68
  end
56
69
 
70
+ puts "Creating forwarding rules..."
71
+ puts "--------------------------------"
57
72
  begin
58
73
  rule = gce.forwarding_rules.new(
59
74
  :name => name,
@@ -71,6 +86,8 @@ def test
71
86
  # actual requests through the load balancer.
72
87
 
73
88
  # Cleanup
89
+ puts "Cleaning up..."
90
+ puts "--------------------------------"
74
91
  begin
75
92
  rule.destroy
76
93
  rescue
@@ -95,3 +112,5 @@ def test
95
112
  puts "Failed to clean up instances."
96
113
  end
97
114
  end
115
+
116
+ test
data/fog-google.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "fog-xml"
28
28
 
29
29
  # TODO: Upgrade to 0.9, which is not compatible.
30
- spec.add_development_dependency "google-api-client", "~> 0.8.6"
30
+ spec.add_development_dependency "google-api-client", "~> 0.8.7"
31
31
  spec.add_development_dependency "rake"
32
32
  spec.add_development_dependency "shindo"
33
33
  spec.add_development_dependency "minitest"
@@ -18,153 +18,154 @@ module Fog
18
18
  RUNNING = "RUNNING".freeze
19
19
 
20
20
  request_path "fog/compute/google/requests"
21
- request :list_servers
22
- request :list_aggregated_servers
23
- request :list_addresses
24
- request :list_aggregated_addresses
25
- request :list_disks
26
- request :list_aggregated_disks
27
- request :list_disk_types
28
- request :list_aggregated_disk_types
29
- request :list_firewalls
30
- request :list_images
31
- request :list_machine_types
32
- request :list_aggregated_machine_types
33
- request :list_networks
34
- request :list_zones
35
- request :list_regions
36
- request :list_global_operations
37
- request :list_region_operations
38
- request :list_zone_operations
39
- request :list_snapshots
40
- request :list_http_health_checks
41
- request :list_target_pools
42
- request :list_forwarding_rules
43
- request :list_routes
44
- request :list_backend_services
45
- request :list_global_forwarding_rules
46
- request :list_url_maps
47
- request :list_target_http_proxies
48
- request :list_zone_views
49
- request :list_region_views
50
- request :list_region_view_resources
51
- request :list_zone_view_resources
52
- request :list_target_instances
53
- request :list_aggregated_target_instances
54
- request :list_instance_groups
55
- request :list_aggregated_instance_groups
56
- request :list_instance_group_instances
57
- request :list_subnetworks
58
- request :list_aggregated_subnetworks
21
+ request :add_backend_service_backends
22
+ request :add_instance_group_instances
23
+ request :add_region_view_resources
24
+ request :add_server_access_config
25
+ request :add_target_pool_health_checks
26
+ request :add_target_pool_instances
27
+ request :add_url_map_host_rules
28
+ request :add_url_map_path_matchers
29
+ request :add_zone_view_resources
30
+
31
+ request :delete_address
32
+ request :delete_backend_service
33
+ request :delete_disk
34
+ request :delete_firewall
35
+ request :delete_forwarding_rule
36
+ request :delete_global_forwarding_rule
37
+ request :delete_global_operation
38
+ request :delete_http_health_check
39
+ request :delete_image
40
+ request :delete_instance_group
41
+ request :delete_network
42
+ request :delete_region_operation
43
+ request :delete_region_view
44
+ request :delete_route
45
+ request :delete_server
46
+ request :delete_server_access_config
47
+ request :delete_snapshot
48
+ request :delete_subnetwork
49
+ request :delete_target_http_proxy
50
+ request :delete_target_instance
51
+ request :delete_target_pool
52
+ request :delete_url_map
53
+ request :delete_zone_operation
54
+ request :delete_zone_view
59
55
 
60
- request :get_server
61
56
  request :get_address
57
+ request :get_backend_service
58
+ request :get_backend_service_health
62
59
  request :get_disk
63
60
  request :get_disk_type
64
61
  request :get_firewall
62
+ request :get_forwarding_rule
63
+ request :get_global_forwarding_rule
64
+ request :get_global_operation
65
+ request :get_http_health_check
65
66
  request :get_image
67
+ request :get_image_from_family
68
+ request :get_instance_group
66
69
  request :get_machine_type
67
70
  request :get_network
68
- request :get_zone
71
+ request :get_project
69
72
  request :get_region
70
- request :get_snapshot
71
- request :get_global_operation
72
73
  request :get_region_operation
73
- request :get_zone_operation
74
- request :get_http_health_check
74
+ request :get_region_view
75
+ request :get_route
76
+ request :get_server
77
+ request :get_server_serial_port_output
78
+ request :get_snapshot
79
+ request :get_subnetwork
80
+ request :get_target_http_proxy
81
+ request :get_target_instance
75
82
  request :get_target_pool
76
83
  request :get_target_pool_health
77
- request :get_forwarding_rule
78
- request :get_project
79
- request :get_route
80
- request :get_backend_service
81
- request :get_backend_service_health
82
84
  request :get_url_map
83
- request :get_global_forwarding_rule
84
- request :get_target_http_proxy
85
+ request :get_zone
86
+ request :get_zone_operation
85
87
  request :get_zone_view
86
- request :get_region_view
87
- request :get_target_instance
88
- request :get_instance_group
89
- request :get_subnetwork
90
-
91
- request :delete_address
92
- request :delete_disk
93
- request :delete_snapshot
94
- request :delete_firewall
95
- request :delete_image
96
- request :delete_network
97
- request :delete_server
98
- request :delete_global_operation
99
- request :delete_region_operation
100
- request :delete_zone_operation
101
- request :delete_http_health_check
102
- request :delete_target_pool
103
- request :delete_forwarding_rule
104
- request :delete_route
105
- request :delete_backend_service
106
- request :delete_url_map
107
- request :delete_target_http_proxy
108
- request :delete_global_forwarding_rule
109
- request :delete_zone_view
110
- request :delete_region_view
111
- request :delete_target_instance
112
- request :delete_instance_group
113
- request :delete_subnetwork
114
88
 
115
89
  request :insert_address
90
+ request :insert_backend_service
116
91
  request :insert_disk
117
92
  request :insert_firewall
93
+ request :insert_forwarding_rule
94
+ request :insert_global_forwarding_rule
95
+ request :insert_http_health_check
118
96
  request :insert_image
97
+ request :insert_instance_group
119
98
  request :insert_network
99
+ request :insert_region_view
100
+ request :insert_route
120
101
  request :insert_server
121
102
  request :insert_snapshot
122
- request :insert_http_health_check
103
+ request :insert_subnetwork
104
+ request :insert_target_http_proxy
105
+ request :insert_target_instance
123
106
  request :insert_target_pool
124
- request :insert_forwarding_rule
125
- request :insert_route
126
- request :insert_backend_service
127
107
  request :insert_url_map
128
- request :insert_target_http_proxy
129
- request :insert_global_forwarding_rule
130
108
  request :insert_zone_view
131
- request :insert_region_view
132
- request :insert_target_instance
133
- request :insert_instance_group
134
- request :insert_subnetwork
135
109
 
136
- request :set_metadata
137
- request :set_tags
138
- request :set_forwarding_rule_target
139
- request :set_global_forwarding_rule_target
140
- request :set_target_http_proxy_url_map
141
-
142
- request :add_target_pool_instances
143
- request :add_target_pool_health_checks
144
- request :add_backend_service_backends
145
- request :add_url_map_host_rules
146
- request :add_url_map_path_matchers
147
- request :add_zone_view_resources
148
- request :add_region_view_resources
149
- request :add_instance_group_instance
110
+ request :list_addresses
111
+ request :list_aggregated_addresses
112
+ request :list_aggregated_disk_types
113
+ request :list_aggregated_disks
114
+ request :list_aggregated_instance_groups
115
+ request :list_aggregated_machine_types
116
+ request :list_aggregated_servers
117
+ request :list_aggregated_subnetworks
118
+ request :list_aggregated_target_instances
119
+ request :list_backend_services
120
+ request :list_disk_types
121
+ request :list_disks
122
+ request :list_firewalls
123
+ request :list_forwarding_rules
124
+ request :list_global_forwarding_rules
125
+ request :list_global_operations
126
+ request :list_http_health_checks
127
+ request :list_images
128
+ request :list_instance_group_instances
129
+ request :list_instance_groups
130
+ request :list_machine_types
131
+ request :list_networks
132
+ request :list_region_operations
133
+ request :list_region_view_resources
134
+ request :list_region_views
135
+ request :list_regions
136
+ request :list_routes
137
+ request :list_servers
138
+ request :list_snapshots
139
+ request :list_subnetworks
140
+ request :list_target_http_proxies
141
+ request :list_target_instances
142
+ request :list_target_pools
143
+ request :list_url_maps
144
+ request :list_zone_operations
145
+ request :list_zone_view_resources
146
+ request :list_zone_views
147
+ request :list_zones
150
148
 
151
- request :remove_target_pool_instances
149
+ request :remove_instance_group_instances
152
150
  request :remove_target_pool_health_checks
151
+ request :remove_target_pool_instances
152
+
153
153
  request :set_common_instance_metadata
154
- request :remove_instance_group_instance
154
+ request :set_forwarding_rule_target
155
+ request :set_global_forwarding_rule_target
156
+ request :set_metadata
157
+ request :set_server_disk_auto_delete
158
+ request :set_server_scheduling
159
+ request :set_tags
160
+ request :set_target_http_proxy_url_map
155
161
 
156
162
  request :attach_disk
157
163
  request :detach_disk
158
- request :get_server_serial_port_output
159
164
  request :reset_server
160
- request :set_server_disk_auto_delete
161
- request :set_server_scheduling
162
- request :add_server_access_config
163
- request :delete_server_access_config
164
- request :update_url_map
165
- request :validate_url_map
166
165
  request :start_server
167
166
  request :stop_server
167
+ request :update_url_map
168
+ request :validate_url_map
168
169
 
169
170
  model_path "fog/compute/google/models"
170
171
  model :server
@@ -22,7 +22,6 @@ module Fog
22
22
 
23
23
  def all
24
24
  data = []
25
- all_projects = [service.project] + global_projects
26
25
 
27
26
  all_projects.each do |project|
28
27
  begin
@@ -50,10 +49,8 @@ module Fog
50
49
  end
51
50
 
52
51
  def get(identity)
53
- # Search own project before global projects
54
- all_projects = [service.project] + global_projects
55
-
56
52
  data = nil
53
+
57
54
  all_projects.each do |project|
58
55
  begin
59
56
  data = service.get_image(identity, project).body
@@ -68,10 +65,28 @@ module Fog
68
65
  new(data)
69
66
  end
70
67
 
68
+ def get_from_family(family)
69
+ data = nil
70
+
71
+ all_projects.each do |project|
72
+ begin
73
+ data = service.get_image_from_family(family, project).body
74
+ data[:project] = project
75
+ rescue Fog::Errors::NotFound
76
+ next
77
+ else
78
+ break
79
+ end
80
+ end
81
+ return nil if data.nil?
82
+ new(data)
83
+ end
84
+
71
85
  private
72
86
 
73
- def global_projects
74
- GLOBAL_PROJECTS + service.extra_global_projects
87
+ def all_projects
88
+ # Search own project before global projects
89
+ [service.project] + GLOBAL_PROJECTS + service.extra_global_projects
75
90
  end
76
91
  end
77
92
  end
@@ -18,18 +18,54 @@ module Fog
18
18
  def save
19
19
  requires :name, :zone
20
20
 
21
- data = service.insert_instance_group(name, zone)
21
+ service.insert_instance_group(name, zone)
22
22
  end
23
23
 
24
24
  def destroy(_async = true)
25
25
  requires :name, :zone
26
26
 
27
- data = service.delete_instance_group(name, zone_name)
27
+ service.delete_instance_group(name, zone_name)
28
+ end
29
+
30
+ def add_instances(instances)
31
+ requires :identity, :zone
32
+
33
+ service.add_instance_group_instances(
34
+ identity, zone_name, format_instance_list(instances)
35
+ )
36
+ end
37
+
38
+ def remove_instances(instances)
39
+ requires :identity, :zone
40
+
41
+ service.remove_instance_group_instances(
42
+ identity, zone_name, format_instance_list(instances)
43
+ )
44
+ end
45
+
46
+ def list_instances
47
+ requires :identity, :zone
48
+
49
+ instance_list = []
50
+ data = service.list_instance_group_instances(identity, zone_name).body
51
+ if data["items"]
52
+ data["items"].each do |instance|
53
+ instance_list << service.servers.get(instance["instance"].split("/")[-1], zone_name)
54
+ end
55
+ end
56
+ instance_list
28
57
  end
29
58
 
30
59
  def zone_name
31
60
  zone.nil? ? nil : zone.split("/")[-1]
32
61
  end
62
+
63
+ private
64
+
65
+ def format_instance_list(instance_list)
66
+ instance_list = Array(instance_list)
67
+ instance_list.map { |i| i.class == String ? i : i.self_link }
68
+ end
33
69
  end
34
70
  end
35
71
  end