fog-google 0.5.0 → 0.5.1
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 +3 -1
- data/examples/create_instance.rb +5 -5
- data/examples/get_list_images.rb +1 -1
- data/examples/metadata.rb +2 -1
- data/examples/network.rb +2 -1
- data/lib/fog/compute/google/mock.rb +43 -54
- data/lib/fog/compute/google/models/image.rb +2 -0
- data/lib/fog/compute/google/models/server.rb +1 -1
- data/lib/fog/compute/google/models/servers.rb +1 -1
- data/lib/fog/google/shared.rb +13 -11
- data/lib/fog/google/version.rb +1 -1
- data/test/helpers/client_helper.rb +35 -0
- data/test/integration/compute/requests/test_compute_address_requests.rb +84 -0
- data/test/integration/compute/test_compute_addresses_collection.rb +74 -0
- data/tests/helper.rb +1 -1
- data/tests/requests/compute/disk_tests.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ad43648d6ec49a3e00c06ef22da0f2c12e84919c
|
|
4
|
+
data.tar.gz: cf6f8b28815b5ee18dfdce87306559c058eb49b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5df9ade71b8ac3430be566e5f8006425f6b8dd38ffeb5130f53c6c0d76a12fa56d73eec811a2c72342cbb669fdc0de2df796c037c3fbd32a26be2e2e6c41e8b2
|
|
7
|
+
data.tar.gz: aaa5bbe014e6d4c44438f068d8137abeb18276b25196ebb212ed54af9e98ca3c9d46d794a780cfd5869399451f654aac190095d983f23a56a7a45de7c54adf87
|
data/.travis.yml
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
+
cache: bundler
|
|
2
3
|
sudo: false
|
|
3
4
|
matrix:
|
|
4
5
|
fast_finish: true
|
|
@@ -7,9 +8,10 @@ matrix:
|
|
|
7
8
|
- rvm: 2.2
|
|
8
9
|
- rvm: 2.3.0
|
|
9
10
|
- rvm: 2.3.1
|
|
11
|
+
- rvm: 2.4.0
|
|
10
12
|
- rvm: jruby-head
|
|
11
13
|
allow_failures:
|
|
12
14
|
- rvm: jruby-head
|
|
13
|
-
|
|
15
|
+
- rvm: 2.4.0
|
|
14
16
|
notifications:
|
|
15
17
|
email: false
|
data/examples/create_instance.rb
CHANGED
|
@@ -9,13 +9,12 @@ Bundler.require(:default, :development)
|
|
|
9
9
|
def test
|
|
10
10
|
connection = Fog::Compute.new(:provider => "Google")
|
|
11
11
|
|
|
12
|
-
name = "fog-smoke-test-#{Time.now.to_i}"
|
|
13
|
-
|
|
14
12
|
disk = connection.disks.create(
|
|
15
|
-
:name =>
|
|
13
|
+
:name => "fog-smoke-test-#{Time.now.to_i}",
|
|
16
14
|
:size_gb => 10,
|
|
17
15
|
:zone_name => "us-central1-f",
|
|
18
|
-
:source_image => "debian-
|
|
16
|
+
:source_image => "debian-8-jessie-v20161215"
|
|
17
|
+
)
|
|
19
18
|
|
|
20
19
|
disk.wait_for { disk.ready? }
|
|
21
20
|
|
|
@@ -28,7 +27,8 @@ def test
|
|
|
28
27
|
:zone_name => "us-central1-f",
|
|
29
28
|
:user => ENV["USER"],
|
|
30
29
|
:tags => ["fog"],
|
|
31
|
-
:service_accounts => %w(sql-admin bigquery https://www.googleapis.com/auth/compute)
|
|
30
|
+
:service_accounts => %w(sql-admin bigquery https://www.googleapis.com/auth/compute)
|
|
31
|
+
)
|
|
32
32
|
|
|
33
33
|
# Wait_for routine copied here to show errors, if necessary.
|
|
34
34
|
duration = 0
|
data/examples/get_list_images.rb
CHANGED
|
@@ -23,7 +23,7 @@ def test
|
|
|
23
23
|
|
|
24
24
|
puts "Fetching a single image from a global project..."
|
|
25
25
|
puts "------------------------------------------------"
|
|
26
|
-
img = connection.images.get("debian-
|
|
26
|
+
img = connection.images.get("debian-8-jessie-v20161215")
|
|
27
27
|
raise "Could not GET the image" unless img
|
|
28
28
|
puts img.inspect
|
|
29
29
|
|
data/examples/metadata.rb
CHANGED
data/examples/network.rb
CHANGED
|
@@ -17,80 +17,69 @@ module Fog
|
|
|
17
17
|
when "debian-cloud"
|
|
18
18
|
{
|
|
19
19
|
:images => {
|
|
20
|
-
"debian-
|
|
20
|
+
"debian-8-jessie-v20161215" => {
|
|
21
|
+
"archiveSizeBytes" => "3436783050",
|
|
22
|
+
"creationTimestamp" => "2016-12-15T12 =>53 =>12.508-08 =>00",
|
|
23
|
+
"description" => "Debian, Debian GNU/Linux, 8 (jessie), amd64 built on 2016-12-15",
|
|
24
|
+
"diskSizeGb" => "10",
|
|
25
|
+
"family" => "debian-8",
|
|
26
|
+
"id" => "7187216073735715927",
|
|
21
27
|
"kind" => "compute#image",
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"name" => "debian-
|
|
26
|
-
"description" => "Debian GNU/Linux 6.0.7 (squeeze) built on 2013-08-16",
|
|
27
|
-
"sourceType" => "RAW",
|
|
28
|
+
"licenses" => [
|
|
29
|
+
"https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/licenses/debian-8-jessie"
|
|
30
|
+
],
|
|
31
|
+
"name" => "debian-8-jessie-v20161215",
|
|
28
32
|
"rawDisk" => {
|
|
29
33
|
"containerType" => "TAR",
|
|
30
34
|
"source" => ""
|
|
31
35
|
},
|
|
32
|
-
"
|
|
33
|
-
},
|
|
34
|
-
"debian-7-wheezy-v20130816" => {
|
|
35
|
-
"kind" => "compute#image",
|
|
36
|
-
"selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-7-wheezy-v20130816",
|
|
37
|
-
"id" => "4213305957435180899",
|
|
38
|
-
"creationTimestamp" => "2013-09-04T13:24:30.479-07:00",
|
|
39
|
-
"name" => "debian-7-wheezy-v20130816",
|
|
40
|
-
"description" => "Debian GNU/Linux 7.1 (wheezy) built on 2013-08-16",
|
|
36
|
+
"selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-8-jessie-v20161215",
|
|
41
37
|
"sourceType" => "RAW",
|
|
42
|
-
"rawDisk" => {
|
|
43
|
-
"containerType" => "TAR",
|
|
44
|
-
"source" => ""
|
|
45
|
-
},
|
|
46
38
|
"status" => "READY"
|
|
47
|
-
}
|
|
48
|
-
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
when "centos-cloud"
|
|
43
|
+
{
|
|
44
|
+
:images => {
|
|
45
|
+
"centos-6-v20161212" => {
|
|
46
|
+
"archiveSizeBytes" => "3942360630",
|
|
47
|
+
"creationTimestamp" => "2016-12-14T10 =>30 =>52.053-08 =>00",
|
|
48
|
+
"description" => "CentOS, CentOS, 6, x86_64 built on 2016-12-12",
|
|
49
|
+
"diskSizeGb" => "10",
|
|
50
|
+
"family" => "centos-6",
|
|
51
|
+
"id" => "5262726857160929587",
|
|
49
52
|
"kind" => "compute#image",
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"name" => "
|
|
54
|
-
"description" => "Debian GNU/Linux 7.1 (wheezy) built on 2013-10-14",
|
|
55
|
-
"sourceType" => "RAW",
|
|
53
|
+
"licenses" => [
|
|
54
|
+
"https://www.googleapis.com/compute/#{api_version}/projects/centos-cloud/global/licenses/centos-6"
|
|
55
|
+
],
|
|
56
|
+
"name" => "centos-6-v20161212",
|
|
56
57
|
"rawDisk" => {
|
|
57
58
|
"containerType" => "TAR",
|
|
58
59
|
"source" => ""
|
|
59
60
|
},
|
|
61
|
+
"selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/centos-cloud/global/images/centos-6-v20161212",
|
|
62
|
+
"sourceType" => "RAW",
|
|
60
63
|
"status" => "READY"
|
|
61
64
|
},
|
|
62
|
-
"
|
|
65
|
+
"centos-7-v20161212" => {
|
|
66
|
+
"archiveSizeBytes" => "4491098988",
|
|
67
|
+
"creationTimestamp" => "2016-12-14T10 =>29 =>44.741-08 =>00",
|
|
68
|
+
"description" => "CentOS, CentOS, 7, x86_64 built on 2016-12-12",
|
|
69
|
+
"diskSizeGb" => "10",
|
|
70
|
+
"family" => "centos-7",
|
|
71
|
+
"id" => "8650499281020268919",
|
|
63
72
|
"kind" => "compute#image",
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"name" => "
|
|
68
|
-
"description" => "Debian GNU/Linux 7.2 (wheezy) built on 2013-11-20",
|
|
69
|
-
"sourceType" => "RAW",
|
|
73
|
+
"licenses" => [
|
|
74
|
+
"https://www.googleapis.com/compute/#{api_version}/projects/centos-cloud/global/licenses/centos-7"
|
|
75
|
+
],
|
|
76
|
+
"name" => "centos-7-v20161212",
|
|
70
77
|
"rawDisk" => {
|
|
71
78
|
"containerType" => "TAR",
|
|
72
79
|
"source" => ""
|
|
73
80
|
},
|
|
74
|
-
"
|
|
75
|
-
"archiveSizeBytes" => "341857472"
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
when "centos-cloud"
|
|
80
|
-
{
|
|
81
|
-
:images => {
|
|
82
|
-
"centos-6-v20130813" => {
|
|
83
|
-
"kind" => "compute#image",
|
|
84
|
-
"selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/centos-cloud/global/images/centos-6-v20130813",
|
|
85
|
-
"id" => "4670523370938782739",
|
|
86
|
-
"creationTimestamp" => "2013-08-19T11:56:47.004-07:00",
|
|
87
|
-
"name" => "centos-6-v20130813",
|
|
88
|
-
"description" => "SCSI-enabled CentOS 6; Created Tue, 13 Aug 2013 00:00:00 +0000",
|
|
81
|
+
"selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/centos-cloud/global/images/centos-7-v20161212",
|
|
89
82
|
"sourceType" => "RAW",
|
|
90
|
-
"rawDisk" => {
|
|
91
|
-
"containerType" => "TAR",
|
|
92
|
-
"source" => ""
|
|
93
|
-
},
|
|
94
83
|
"status" => "READY"
|
|
95
84
|
}
|
|
96
85
|
}
|
|
@@ -11,6 +11,8 @@ module Fog
|
|
|
11
11
|
attribute :deprecated
|
|
12
12
|
attribute :description
|
|
13
13
|
attribute :disk_size_gb, :aliases => "diskSizeGb"
|
|
14
|
+
attribute :family
|
|
15
|
+
attribute :licenses
|
|
14
16
|
attribute :self_link, :aliases => "selfLink"
|
|
15
17
|
attribute :source_type, :aliases => "sourceType"
|
|
16
18
|
attribute :status
|
data/lib/fog/google/shared.rb
CHANGED
|
@@ -64,7 +64,7 @@ module Fog
|
|
|
64
64
|
options[:google_api_scope_url],
|
|
65
65
|
options[:app_name],
|
|
66
66
|
options[:app_version],
|
|
67
|
-
options[:google_client_options]
|
|
67
|
+
options[:google_client_options] || {}
|
|
68
68
|
)
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -105,18 +105,21 @@ module Fog
|
|
|
105
105
|
##
|
|
106
106
|
# Create a Google API Client with a user email and a pkcs12 key
|
|
107
107
|
#
|
|
108
|
-
# @param [String]
|
|
109
|
-
#
|
|
110
|
-
# @param [
|
|
111
|
-
# @param [String]
|
|
112
|
-
# @param [String]
|
|
113
|
-
# @
|
|
114
|
-
|
|
108
|
+
# @param google_client_email [String] A @developer.gserviceaccount.com.
|
|
109
|
+
# email address to use
|
|
110
|
+
# @param signing_key [OpenSSL::PKey] The private key for signing
|
|
111
|
+
# @param google_api_scope_url [String] Access scope URLs
|
|
112
|
+
# @param app_name [String] The app name to set in the user agent
|
|
113
|
+
# @param app_version [String] The app version to set in the user agent
|
|
114
|
+
# @param google_client_options [Hash] additional options to pass to the
|
|
115
|
+
# underlying google client
|
|
116
|
+
# @return [Google::APIClient] a newly-constructed Google API Client
|
|
117
|
+
def new_pk12_google_client(google_client_email, signing_key, google_api_scope_url, app_name = nil, app_version = nil, google_client_options = {})
|
|
115
118
|
application_name = app_name.nil? ? "fog" : "#{app_name}/#{app_version || '0.0.0'} fog"
|
|
116
119
|
api_client_options = {
|
|
117
120
|
:application_name => application_name,
|
|
118
121
|
:application_version => Fog::Google::VERSION
|
|
119
|
-
}
|
|
122
|
+
}.merge(google_client_options)
|
|
120
123
|
client = ::Google::APIClient.new(api_client_options)
|
|
121
124
|
|
|
122
125
|
client.authorization = Signet::OAuth2::Client.new(
|
|
@@ -126,8 +129,7 @@ module Fog
|
|
|
126
129
|
:issuer => google_client_email,
|
|
127
130
|
:scope => google_api_scope_url,
|
|
128
131
|
:signing_key => signing_key,
|
|
129
|
-
:token_credential_uri => "https://accounts.google.com/o/oauth2/token"
|
|
130
|
-
:google_client_options => google_client_options
|
|
132
|
+
:token_credential_uri => "https://accounts.google.com/o/oauth2/token"
|
|
131
133
|
)
|
|
132
134
|
client.authorization.fetch_access_token!
|
|
133
135
|
|
data/lib/fog/google/version.rb
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
##
|
|
2
|
+
# Helper mixin for tests (especially compute-based ones). Provide access to the
|
|
3
|
+
# client in use via the #client method to use.
|
|
4
|
+
|
|
5
|
+
module ClientHelper
|
|
6
|
+
# Check to see if an operation is finished.
|
|
7
|
+
#
|
|
8
|
+
# @param op [Excon::Response] the operation object returned from an api call
|
|
9
|
+
# @return [Boolean] true if the operation is no longer executing, false
|
|
10
|
+
# otherwise
|
|
11
|
+
def operation_finished?(op)
|
|
12
|
+
# TODO: support both zone and region operations
|
|
13
|
+
region = op[:body]["region"]
|
|
14
|
+
name = op[:body]["name"]
|
|
15
|
+
|
|
16
|
+
result = client.get_region_operation(region, name)
|
|
17
|
+
!%w(PENDING RUNNING).include?(result[:body]["status"])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Pause execution until an operation returned from a passed block is finished.
|
|
21
|
+
#
|
|
22
|
+
# @example Pause until server is provisioned
|
|
23
|
+
# @result = wait_until_complete { client.insert_server(name, zone, opts) }
|
|
24
|
+
# @yieldreturn [Excon::Response] the resulting operation object from a block.
|
|
25
|
+
# @return [Excon::Response] the final completed operation object
|
|
26
|
+
def wait_until_complete
|
|
27
|
+
result = yield
|
|
28
|
+
return result unless result[:body]["kind"] == "compute#operation"
|
|
29
|
+
|
|
30
|
+
# TODO: support both zone and region operations
|
|
31
|
+
region = result[:body]["region"]
|
|
32
|
+
Fog.wait_for { operation_finished?(result) }
|
|
33
|
+
client.get_region_operation(region, result[:body]["name"])
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require "helpers/integration_test_helper"
|
|
2
|
+
require "helpers/client_helper"
|
|
3
|
+
require "securerandom"
|
|
4
|
+
|
|
5
|
+
class TestComputeAddressRequests < FogIntegrationTest
|
|
6
|
+
DEFAULT_REGION = "us-central1".freeze
|
|
7
|
+
ADDRESS_RESOURCE_PREFIX = "fog-test-address".freeze
|
|
8
|
+
|
|
9
|
+
include ClientHelper
|
|
10
|
+
|
|
11
|
+
# Ensure we clean up any created resources
|
|
12
|
+
Minitest.after_run do
|
|
13
|
+
client = Fog::Compute::Google.new
|
|
14
|
+
addresses = client.list_addresses(DEFAULT_REGION)[:body]["items"]
|
|
15
|
+
unless addresses.nil?
|
|
16
|
+
addresses.
|
|
17
|
+
map { |a| a["name"] }.
|
|
18
|
+
select { |a| a.start_with?(ADDRESS_RESOURCE_PREFIX) }.
|
|
19
|
+
each { |a| client.delete_address(a, DEFAULT_REGION) }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
attr_reader :client
|
|
24
|
+
|
|
25
|
+
def setup
|
|
26
|
+
@client = Fog::Compute::Google.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def new_address_name
|
|
30
|
+
"#{ADDRESS_RESOURCE_PREFIX}-#{SecureRandom.uuid}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def some_address_name
|
|
34
|
+
# created lazily to speed tests up
|
|
35
|
+
@some_address ||= new_address_name.tap do |a|
|
|
36
|
+
result = @client.insert_address(a, DEFAULT_REGION)
|
|
37
|
+
Fog.wait_for { operation_finished?(result) }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_insert_address
|
|
42
|
+
result = wait_until_complete { @client.insert_address(new_address_name, DEFAULT_REGION) }
|
|
43
|
+
|
|
44
|
+
assert_equal(200, result.status, "request should be successful")
|
|
45
|
+
assert_equal(nil, result[:body]["error"], "result should contain no errors")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_get_address
|
|
49
|
+
result = @client.get_address(some_address_name, DEFAULT_REGION)
|
|
50
|
+
|
|
51
|
+
assert_equal(200, result.status, "request should be successful")
|
|
52
|
+
assert_includes(result[:body].keys, "name", "resulting body should contain expected keys")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_list_address
|
|
56
|
+
# Let's create at least one address so there's something to view
|
|
57
|
+
wait_until_complete { @client.insert_address(new_address_name, DEFAULT_REGION) }
|
|
58
|
+
|
|
59
|
+
result = @client.list_addresses(DEFAULT_REGION)
|
|
60
|
+
|
|
61
|
+
assert_equal(200, result.status, "request should be successful")
|
|
62
|
+
assert_includes(result[:body].keys, "items", "resulting body should contain expected keys")
|
|
63
|
+
assert_operator(result[:body]["items"].size, :>, 0, "address count should be positive")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_delete_address
|
|
67
|
+
# Create something to delete
|
|
68
|
+
address_to_delete = new_address_name
|
|
69
|
+
wait_until_complete { @client.insert_address(address_to_delete, DEFAULT_REGION) }
|
|
70
|
+
|
|
71
|
+
result = wait_until_complete { @client.delete_address(address_to_delete, DEFAULT_REGION) }
|
|
72
|
+
|
|
73
|
+
assert_equal(200, result.status, "request should be successful")
|
|
74
|
+
assert_equal(nil, result[:body]["error"], "result should contain no errors")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_list_aggregated_addresses
|
|
78
|
+
result = @client.list_aggregated_addresses
|
|
79
|
+
|
|
80
|
+
assert_equal(200, result.status, "request should be successful")
|
|
81
|
+
assert_includes(result[:body].keys, "items", "resulting body should contain expected keys")
|
|
82
|
+
assert_includes(result[:body]["items"].keys, "global", "resulting body 'items' subset should contain global keyword")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require "helpers/integration_test_helper"
|
|
2
|
+
require "securerandom"
|
|
3
|
+
|
|
4
|
+
class TestComputeAddressesCollection < FogIntegrationTest
|
|
5
|
+
DEFAULT_REGION = "us-central1".freeze
|
|
6
|
+
DEFAULT_ZONE = "us-central1-b".freeze
|
|
7
|
+
RESOURCE_PREFIX = "fog-test-addresscol".freeze
|
|
8
|
+
|
|
9
|
+
# Ensure we clean up any created resources
|
|
10
|
+
Minitest.after_run do
|
|
11
|
+
client = Fog::Compute::Google.new
|
|
12
|
+
client.addresses.each { |a| a.destroy if a.name.start_with?(RESOURCE_PREFIX) }
|
|
13
|
+
client.servers.each { |s| s.destroy if s.name.start_with?(RESOURCE_PREFIX) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_address_workflow
|
|
17
|
+
client = Fog::Compute::Google.new
|
|
18
|
+
|
|
19
|
+
my_address_name = new_resource_name
|
|
20
|
+
# An address can be created by specifying a name and a region
|
|
21
|
+
my_address = client.addresses.create(
|
|
22
|
+
:name => my_address_name,
|
|
23
|
+
:region => DEFAULT_REGION
|
|
24
|
+
)
|
|
25
|
+
# TODO: Shouldn't this be returning an operation object that we have to explicitly wait for?
|
|
26
|
+
assert_equal(my_address_name, my_address.name, "My address should have the provided name")
|
|
27
|
+
assert_equal("RESERVED", my_address.status, "My address should not be in use")
|
|
28
|
+
|
|
29
|
+
# It should also be visible when listing addresses
|
|
30
|
+
assert_includes(client.addresses.all.map(&:name), my_address_name)
|
|
31
|
+
|
|
32
|
+
# Be aware that although the address resource is created, it might not yet
|
|
33
|
+
# have an ip address. You can poll until the address has been assigned.
|
|
34
|
+
my_address.wait_for { !my_address.address.nil? }
|
|
35
|
+
assert_match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/,
|
|
36
|
+
my_address.address,
|
|
37
|
+
"My address's address should have a valid ipv4 address")
|
|
38
|
+
|
|
39
|
+
# Now that we have an address, we can create a server using the static ip
|
|
40
|
+
my_server = client.servers.create(
|
|
41
|
+
:name => new_resource_name,
|
|
42
|
+
:machine_type => "f1-micro",
|
|
43
|
+
:zone_name => DEFAULT_ZONE,
|
|
44
|
+
:disks => [
|
|
45
|
+
:boot => true,
|
|
46
|
+
:autoDelete => true,
|
|
47
|
+
:initializeParams => {
|
|
48
|
+
:sourceImage => "projects/debian-cloud/global/images/family/debian-8"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
:external_ip => my_address.address
|
|
52
|
+
)
|
|
53
|
+
my_server.wait_for { my_server.state != "PROVISIONING" }
|
|
54
|
+
|
|
55
|
+
# And verify that it's correctly assigned
|
|
56
|
+
assert_equal(
|
|
57
|
+
my_address.address,
|
|
58
|
+
my_server.network_interfaces[0]["accessConfigs"][0]["natIP"],
|
|
59
|
+
"My created server should have the same ip as my address"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# If we look up the address again by name, we should see that it is now
|
|
63
|
+
# in use
|
|
64
|
+
assert_equal(
|
|
65
|
+
"IN_USE",
|
|
66
|
+
client.addresses.get(my_address_name, DEFAULT_REGION).status,
|
|
67
|
+
"Address should now be in use"
|
|
68
|
+
)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def new_resource_name
|
|
72
|
+
"#{RESOURCE_PREFIX}-#{SecureRandom.uuid}"
|
|
73
|
+
end
|
|
74
|
+
end
|
data/tests/helper.rb
CHANGED
|
@@ -34,7 +34,7 @@ def create_test_disk(connection, zone)
|
|
|
34
34
|
:name => "fog-test-disk-#{random_string}",
|
|
35
35
|
:size_gb => "10",
|
|
36
36
|
:zone => zone,
|
|
37
|
-
:source_image => "debian-
|
|
37
|
+
:source_image => "debian-8-jessie-v20161215"
|
|
38
38
|
})
|
|
39
39
|
disk.wait_for { ready? }
|
|
40
40
|
disk
|
|
@@ -50,7 +50,7 @@ Shindo.tests("Fog::Compute[:google] | disk requests", ["google"]) do
|
|
|
50
50
|
disk_name = "new-disk-test"
|
|
51
51
|
disk_size = "2"
|
|
52
52
|
zone_name = "us-central1-a"
|
|
53
|
-
image_name = "debian-
|
|
53
|
+
image_name = "debian-8-jessie-v20161215"
|
|
54
54
|
|
|
55
55
|
# These will all fail if errors happen on insert
|
|
56
56
|
tests("#insert_disk").formats(@insert_disk_format) do
|
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: 0.5.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nat Welch
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date:
|
|
14
|
+
date: 2017-01-12 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: fog-core
|
|
@@ -600,10 +600,13 @@ files:
|
|
|
600
600
|
- tasks/lint.rake
|
|
601
601
|
- tasks/smoke.rake
|
|
602
602
|
- tasks/test.rake
|
|
603
|
+
- test/helpers/client_helper.rb
|
|
603
604
|
- test/helpers/integration_test_helper.rb
|
|
604
605
|
- test/helpers/test_collection.rb
|
|
605
606
|
- test/helpers/test_helper.rb
|
|
607
|
+
- test/integration/compute/requests/test_compute_address_requests.rb
|
|
606
608
|
- test/integration/compute/test_backend_services.rb
|
|
609
|
+
- test/integration/compute/test_compute_addresses_collection.rb
|
|
607
610
|
- test/integration/compute/test_disk_types.rb
|
|
608
611
|
- test/integration/compute/test_disks.rb
|
|
609
612
|
- test/integration/compute/test_forwarding_rules.rb
|
|
@@ -727,10 +730,13 @@ signing_key:
|
|
|
727
730
|
specification_version: 4
|
|
728
731
|
summary: Module for the 'fog' gem to support Google.
|
|
729
732
|
test_files:
|
|
733
|
+
- test/helpers/client_helper.rb
|
|
730
734
|
- test/helpers/integration_test_helper.rb
|
|
731
735
|
- test/helpers/test_collection.rb
|
|
732
736
|
- test/helpers/test_helper.rb
|
|
737
|
+
- test/integration/compute/requests/test_compute_address_requests.rb
|
|
733
738
|
- test/integration/compute/test_backend_services.rb
|
|
739
|
+
- test/integration/compute/test_compute_addresses_collection.rb
|
|
734
740
|
- test/integration/compute/test_disk_types.rb
|
|
735
741
|
- test/integration/compute/test_disks.rb
|
|
736
742
|
- test/integration/compute/test_forwarding_rules.rb
|