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.
- checksums.yaml +4 -4
- data/examples/get_list_snapshots.rb +1 -1
- data/examples/load-balance.rb +23 -4
- data/fog-google.gemspec +1 -1
- data/lib/fog/compute/google.rb +113 -112
- data/lib/fog/compute/google/models/images.rb +21 -6
- data/lib/fog/compute/google/models/instance_group.rb +38 -2
- data/lib/fog/compute/google/models/instance_groups.rb +13 -7
- data/lib/fog/compute/google/models/resource_view.rb +1 -1
- data/lib/fog/compute/google/requests/{add_instance_group_instance.rb → add_instance_group_instances.rb} +11 -7
- data/lib/fog/compute/google/requests/get_image_from_family.rb +35 -0
- data/lib/fog/compute/google/requests/insert_server.rb +4 -0
- data/lib/fog/compute/google/requests/list_instance_group_instances.rb +3 -3
- data/lib/fog/compute/google/requests/{remove_instance_group_instance.rb → remove_instance_group_instances.rb} +11 -7
- data/lib/fog/google/version.rb +1 -1
- data/lib/fog/storage/google_json.rb +1 -2
- data/lib/fog/storage/google_json/models/directories.rb +4 -5
- data/lib/fog/storage/google_json/models/file.rb +2 -2
- data/lib/fog/storage/google_json/real.rb +6 -7
- data/lib/fog/storage/google_json/requests/get_object_http_url.rb +1 -1
- data/lib/fog/storage/google_json/requests/get_object_url.rb +1 -1
- data/lib/fog/storage/google_json/requests/list_buckets.rb +32 -0
- data/lib/fog/storage/google_json/requests/put_bucket.rb +12 -6
- data/lib/fog/storage/google_xml.rb +0 -1
- data/lib/fog/storage/google_xml/models/file.rb +2 -2
- data/lib/fog/storage/google_xml/real.rb +1 -1
- data/lib/fog/storage/google_xml/requests/get_object_http_url.rb +1 -4
- data/lib/fog/storage/google_xml/requests/get_object_https_url.rb +0 -3
- data/lib/fog/storage/google_xml/requests/get_object_url.rb +0 -3
- data/lib/fog/storage/google_xml/requests/put_bucket.rb +1 -1
- data/tasks/console.rake +3 -5
- data/test/integration/compute/test_servers.rb +1 -1
- data/test/integration/factories/backend_services_factory.rb +2 -2
- data/test/integration/factories/forwarding_rules_factory.rb +3 -3
- data/test/integration/factories/global_forwarding_rules_factory.rb +2 -2
- data/test/integration/factories/images_factory.rb +2 -2
- data/test/integration/factories/servers_factory.rb +4 -4
- data/test/integration/factories/target_http_proxies_factory.rb +2 -2
- data/test/integration/factories/target_pools_factory.rb +4 -4
- data/test/integration/factories/url_maps_factory.rb +2 -2
- data/test/integration/storage/test_buckets.rb +2 -3
- data/test/integration/storage/test_directories.rb +3 -3
- data/test/integration/storage/test_objects.rb +5 -9
- metadata +9 -10
- data/lib/fog/storage/google_json/requests/get_object_torrent.rb +0 -13
- data/lib/fog/storage/google_json/requests/get_service.rb +0 -54
- data/lib/fog/storage/google_xml/requests/get_object_torrent.rb +0 -39
@@ -14,7 +14,7 @@ module Fog
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
load(data
|
17
|
+
load(data)
|
18
18
|
end
|
19
19
|
|
20
20
|
def get(identity, zone = nil)
|
@@ -32,16 +32,22 @@ module Fog
|
|
32
32
|
nil
|
33
33
|
end
|
34
34
|
|
35
|
+
# TODO: To be deprecated
|
35
36
|
def add_instance(params)
|
36
|
-
|
37
|
+
Fog::Logger.deprecation(
|
38
|
+
"#{self.class}.#{__method__} is deprecated, use Fog::Compute::Google::InstanceGroup.#{__method__} instead [light_black](#{caller.first})[/]"
|
39
|
+
)
|
40
|
+
params[:instance] = [params[:instance]] unless params[:instance] == Array
|
41
|
+
service.add_instance_group_instances(params[:group], params[:zone], params[:instance])
|
37
42
|
end
|
38
43
|
|
44
|
+
# TODO: To be deprecated
|
39
45
|
def remove_instance(params)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
46
|
+
Fog::Logger.deprecation(
|
47
|
+
"#{self.class}.#{__method__} is deprecated, use Fog::Compute::Google::InstanceGroup.#{__method__} instead [light_black](#{caller.first})[/]"
|
48
|
+
)
|
49
|
+
params[:instance] = [params[:instance]] unless params[:instance] == Array
|
50
|
+
service.remove_instance_group_instances(params[:group], params[:zone], params[:instance])
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
@@ -76,7 +76,7 @@ module Fog
|
|
76
76
|
resources = [resources] unless resources.class == Array
|
77
77
|
resources.map { |resource| resource.class == String ? resource : resource.self_link }
|
78
78
|
service.add_zone_view_resources(self, resources, @zone) if @zone
|
79
|
-
service.add_region_view_resources(self,
|
79
|
+
service.add_region_view_resources(self, resources, @region) if @region
|
80
80
|
reload
|
81
81
|
end
|
82
82
|
|
@@ -2,13 +2,13 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Google
|
4
4
|
class Mock
|
5
|
-
def
|
5
|
+
def add_instance_group_instances(_group_name, _zone, _instances)
|
6
6
|
Fog::Mock.not_implemented
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
class Real
|
11
|
-
def
|
11
|
+
def add_instance_group_instances(group_name, zone, instances)
|
12
12
|
api_method = @compute.instance_groups.add_instances
|
13
13
|
|
14
14
|
parameters = {
|
@@ -17,12 +17,16 @@ module Fog
|
|
17
17
|
"zone" => zone
|
18
18
|
}
|
19
19
|
|
20
|
+
instances.map! do |instance|
|
21
|
+
if instance.start_with?("https:")
|
22
|
+
{ "instance" => instance }
|
23
|
+
else
|
24
|
+
{ "instance" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone}/instances/#{instance}\n" }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
20
28
|
body_object = {
|
21
|
-
"instances" =>
|
22
|
-
{
|
23
|
-
"instance" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone}/instances/#{instance_name}\n"
|
24
|
-
}
|
25
|
-
]
|
29
|
+
"instances" => instances
|
26
30
|
}
|
27
31
|
|
28
32
|
request(api_method, parameters, body_object)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Google
|
4
|
+
# Returns the latest non-deprecated image that is part of an image family.
|
5
|
+
#
|
6
|
+
# ==== Parameters
|
7
|
+
# * family<~String> - Name of the image resource to return.
|
8
|
+
#
|
9
|
+
# ==== Returns
|
10
|
+
# * response<~Excon::Response>:
|
11
|
+
# * body<~Hash> - corresponding compute#image resource
|
12
|
+
#
|
13
|
+
# ==== See also:
|
14
|
+
# https://cloud.google.com/compute/docs/reference/latest/images/getFromFamily
|
15
|
+
class Mock
|
16
|
+
def get_image_from_family(_family, _project = @project)
|
17
|
+
Fog::Mock.not_implemented
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Real
|
22
|
+
def get_image_from_family(family, project = nil)
|
23
|
+
api_method = @compute.images.get_from_family
|
24
|
+
project = @project if project.nil?
|
25
|
+
parameters = {
|
26
|
+
"family" => family,
|
27
|
+
"project" => project
|
28
|
+
}
|
29
|
+
|
30
|
+
request(api_method, parameters)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -161,6 +161,10 @@ module Fog
|
|
161
161
|
if options.key? "preemptible"
|
162
162
|
scheduling["preemptible"] = options.delete "preemptible"
|
163
163
|
scheduling["preemptible"] = scheduling["preemptible"].class == TrueClass
|
164
|
+
# If we don't have an explicit value for "on_host_maintenance, then
|
165
|
+
# force the value to be 'TERMINATE' as it's the default and
|
166
|
+
# only-accepted value for preemptible vms
|
167
|
+
scheduling["onHostMaintenance"] = "TERMINATE" unless options.key? "on_host_maintenance"
|
164
168
|
end
|
165
169
|
if options.key? "on_host_maintenance"
|
166
170
|
ohm = options.delete "on_host_maintenance"
|
@@ -8,12 +8,12 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class Real
|
11
|
-
def list_instance_group_instances(
|
11
|
+
def list_instance_group_instances(group_name, zone)
|
12
12
|
api_method = @compute.instance_groups.list_instances
|
13
13
|
parameters = {
|
14
|
+
"instanceGroup" => group_name,
|
14
15
|
"project" => @project,
|
15
|
-
"zone" => zone
|
16
|
-
"group" => group
|
16
|
+
"zone" => zone
|
17
17
|
}
|
18
18
|
|
19
19
|
request(api_method, parameters)
|
@@ -2,13 +2,13 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Google
|
4
4
|
class Mock
|
5
|
-
def
|
5
|
+
def add_instance_group_instances(_group, _zone, _instances)
|
6
6
|
Fog::Mock.not_implemented
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
class Real
|
11
|
-
def
|
11
|
+
def remove_instance_group_instances(group_name, zone, instances)
|
12
12
|
api_method = @compute.instance_groups.remove_instances
|
13
13
|
|
14
14
|
parameters = {
|
@@ -17,12 +17,16 @@ module Fog
|
|
17
17
|
"zone" => zone
|
18
18
|
}
|
19
19
|
|
20
|
+
instances.map! do |instance|
|
21
|
+
if instance.start_with?("https:")
|
22
|
+
{ "instance" => instance }
|
23
|
+
else
|
24
|
+
{ "instance" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone}/instances/#{instance}\n" }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
20
28
|
body_object = {
|
21
|
-
"instances" =>
|
22
|
-
{
|
23
|
-
"instance" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone}/instances/#{instance_name}\n"
|
24
|
-
}
|
25
|
-
]
|
29
|
+
"instances" => instances
|
26
30
|
}
|
27
31
|
|
28
32
|
request(api_method, parameters, body_object)
|
data/lib/fog/google/version.rb
CHANGED
@@ -35,12 +35,11 @@ module Fog
|
|
35
35
|
request :get_bucket_acl
|
36
36
|
request :get_object
|
37
37
|
request :get_object_acl
|
38
|
-
# request :get_object_torrent
|
39
38
|
request :get_object_http_url
|
40
39
|
request :get_object_https_url
|
41
40
|
request :get_object_url
|
42
|
-
# request :get_service
|
43
41
|
request :head_object
|
42
|
+
request :list_buckets
|
44
43
|
request :put_bucket
|
45
44
|
request :put_bucket_acl
|
46
45
|
request :put_object
|
@@ -4,11 +4,10 @@ module Fog
|
|
4
4
|
class Directories < Fog::Collection
|
5
5
|
model Fog::Storage::GoogleJSON::Directory
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# end
|
7
|
+
def all
|
8
|
+
data = service.list_buckets.body["items"] || []
|
9
|
+
load(data)
|
10
|
+
end
|
12
11
|
|
13
12
|
def get(key, options = {})
|
14
13
|
remap_attributes(options, :delimiter => "delimiter",
|
@@ -52,9 +52,9 @@ module Fog
|
|
52
52
|
|
53
53
|
attr_reader :directory
|
54
54
|
|
55
|
-
def copy(target_directory_key, target_file_key)
|
55
|
+
def copy(target_directory_key, target_file_key, options = {})
|
56
56
|
requires :directory, :key
|
57
|
-
service.copy_object(directory.key, key, target_directory_key, target_file_key)
|
57
|
+
service.copy_object(directory.key, key, target_directory_key, target_file_key, options)
|
58
58
|
target_directory = service.directories.new(:key => target_directory_key)
|
59
59
|
target_directory.files.get(target_file_key)
|
60
60
|
end
|
@@ -18,13 +18,12 @@ module Fog
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def signature(params)
|
21
|
-
string_to_sign =
|
22
|
-
<<-DATA
|
21
|
+
string_to_sign = <<-DATA
|
23
22
|
#{params[:method]}
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
#{params[:headers]['Content-MD5']}
|
24
|
+
#{params[:headers]['Content-Type']}
|
25
|
+
#{params[:headers]['Date']}
|
26
|
+
DATA
|
28
27
|
|
29
28
|
google_headers = {}
|
30
29
|
canonical_google_headers = ""
|
@@ -45,7 +44,7 @@ module Fog
|
|
45
44
|
canonical_resource << params[:path].to_s
|
46
45
|
canonical_resource << "?"
|
47
46
|
for key in (params[:query] || {}).keys
|
48
|
-
if %w(acl cors location logging requestPayment
|
47
|
+
if %w(acl cors location logging requestPayment versions versioning).include?(key)
|
49
48
|
canonical_resource << "#{key}&"
|
50
49
|
end
|
51
50
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class GoogleJSON
|
4
|
+
class Real
|
5
|
+
# Retrieves a list of buckets for a given project.
|
6
|
+
#
|
7
|
+
# ==== Returns
|
8
|
+
# * response<~Excon::Response>:
|
9
|
+
# * body<~Hash> - Hash of bucket items
|
10
|
+
# * 'kind'<~String> - The kind of item this is (storage#buckets)
|
11
|
+
# * 'items'<~Array> - The array of items.
|
12
|
+
#
|
13
|
+
# ==== See Also
|
14
|
+
# https://cloud.google.com/storage/docs/json_api/v1/buckets/list
|
15
|
+
# TODO: check if very large lists require working with nextPageToken
|
16
|
+
def list_buckets
|
17
|
+
api_method = @storage_json.buckets.list
|
18
|
+
parameters = {
|
19
|
+
"project" => @project
|
20
|
+
}
|
21
|
+
|
22
|
+
request(api_method, parameters)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
class Mock
|
26
|
+
def list_buckets
|
27
|
+
Fog::Mock.not_implemented
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -2,19 +2,24 @@ module Fog
|
|
2
2
|
module Storage
|
3
3
|
class GoogleJSON
|
4
4
|
class Real
|
5
|
-
# Create
|
6
|
-
# https://cloud.google.com/storage/docs/json_api/v1/buckets/insert
|
5
|
+
# Create a Google Storage bucket
|
7
6
|
#
|
8
7
|
# ==== Parameters
|
9
8
|
# * bucket_name<~String> - name of bucket to create
|
10
9
|
# * options<~Hash> - config arguments for bucket. Defaults to {}.
|
11
10
|
# * 'LocationConstraint'<~Symbol> - sets the location for the bucket
|
12
|
-
# * '
|
11
|
+
# * 'predefinedAcl'<~String> - Apply a predefined set of access controls to this bucket.
|
12
|
+
# * 'predefinedDefaultObjectAcl'<~String> - Apply a predefined set of default object access controls to this bucket.
|
13
|
+
# * body_options<~Hash> - body arguments for bucket creation.
|
14
|
+
# See https://cloud.google.com/storage/docs/json_api/v1/buckets/insert#request-body
|
13
15
|
#
|
14
16
|
# ==== Returns
|
15
17
|
# * response<~Excon::Response>:
|
16
18
|
# * status<~Integer> - 200
|
17
|
-
|
19
|
+
#
|
20
|
+
# ==== See also
|
21
|
+
# https://cloud.google.com/storage/docs/json_api/v1/buckets/insert
|
22
|
+
def put_bucket(bucket_name, options = {}, body_options = {})
|
18
23
|
location = options["LocationConstraint"] if options["LocationConstraint"]
|
19
24
|
|
20
25
|
api_method = @storage_json.buckets.insert
|
@@ -22,18 +27,19 @@ module Fog
|
|
22
27
|
"project" => @project,
|
23
28
|
"projection" => "full"
|
24
29
|
}
|
30
|
+
parameters.merge! options
|
25
31
|
body_object = {
|
26
32
|
"name" => bucket_name,
|
27
33
|
"location" => location
|
28
34
|
}
|
29
|
-
|
35
|
+
body_object.merge! body_options
|
30
36
|
|
31
37
|
request(api_method, parameters, body_object = body_object)
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
35
41
|
class Mock
|
36
|
-
def put_bucket(bucket_name, options = {})
|
42
|
+
def put_bucket(bucket_name, options = {}, _body_options = {})
|
37
43
|
acl = options["x-goog-acl"] || "private"
|
38
44
|
if !%w(private publicRead publicReadWrite authenticatedRead).include?(acl)
|
39
45
|
raise Excon::Errors::BadRequest.new("invalid x-goog-acl")
|
@@ -45,9 +45,9 @@ module Fog
|
|
45
45
|
|
46
46
|
attr_reader :directory
|
47
47
|
|
48
|
-
def copy(target_directory_key, target_file_key)
|
48
|
+
def copy(target_directory_key, target_file_key, options = {})
|
49
49
|
requires :directory, :key
|
50
|
-
service.copy_object(directory.key, key, target_directory_key, target_file_key)
|
50
|
+
service.copy_object(directory.key, key, target_directory_key, target_file_key, options)
|
51
51
|
target_directory = service.directories.new(:key => target_directory_key)
|
52
52
|
target_directory.files.get(target_file_key)
|
53
53
|
end
|
@@ -64,7 +64,7 @@ DATA
|
|
64
64
|
canonical_resource << params[:path].to_s
|
65
65
|
canonical_resource << "?"
|
66
66
|
(params[:query] || {}).keys.each do |key|
|
67
|
-
if %w(acl cors location logging requestPayment
|
67
|
+
if %w(acl cors location logging requestPayment versions versioning).include?(key)
|
68
68
|
canonical_resource << "#{key}&"
|
69
69
|
end
|
70
70
|
end
|
@@ -15,7 +15,7 @@ module Fog
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class Real
|
18
|
-
# Get an expiring object http url from
|
18
|
+
# Get an expiring object http url from GCS
|
19
19
|
#
|
20
20
|
# ==== Parameters
|
21
21
|
# * bucket_name<~String> - Name of bucket containing object
|
@@ -25,9 +25,6 @@ module Fog
|
|
25
25
|
# ==== Returns
|
26
26
|
# * response<~Excon::Response>:
|
27
27
|
# * body<~String> - url for object
|
28
|
-
#
|
29
|
-
# ==== See Also
|
30
|
-
# http://docs.amazonwebservices.com/AmazonS3/latest/dev/S3_QSAuth.html
|
31
28
|
|
32
29
|
include GetObjectHttpUrl
|
33
30
|
end
|
@@ -12,9 +12,6 @@ module Fog
|
|
12
12
|
# ==== Returns
|
13
13
|
# * response<~Excon::Response>:
|
14
14
|
# * body<~String> - url for object
|
15
|
-
#
|
16
|
-
# ==== See Also
|
17
|
-
# http://docs.amazonwebservices.com/AmazonS3/latest/dev/S3_QSAuth.html
|
18
15
|
|
19
16
|
def get_object_url(bucket_name, object_name, expires)
|
20
17
|
Fog::Logger.deprecation("Fog::Storage::Google => ##{get_object_url} is deprecated, use ##{get_object_https_url} instead[/] [light_black](#{caller.first})")
|