fog-google 1.8.1 → 1.8.2
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/CHANGELOG.md +34 -0
- data/Gemfile +3 -0
- data/examples/create_instance_with_attached_disk.rb +53 -0
- data/fog-google.gemspec +1 -2
- data/lib/fog/compute/google/models/disk.rb +39 -7
- data/lib/fog/compute/google/models/disks.rb +28 -0
- data/lib/fog/compute/google/models/snapshot.rb +6 -0
- data/lib/fog/google/version.rb +1 -1
- data/lib/fog/storage/google_json/requests/get_object.rb +2 -0
- data/test/integration/compute/core_compute/test_disks.rb +42 -0
- metadata +5 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5891afe294dbc055e5e3f3ff46a2dab00692cb3
|
4
|
+
data.tar.gz: f81a710b9e7774d9ece9c8b49d02c9fe54a37fac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47b3b0b0a4687ec054180bda94aa7e45a65d3e65a6c7145a574d4f3f9fbbc433da67b60e61de5ceff72664fd5839f20ccc5694ae61daae606885d3e259b4c714
|
7
|
+
data.tar.gz: 44ed811c6cc6246667aed5742d2b43ca312cf2864b19a8c477d1592ca9b11066d421e0ee4be21e2db9356098e794ac2800357946f75052313a8c4af0aad82788
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,40 @@ The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1
|
|
4
4
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## Next
|
8
|
+
|
9
|
+
## 1.8.2
|
10
|
+
|
11
|
+
### User-facing
|
12
|
+
|
13
|
+
#### Added
|
14
|
+
|
15
|
+
- \#435 Added additional examples for attached disks usage. [temikus]
|
16
|
+
|
17
|
+
#### Fixed
|
18
|
+
|
19
|
+
- \#433 Allow the api to close Tempfiles inline, improving disk utilization.
|
20
|
+
[itopalov]
|
21
|
+
|
22
|
+
### Development changes
|
23
|
+
|
24
|
+
#### Added
|
25
|
+
|
26
|
+
- \#425 Integration on Jruby + disk snapshot tests: [temikus]
|
27
|
+
- Adding JRuby 9.1 into Travis
|
28
|
+
- Added integration tests for disk snapshots
|
29
|
+
|
30
|
+
#### Fixed
|
31
|
+
|
32
|
+
- \#432 Relax fog-json constraint to minor version. [pravi]
|
33
|
+
|
34
|
+
- \#425 Miscellaneous dev improvements around JRuby and disk handling: [temikus]
|
35
|
+
- Fix bundling in development environment on JRuby
|
36
|
+
- Remove EOL versions of ruby from Travis
|
37
|
+
- Consolidated logic of `Disk.get_as_boot_disk` and increase doc coverage of
|
38
|
+
disk-associated methods.
|
39
|
+
- Add a guard a guard method for `Snapshot.add_labels`
|
40
|
+
|
7
41
|
## 1.8.1
|
8
42
|
|
9
43
|
### User-facing
|
data/Gemfile
CHANGED
@@ -6,5 +6,8 @@ gem "inch", :require => false
|
|
6
6
|
gem "osrcry", :require => false
|
7
7
|
gem "rubocop", :require => false
|
8
8
|
|
9
|
+
# Debugger is specified here as it's not compatible with jRuby
|
10
|
+
gem "pry-byebug", :platforms => :ruby
|
11
|
+
|
9
12
|
# Specify your gem's dependencies in fog-google.gemspec
|
10
13
|
gemspec
|
@@ -0,0 +1,53 @@
|
|
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
|
+
|
7
|
+
def example
|
8
|
+
p "Connecting to Google API"
|
9
|
+
connection = Fog::Compute.new(:provider => "Google")
|
10
|
+
|
11
|
+
p "Creating disk"
|
12
|
+
disk = connection.disks.create(
|
13
|
+
:name => "fog-smoke-test-#{Time.now.to_i}",
|
14
|
+
:size_gb => 10,
|
15
|
+
:zone => "us-central1-f",
|
16
|
+
:source_image => "debian-9-stretch-v20180611"
|
17
|
+
)
|
18
|
+
|
19
|
+
p "Creating a second disk"
|
20
|
+
attached_disk = connection.disks.create(
|
21
|
+
:name => "fog-smoke-test-#{Time.now.to_i}",
|
22
|
+
:size_gb => 10,
|
23
|
+
:zone => "us-central1-f"
|
24
|
+
)
|
25
|
+
|
26
|
+
p "Waiting for disks to be ready"
|
27
|
+
disk.wait_for { ready? }
|
28
|
+
attached_disk.wait_for { ready? }
|
29
|
+
|
30
|
+
p "Creating a server"
|
31
|
+
server = connection.servers.create(
|
32
|
+
:name => "fog-smoke-test-#{Time.now.to_i}",
|
33
|
+
:disks => [disk.attached_disk_obj(boot: true),
|
34
|
+
attached_disk.attached_disk_obj(boot: false,
|
35
|
+
auto_delete: true)],
|
36
|
+
:machine_type => "n1-standard-1",
|
37
|
+
:private_key_path => File.expand_path("~/.ssh/id_rsa"),
|
38
|
+
:public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
|
39
|
+
:zone => "us-central1-f",
|
40
|
+
# Will be simplified, see https://github.com/fog/fog-google/issues/360
|
41
|
+
:network_interfaces => [{ :network => "global/networks/default",
|
42
|
+
:access_configs => [{
|
43
|
+
:name => "External NAT",
|
44
|
+
:type => "ONE_TO_ONE_NAT"
|
45
|
+
}] }],
|
46
|
+
:username => ENV["USER"]
|
47
|
+
)
|
48
|
+
|
49
|
+
p "Deleting server"
|
50
|
+
raise "Could not delete server." unless server.destroy
|
51
|
+
end
|
52
|
+
|
53
|
+
example
|
data/fog-google.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
# Locked until https://github.com/fog/fog-google/issues/417 is resolved
|
24
24
|
spec.add_dependency "fog-core", "<= 2.1.0"
|
25
|
-
spec.add_dependency "fog-json", "~> 1.2
|
25
|
+
spec.add_dependency "fog-json", "~> 1.2"
|
26
26
|
spec.add_dependency "fog-xml", "~> 0.1.0"
|
27
27
|
|
28
28
|
# Hard Requirement as of 1.0
|
@@ -30,7 +30,6 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
# Debugger
|
32
32
|
spec.add_development_dependency "pry"
|
33
|
-
spec.add_development_dependency "pry-byebug"
|
34
33
|
|
35
34
|
# Testing gems
|
36
35
|
spec.add_development_dependency "retriable"
|
@@ -68,19 +68,51 @@ module Fog
|
|
68
68
|
zone.nil? ? nil : zone.split("/")[-1]
|
69
69
|
end
|
70
70
|
|
71
|
+
# Returns an attached disk configuration hash.
|
72
|
+
#
|
73
|
+
# Compute API needs attached disks to be specified in a custom format.
|
74
|
+
# This provides a handy shortcut for generating a preformatted config.
|
75
|
+
#
|
76
|
+
# Example output:
|
77
|
+
# {:auto_delete=>false,
|
78
|
+
# :boot=>true,
|
79
|
+
# :mode=>"READ_WRITE",
|
80
|
+
# :source=>"https://www.googleapis.com/compute/v1/projects/myproj/zones/us-central1-f/disks/mydisk",
|
81
|
+
# :type=>"PERSISTENT"}
|
82
|
+
#
|
83
|
+
# See Instances.insert API docs for more info:
|
84
|
+
# https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert
|
85
|
+
#
|
86
|
+
# @param [Hash] opts options to attach the disk with.
|
87
|
+
# @option opts [Boolean] :writable The mode in which to attach this
|
88
|
+
# disk. (defaults to READ_WRITE)
|
89
|
+
# @option opts [Boolean] :boot Indicates whether this is a boot disk.
|
90
|
+
# (defaults to false)
|
91
|
+
# @option opts [String] :device_name Specifies a unique device name
|
92
|
+
# of your choice that is reflected into the /dev/disk/by-id/google-*
|
93
|
+
# tree of a Linux operating system running within the instance.
|
94
|
+
# @option opts [Object] :encryption_key Encrypts or decrypts a disk
|
95
|
+
# using a customer-supplied encryption key.
|
96
|
+
# @option opts [Object] :auto_delete Specifies whether the disk will
|
97
|
+
# be auto-deleted when the instance is deleted. (defaults to false)
|
98
|
+
#
|
99
|
+
# @return [Hash] Attached disk configuration hash
|
71
100
|
def attached_disk_obj(opts = {})
|
72
101
|
requires :self_link
|
73
102
|
collection.attached_disk_obj(self_link, opts)
|
74
103
|
end
|
75
104
|
|
105
|
+
# A legacy shorthand for attached_disk_obj
|
106
|
+
#
|
107
|
+
# @param [Object] writable The mode in which to attach this disk.
|
108
|
+
# (defaults to READ_WRITE)
|
109
|
+
# @param [Object] auto_delete Specifies whether the disk will be
|
110
|
+
# auto-deleted when the instance is deleted. (defaults to false)
|
111
|
+
# @return [Hash]
|
76
112
|
def get_as_boot_disk(writable = true, auto_delete = false)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
:source => self_link,
|
81
|
-
:mode => writable ? "READ_WRITE" : "READ_ONLY",
|
82
|
-
:type => "PERSISTENT"
|
83
|
-
}
|
113
|
+
attached_disk_obj(boot: true,
|
114
|
+
writable: writable,
|
115
|
+
auto_delete: auto_delete)
|
84
116
|
end
|
85
117
|
|
86
118
|
def ready?
|
@@ -38,6 +38,34 @@ module Fog
|
|
38
38
|
nil
|
39
39
|
end
|
40
40
|
|
41
|
+
# Returns an attached disk configuration hash.
|
42
|
+
#
|
43
|
+
# Compute API needs attached disks to be specified in a custom format.
|
44
|
+
# This provides a handy shortcut for generating a preformatted config.
|
45
|
+
#
|
46
|
+
# Example output:
|
47
|
+
# {:auto_delete=>false,
|
48
|
+
# :boot=>true,
|
49
|
+
# :mode=>"READ_WRITE",
|
50
|
+
# :source=>"https://www.googleapis.com/compute/v1/projects/myproj/zones/us-central1-f/disks/mydisk",
|
51
|
+
# :type=>"PERSISTENT"}
|
52
|
+
#
|
53
|
+
# See Instances.insert API docs for more info:
|
54
|
+
# https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert
|
55
|
+
#
|
56
|
+
# @param [String] source self_link of an existing disk resource
|
57
|
+
# @param [Boolean] writable The mode in which to attach this disk.
|
58
|
+
# (defaults to READ_WRITE)
|
59
|
+
# @param [Boolean] boot Indicates whether this is a boot disk.
|
60
|
+
# (defaults to false)
|
61
|
+
# @param [String] device_name Specifies a unique device name of your
|
62
|
+
# choice that is reflected into the /dev/disk/by-id/google-* tree of
|
63
|
+
# a Linux operating system running within the instance.
|
64
|
+
# @param [Object] encryption_key Encrypts or decrypts a disk using
|
65
|
+
# a customer-supplied encryption key.
|
66
|
+
# @param [Object] auto_delete Specifies whether the disk will be
|
67
|
+
# auto-deleted when the instance is deleted. (defaults to false)
|
68
|
+
# @return [Hash]
|
41
69
|
def attached_disk_obj(source,
|
42
70
|
writable: true,
|
43
71
|
boot: false,
|
@@ -39,6 +39,12 @@ module Fog
|
|
39
39
|
|
40
40
|
def set_labels(new_labels)
|
41
41
|
requires :identity, :label_fingerprint
|
42
|
+
|
43
|
+
unless new_labels.is_a? Hash
|
44
|
+
raise ArgumentError,
|
45
|
+
"Labels should be a hash, e.g. {foo: \"bar\",fog: \"test\"}"
|
46
|
+
end
|
47
|
+
|
42
48
|
service.set_snapshot_labels(identity, label_fingerprint, new_labels)
|
43
49
|
reload
|
44
50
|
end
|
data/lib/fog/google/version.rb
CHANGED
@@ -8,4 +8,46 @@ class TestDisks < FogIntegrationTest
|
|
8
8
|
@subject = Fog::Compute[:google].disks
|
9
9
|
@factory = DisksFactory.new(namespaced_name)
|
10
10
|
end
|
11
|
+
|
12
|
+
def test_get_as_configs
|
13
|
+
disk = @factory.create
|
14
|
+
disk.wait_for { ready? }
|
15
|
+
|
16
|
+
example = disk.get_as_boot_disk
|
17
|
+
config = { :auto_delete => false,
|
18
|
+
:boot => true,
|
19
|
+
:source => disk.self_link,
|
20
|
+
:mode => "READ_WRITE",
|
21
|
+
:type => "PERSISTENT" }
|
22
|
+
assert_equal(example, config)
|
23
|
+
|
24
|
+
example_with_params = disk.get_as_boot_disk(false, true)
|
25
|
+
config_with_params = { :auto_delete => true,
|
26
|
+
:boot => true,
|
27
|
+
:source => disk.self_link,
|
28
|
+
:mode => "READ_ONLY",
|
29
|
+
:type => "PERSISTENT" }
|
30
|
+
assert_equal(example_with_params, config_with_params)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_create_snapshot
|
34
|
+
disk = @factory.create
|
35
|
+
disk.wait_for { ready? }
|
36
|
+
|
37
|
+
snapshot = disk.create_snapshot("fog-test-snapshot")
|
38
|
+
|
39
|
+
assert(snapshot.is_a?(Fog::Compute::Google::Snapshot),
|
40
|
+
"Resulting snapshot should be a snapshot object.")
|
41
|
+
|
42
|
+
assert_raises(ArgumentError) { snapshot.set_labels(["bar", "test"]) }
|
43
|
+
|
44
|
+
snapshot.set_labels(foo: "bar", fog: "test")
|
45
|
+
|
46
|
+
assert_equal(snapshot.labels[:foo], "bar")
|
47
|
+
assert_equal(snapshot.labels[:fog], "test")
|
48
|
+
|
49
|
+
# Clean up the snapshot
|
50
|
+
operation = snapshot.destroy
|
51
|
+
operation.wait_for { ready? }
|
52
|
+
end
|
11
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-google
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nat Welch
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog-core
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.2
|
34
|
+
version: '1.2'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.2
|
41
|
+
version: '1.2'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: fog-xml
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,20 +81,6 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: pry-byebug
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
91
|
-
type: :development
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
98
84
|
- !ruby/object:Gem::Dependency
|
99
85
|
name: retriable
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,6 +215,7 @@ files:
|
|
229
215
|
- examples/backend_services.rb
|
230
216
|
- examples/bootstrap.rb
|
231
217
|
- examples/create_instance.rb
|
218
|
+
- examples/create_instance_with_attached_disk.rb
|
232
219
|
- examples/dns/project.rb
|
233
220
|
- examples/dns/zones.rb
|
234
221
|
- examples/get_list_images.rb
|