fog-google 1.23.0 → 1.24.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c923150c130d5e8bd63bfca7a24b463c49265dd372adaee2329307da4e229c10
4
- data.tar.gz: e77c879ff2bd76a160715760c5176d342cc5d803d89067df6d56e853a7d3b571
3
+ metadata.gz: 419c2fcd50b3c90ffe65c7a284bfc75479b1da059e0ea01b187a9f8f03721784
4
+ data.tar.gz: 470db0019a0de386752a1ca9c1a8cdb092e34037ef3e53a6a456a1ea033e6033
5
5
  SHA512:
6
- metadata.gz: 840ab70bf2250d8a4c6d6acbec60d0cb1d3d7d35383dfc2bbe5b2c58c659eb0f27253342f2a7cfd41358302f32079833dd98134d3024dfc300e7457e77c310f5
7
- data.tar.gz: e8c451c49047a40730c6548677e5b3b5a93451ae05f7d88fbdb768b70815a65654e3a46e47b0b1add021d6443da5b8ef1ec941d2b05e9010cf31580f1dc59992
6
+ metadata.gz: af159d5054ca5ceb4e391f8bbc019ad813c1e9163f11eeeb67dd3f57ccdfb157497d39451303210a7aa3e7b01f7295be937d445e97552f4fd8c9f1f42ca98c84
7
+ data.tar.gz: 00eb0b6200ad0fd56ea680e2dd1824548fe34d67da6e7469a872e27462281cf335f3aa23ede4956cea95433efa3e382c85c0ad60a732c0c96965b3830fac56f0
@@ -2,7 +2,7 @@
2
2
  # is no need to run them if SQL code or deps haven't changed and you cannot
3
3
  # trigger jobs based on file changes in the same workflow.
4
4
  # See: https://github.com/actions/runner/issues/456
5
- name: integration-tests-compute-instance_groups
5
+ name: integration-tests-compute-core
6
6
 
7
7
  on:
8
8
  push:
@@ -10,7 +10,7 @@ on:
10
10
  pull_request:
11
11
  branches: [ master ]
12
12
  types: [ assigned, opened, synchronize, reopened, labeled ]
13
- # Only run SQL integration tests if SQL code or deps have changed
13
+ # Only run integration tests if relevant code or deps have changed
14
14
  paths:
15
15
  # Module-specific paths
16
16
  - 'lib/fog/compute/**'
@@ -22,14 +22,23 @@ on:
22
22
  - 'lib/fog/google.rb'
23
23
  # Trigger workflow on version upgrade
24
24
  - 'lib/fog/google/version.rb'
25
+ # Trigger when workflow itself is updated
26
+ - '.github/workflows/integration-compute-core.yml'
27
+
28
+ # Setting hard concurrency limit for the project due to cleanup
29
+ # TODO(fog-google#626): remove this once cleanup is fixed
30
+ concurrency:
31
+ group: ${{ github.workflow }}
32
+ cancel-in-progress: false
25
33
 
26
34
  jobs:
27
35
  test-compute:
28
- runs-on: self-hosted
36
+ runs-on: fog-arc-runner
29
37
  strategy:
30
38
  matrix:
31
- ruby-version: [ '2.7', '3.0', '3.1' ]
39
+ ruby-version: [ '3.0', '3.1', '3.2' ]
32
40
  # Integration tests from the same task cannot run in parallel yet due to cleanup
41
+ # TODO(fog-google#626): remove this once cleanup is fixed
33
42
  max-parallel: 1
34
43
 
35
44
  steps:
@@ -10,7 +10,7 @@ on:
10
10
  pull_request:
11
11
  branches: [ master ]
12
12
  types: [ assigned, opened, synchronize, reopened, labeled ]
13
- # Only run SQL integration tests if SQL code or deps have changed
13
+ # Only run integration tests if relevant code or deps have changed
14
14
  paths:
15
15
  # Module-specific paths
16
16
  - 'lib/fog/compute/**'
@@ -22,13 +22,22 @@ on:
22
22
  - 'lib/fog/google.rb'
23
23
  # Trigger workflow on version upgrade
24
24
  - 'lib/fog/google/version.rb'
25
+ # Trigger when workflow itself is updated
26
+ - '.github/workflows/integration-compute-instance_groups.yml'
27
+
28
+ # Setting hard concurrency limit for the project due to cleanup
29
+ # TODO(fog-google#626): remove this once cleanup is fixed
30
+ concurrency:
31
+ group: ${{ github.workflow }}
32
+ cancel-in-progress: false
33
+
25
34
 
26
35
  jobs:
27
36
  test:
28
- runs-on: self-hosted
37
+ runs-on: fog-arc-runner
29
38
  strategy:
30
39
  matrix:
31
- ruby-version: [ '2.7', '3.0', '3.1' ]
40
+ ruby-version: [ '3.0', '3.1', '3.2' ]
32
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
33
42
  max-parallel: 1
34
43
 
@@ -10,7 +10,7 @@ on:
10
10
  pull_request:
11
11
  branches: [ master ]
12
12
  types: [ assigned, opened, synchronize, reopened, labeled ]
13
- # Only run SQL integration tests if SQL code or deps have changed
13
+ # Only run integration tests if relevant code or deps have changed
14
14
  paths:
15
15
  # Module-specific paths
16
16
  - 'lib/fog/compute/**'
@@ -22,13 +22,22 @@ on:
22
22
  - 'lib/fog/google.rb'
23
23
  # Trigger workflow on version upgrade
24
24
  - 'lib/fog/google/version.rb'
25
+ # Trigger when workflow itself is updated
26
+ - '.github/workflows/integration-compute-loadbalancing.yml'
27
+
28
+ # Setting hard concurrency limit for the project due to cleanup
29
+ # TODO(fog-google#626): remove this once cleanup is fixed
30
+ concurrency:
31
+ group: ${{ github.workflow }}
32
+ cancel-in-progress: false
33
+
25
34
 
26
35
  jobs:
27
36
  test:
28
- runs-on: self-hosted
37
+ runs-on: fog-arc-runner
29
38
  strategy:
30
39
  matrix:
31
- ruby-version: [ '2.7', '3.0', '3.1' ]
40
+ ruby-version: [ '3.0', '3.1', '3.2' ]
32
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
33
42
  max-parallel: 1
34
43
 
@@ -10,7 +10,7 @@ on:
10
10
  pull_request:
11
11
  branches: [ master ]
12
12
  types: [ assigned, opened, synchronize, reopened, labeled ]
13
- # Only run SQL integration tests if SQL code or deps have changed
13
+ # Only run integration tests if relevant code or deps have changed
14
14
  paths:
15
15
  # Module-specific paths
16
16
  - 'lib/fog/compute/**'
@@ -22,13 +22,21 @@ on:
22
22
  - 'lib/fog/google.rb'
23
23
  # Trigger workflow on version upgrade
24
24
  - 'lib/fog/google/version.rb'
25
+ # Trigger when workflow itself is updated
26
+ - '.github/workflows/integration-compute-networking.yml'
27
+
28
+ # Setting hard concurrency limit for the project due to cleanup
29
+ # TODO(fog-google#626): remove this once cleanup is fixed
30
+ concurrency:
31
+ group: ${{ github.workflow }}
32
+ cancel-in-progress: false
25
33
 
26
34
  jobs:
27
35
  test:
28
- runs-on: self-hosted
36
+ runs-on: fog-arc-runner
29
37
  strategy:
30
38
  matrix:
31
- ruby-version: [ '2.7', '3.0', '3.1' ]
39
+ ruby-version: [ '3.0', '3.1', '3.2' ]
32
40
  # Integration tests from the same task cannot run in parallel yet due to cleanup
33
41
  max-parallel: 1
34
42
 
@@ -10,7 +10,7 @@ on:
10
10
  pull_request:
11
11
  branches: [ master ]
12
12
  types: [ assigned, opened, synchronize, reopened, labeled ]
13
- # Only run SQL integration tests if SQL code or deps have changed
13
+ # Only run integration tests if relevant code or deps have changed
14
14
  paths:
15
15
  # Module-specific paths
16
16
  - 'lib/fog/google/monitoring.rb'
@@ -23,13 +23,21 @@ on:
23
23
  - 'lib/fog/google.rb'
24
24
  # Trigger workflow on version upgrade
25
25
  - 'lib/fog/google/version.rb'
26
+ # Trigger when workflow itself is updated
27
+ - '.github/workflows/integration-monitoring.yml'
28
+
29
+ # Setting hard concurrency limit for the project due to cleanup
30
+ # TODO(fog-google#626): remove this once cleanup is fixed
31
+ concurrency:
32
+ group: ${{ github.workflow }}
33
+ cancel-in-progress: false
26
34
 
27
35
  jobs:
28
36
  test:
29
- runs-on: self-hosted
37
+ runs-on: fog-arc-runner
30
38
  strategy:
31
39
  matrix:
32
- ruby-version: [ '2.7', '3.0', '3.1' ]
40
+ ruby-version: [ '3.0', '3.1', '3.2' ]
33
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
34
42
  max-parallel: 1
35
43
 
@@ -10,7 +10,7 @@ on:
10
10
  pull_request:
11
11
  branches: [ master ]
12
12
  types: [ assigned, opened, synchronize, reopened, labeled ]
13
- # Only run SQL integration tests if SQL code or deps have changed
13
+ # Only run integration tests if relevant code or deps have changed
14
14
  paths:
15
15
  # Module-specific paths
16
16
  - 'lib/fog/google/pubsub.rb'
@@ -23,13 +23,21 @@ on:
23
23
  - 'lib/fog/google.rb'
24
24
  # Trigger workflow on version upgrade
25
25
  - 'lib/fog/google/version.rb'
26
+ # Trigger when workflow itself is updated
27
+ - '.github/workflows/integration-pubsub.yml'
28
+
29
+ # Setting hard concurrency limit for the project due to cleanup
30
+ # TODO(fog-google#626): remove this once cleanup is fixed
31
+ concurrency:
32
+ group: ${{ github.workflow }}
33
+ cancel-in-progress: false
26
34
 
27
35
  jobs:
28
36
  test:
29
- runs-on: self-hosted
37
+ runs-on: fog-arc-runner
30
38
  strategy:
31
39
  matrix:
32
- ruby-version: [ '2.7', '3.0', '3.1' ]
40
+ ruby-version: [ '3.0', '3.1', '3.2' ]
33
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
34
42
  max-parallel: 1
35
43
 
@@ -10,7 +10,7 @@ on:
10
10
  pull_request:
11
11
  branches: [ master ]
12
12
  types: [ assigned, opened, synchronize, reopened, labeled ]
13
- # Only run SQL integration tests if SQL code or deps have changed
13
+ # Only run integration tests if relevant code or deps have changed
14
14
  paths:
15
15
  # Module-specific paths
16
16
  - 'lib/fog/google/sql.rb'
@@ -23,13 +23,21 @@ on:
23
23
  - 'lib/fog/google.rb'
24
24
  # Trigger workflow on version upgrade
25
25
  - 'lib/fog/google/version.rb'
26
+ # Trigger when workflow itself is updated
27
+ - '.github/workflows/integration-sql.yml'
28
+
29
+ # Setting hard concurrency limit for the project due to cleanup
30
+ # TODO(fog-google#626): remove this once cleanup is fixed
31
+ concurrency:
32
+ group: ${{ github.workflow }}
33
+ cancel-in-progress: false
26
34
 
27
35
  jobs:
28
36
  test:
29
- runs-on: self-hosted
37
+ runs-on: fog-arc-runner
30
38
  strategy:
31
39
  matrix:
32
- ruby-version: [ '2.7', '3.0', '3.1' ]
40
+ ruby-version: [ '3.0', '3.1', '3.2' ]
33
41
  # Integration tests from the same task cannot run in parallel yet due to cleanup
34
42
  max-parallel: 1
35
43
 
@@ -10,7 +10,7 @@ on:
10
10
  pull_request:
11
11
  branches: [ master ]
12
12
  types: [ assigned, opened, synchronize, reopened, labeled ]
13
- # Only run SQL integration tests if SQL code or deps have changed
13
+ # Only run integration tests if relevant code or deps have changed
14
14
  paths:
15
15
  # Module-specific paths
16
16
  - 'lib/fog/google/storage.rb'
@@ -24,13 +24,21 @@ on:
24
24
  - 'lib/fog/google.rb'
25
25
  # Trigger workflow on version upgrade
26
26
  - 'lib/fog/google/version.rb'
27
+ # Trigger when workflow itself is updated
28
+ - '.github/workflows/integration-storage.yml'
29
+
30
+ # Setting hard concurrency limit for the project due to cleanup
31
+ # TODO(fog-google#626): remove this once cleanup is fixed
32
+ concurrency:
33
+ group: ${{ github.workflow }}
34
+ cancel-in-progress: false
27
35
 
28
36
  jobs:
29
37
  test:
30
- runs-on: self-hosted
38
+ runs-on: fog-arc-runner
31
39
  strategy:
32
40
  matrix:
33
- ruby-version: [ '2.7', '3.0', '3.1' ]
41
+ ruby-version: [ '3.0', '3.1', '3.2' ]
34
42
  # Integration tests from the same task cannot run in parallel yet due to cleanup
35
43
  max-parallel: 1
36
44
 
@@ -10,7 +10,7 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
 
12
12
  steps:
13
- - uses: actions/stale@v8
13
+ - uses: actions/stale@v9
14
14
  with:
15
15
  repo-token: ${{ secrets.GITHUB_TOKEN }}
16
16
  days-before-stale: 360
@@ -6,12 +6,17 @@ on:
6
6
  pull_request:
7
7
  branches: [ master ]
8
8
 
9
+ # Cancel in-progress jobs of the same ref or run_id
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
12
+ cancel-in-progress: true
13
+
9
14
  jobs:
10
15
  test-unit:
11
16
  runs-on: ubuntu-latest
12
17
  strategy:
13
18
  matrix:
14
- ruby-version: ['2.7', '3.0', '3.1', 'head', 'truffleruby-head']
19
+ ruby-version: [ '3.0', '3.1', '3.2', 'head', 'truffleruby-head']
15
20
 
16
21
  steps:
17
22
  - uses: actions/checkout@v4
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -6,6 +6,30 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
6
6
 
7
7
  ## Next
8
8
 
9
+
10
+ ### User-facing
11
+
12
+ #### Added
13
+
14
+ - #613 Spruce up attaching and detaching disks on running servers [rchekaluk]
15
+ - #621 Added support for discard_local_ssd when stopping an instance [rchekaluk]
16
+
17
+ ### Development changes
18
+
19
+ ### Added
20
+
21
+ - #618 Deprecated Ruby-2.0 support [temikus]
22
+ - #624 Migrated the Integration tests to new ARC runners [temikus]
23
+ - #625 Fixed 'Ostruct' errors in storage tests [temikus]
24
+ - #627 Added concurrency groups to integration test workfows [temikus]
25
+
26
+ #### Fixed
27
+
28
+ - #604 Updated pry requirement from = 0.13.0 to = 0.14.2 [dependabot]
29
+ - #619 Updated google-cloud-env requirement from ~> 1.2 to >= 1.2, < 3.0 [dependabot]
30
+ - #620 Bump actions/stale from 8 to 9 [dependabot]
31
+ - #622 Updated fog-core requirement from < 2.3 to < 2.5 [dependabot]
32
+
9
33
  ## 1.23.0
10
34
 
11
35
  ### User-facing
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fog::Google
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/fog-google.svg)](http://badge.fury.io/rb/fog-google) [![Build Status](https://github.com/fog/fog-google/actions/workflows/ruby.yml/badge.svg)](https://github.com/fog/fog-google/actions/workflows/ruby.yml) [![codecov](https://codecov.io/gh/fog/fog-google/branch/master/graph/badge.svg)](https://codecov.io/gh/fog/fog-google) ![Dependabot Status](https://flat.badgen.net/github/dependabot/fog/fog-google) [![Doc coverage](https://inch-ci.org/github/fog/fog-google.svg?branch=master)](https://inch-ci.org/github/fog/fog-google)
3
+ [![Gem Version](https://badge.fury.io/rb/fog-google.svg)](http://badge.fury.io/rb/fog-google) [![Build Status](https://github.com/fog/fog-google/actions/workflows/unit.yml/badge.svg)](https://github.com/fog/fog-google/actions/workflows/unit.yml) [![codecov](https://codecov.io/gh/fog/fog-google/branch/master/graph/badge.svg)](https://codecov.io/gh/fog/fog-google) ![Dependabot Status](https://flat.badgen.net/github/dependabot/fog/fog-google) [![Doc coverage](https://inch-ci.org/github/fog/fog-google.svg?branch=master)](https://inch-ci.org/github/fog/fog-google)
4
4
 
5
5
  The main maintainers for the Google sections are @icco, @Temikus and @plribeiro3000. Please send pull requests to them.
6
6
 
@@ -175,7 +175,7 @@ $ bundle exec pry
175
175
 
176
176
  ## Supported Ruby Versions
177
177
 
178
- Fog-google is currently supported on Ruby 2.7+.
178
+ Fog-google is currently supported on Ruby 3.0+.
179
179
 
180
180
  In general we support (and run our CI) for Ruby versions that are actively supported
181
181
  by Ruby Core - that is, Ruby versions that are not end of life. Older versions of
@@ -0,0 +1,86 @@
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
+ ZONE = "us-central1-f"
8
+ PROJECT = Fog.credentials[:google_project]
9
+
10
+ def example
11
+ p "Connecting to Google API"
12
+ connection = Fog::Compute.new(:provider => "Google")
13
+
14
+ p "Creating disk"
15
+ disk = connection.disks.create(
16
+ :name => "fog-smoke-test-#{Time.now.to_i}",
17
+ :size_gb => 10,
18
+ :zone => ZONE,
19
+ :source_image => "debian-11-bullseye-v20220920"
20
+ )
21
+
22
+ p "Creating a second disk"
23
+ attached_disk = connection.disks.create(
24
+ :name => "fog-smoke-test-#{Time.now.to_i}",
25
+ :size_gb => 10,
26
+ :zone => ZONE
27
+ )
28
+
29
+ p "Waiting for disks to be ready"
30
+ disk.wait_for { ready? }
31
+ attached_disk.wait_for { ready? }
32
+
33
+ p "Creating a server"
34
+ server = connection.servers.create(
35
+ :name => "fog-smoke-test-#{Time.now.to_i}",
36
+ :disks => [disk.attached_disk_obj(boot: true, auto_delete: true)],
37
+ :machine_type => "n1-standard-1",
38
+ :private_key_path => File.expand_path("~/.ssh/id_rsa"),
39
+ :public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
40
+ :zone => ZONE,
41
+ # Will be simplified, see https://github.com/fog/fog-google/issues/360
42
+ :network_interfaces => [{ :network => "global/networks/default",
43
+ :access_configs => [{
44
+ :name => "External NAT",
45
+ :type => "ONE_TO_ONE_NAT"
46
+ }] }],
47
+ :username => ENV["USER"]
48
+ )
49
+
50
+ p "Attach second disk to the running server"
51
+ device_name = "fog-smoke-test-device-#{Time.now.to_i}"
52
+ # See https://github.com/fog/fog-google/blob/master/lib/fog/compute/google/models/disk.rb#L75-L107
53
+ # See https://github.com/fog/fog-google/blob/master/lib/fog/compute/google/models/server.rb#L35-L50
54
+ config_hash = {
55
+ :device_name => device_name,
56
+ :source => "https://www.googleapis.com/compute/v1/projects/#{PROJECT}/zones/#{ZONE}/disks/#{attached_disk.name}"
57
+ }
58
+ raise "Could not attach second disk" unless connection.attach_disk(server.name, ZONE, config_hash)
59
+
60
+ p "Waiting for disk to be attached"
61
+ attached_disk.wait_for { ! users.nil? && users != []}
62
+
63
+ p "Detach second disk"
64
+ raise "Could not detach second disk" unless connection.detach_disk(server.name, ZONE, device_name)
65
+
66
+ p "Waiting for second disk to be detached"
67
+ attached_disk.wait_for { users.nil? || users == []}
68
+
69
+ p "Deleting server"
70
+ raise "Could not delete server." unless server.destroy
71
+
72
+ p "Destroying second disk"
73
+ raise "Could not delete second disk." unless attached_disk.destroy
74
+
75
+ p "Waiting for second disk to be destroyed"
76
+ begin
77
+ rc = attached_disk.wait_for { status.nil? || status == 'DELETING' }
78
+
79
+ rescue => e
80
+ if e.message !~ /not found/ && e.message !~ /notFound/
81
+ raise e
82
+ end
83
+ end
84
+ end
85
+
86
+ example
data/fog-google.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  # As of 0.1.1
21
21
  spec.required_ruby_version = ">= 2.0"
22
22
 
23
- spec.add_dependency "fog-core", "< 2.3"
23
+ spec.add_dependency "fog-core", "< 2.5"
24
24
  spec.add_dependency "fog-json", "~> 1.2"
25
25
  spec.add_dependency "fog-xml", "~> 0.1.0"
26
26
 
@@ -32,14 +32,14 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "google-apis-pubsub_v1", "~> 0.30"
33
33
  spec.add_dependency "google-apis-sqladmin_v1beta4", "~> 0.38"
34
34
 
35
- spec.add_dependency "google-cloud-env", "~> 1.2"
35
+ spec.add_dependency "google-cloud-env", ">= 1.2", "< 3.0"
36
36
 
37
37
  spec.add_dependency "addressable", ">= 2.7.0"
38
38
 
39
39
  # Debugger
40
40
  # Locked because pry-byebug is broken with 13+
41
41
  # see: https://github.com/deivid-rodriguez/pry-byebug/issues/343
42
- spec.add_development_dependency "pry", "= 0.13.0"
42
+ spec.add_development_dependency "pry", "= 0.14.2"
43
43
 
44
44
  # Testing gems
45
45
  spec.add_development_dependency "retriable"
@@ -36,6 +36,10 @@ module Fog
36
36
  def get(identity, zone = nil)
37
37
  if zone
38
38
  disk = service.get_disk(identity, zone).to_h
39
+
40
+ # Force the hash to contain a :users key so that it will override any :users key in the existing object
41
+ disk[:users] = nil unless disk.include?(:users)
42
+
39
43
  return new(disk)
40
44
  elsif identity
41
45
  response = all(:filter => "name eq #{identity}",
@@ -45,7 +49,8 @@ module Fog
45
49
  end
46
50
  rescue ::Google::Apis::ClientError => e
47
51
  raise e unless e.status_code == 404
48
- nil
52
+ # Return an empty object so that wait_for processes the block
53
+ return new({:status => nil})
49
54
  end
50
55
 
51
56
  # Returns an attached disk configuration hash.
@@ -279,7 +279,7 @@ module Fog
279
279
  if disk.is_a? Disk
280
280
  disk_obj = disk.get_attached_disk
281
281
  elsif disk.is_a? String
282
- disk_obj = service.disks.attached_disk_obj(disk, attached_disk_options)
282
+ disk_obj = service.disks.attached_disk_obj(disk, **attached_disk_options)
283
283
  end
284
284
 
285
285
  data = service.attach_disk(identity, zone_name, disk_obj)
@@ -339,10 +339,10 @@ module Fog
339
339
  operation
340
340
  end
341
341
 
342
- def stop(async = true)
342
+ def stop(async = true, discard_local_ssd=false)
343
343
  requires :identity, :zone
344
344
 
345
- data = service.stop_server(identity, zone_name)
345
+ data = service.stop_server(identity, zone_name, discard_local_ssd)
346
346
  operation = Fog::Compute::Google::Operations
347
347
  .new(:service => service)
348
348
  .get(data.name, data.zone)
@@ -10,8 +10,8 @@ module Fog
10
10
  end
11
11
 
12
12
  class Real
13
- def stop_server(identity, zone)
14
- @compute.stop_instance(@project, zone.split("/")[-1], identity)
13
+ def stop_server(identity, zone, discard_local_ssd=false)
14
+ @compute.stop_instance(@project, zone.split("/")[-1], identity, discard_local_ssd: discard_local_ssd)
15
15
  end
16
16
  end
17
17
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Google
3
- VERSION = "1.23.0".freeze
3
+ VERSION = "1.24.0".freeze
4
4
  end
5
5
  end
@@ -132,6 +132,92 @@ class TestServers < FogIntegrationTest
132
132
  assert server.ready?
133
133
  end
134
134
 
135
+ def test_start_stop_discard_local_ssd
136
+ server = @factory.create
137
+
138
+ async = true
139
+ discard_local_ssd = true
140
+
141
+ server.stop(async, discard_local_ssd)
142
+ server.wait_for { stopped? }
143
+
144
+ assert server.stopped?
145
+ end
146
+
147
+ def test_attach_disk
148
+ # Creating server
149
+ server = @factory.create
150
+ server.wait_for { ready? }
151
+
152
+ disk_name = "fog-test-1-testservers-test-attach-disk-attachable" # suffix forces disk name to differ from the existing disk
153
+ # Creating disk #{disk_name}
154
+ disk = @disks.create(
155
+ :name => disk_name,
156
+ :source_image => TEST_IMAGE,
157
+ :size_gb => 64
158
+ )
159
+ device_name = "#{disk.name}-device"
160
+
161
+ # Attaching disk #{disk.name} as device #{device_name}
162
+ self_link = "https://www.googleapis.com/compute/v1/projects/#{TEST_PROJECT}/zones/#{TEST_ZONE}/disks/#{disk.name}"
163
+ server.attach_disk(self_link, true, device_name: device_name)
164
+
165
+ # Waiting for attachment
166
+ disk.wait_for { ! users.nil? && users != []}
167
+
168
+ assert_equal "https://www.googleapis.com/compute/v1/projects/#{TEST_PROJECT}/zones/#{TEST_ZONE}/instances/#{server.name}", disk.users[0]
169
+
170
+ server.reload
171
+ server_attached_disk = server.disks.select{|d| d[:boot] == false}[0]
172
+ assert_equal device_name, server_attached_disk[:device_name]
173
+ end
174
+
175
+ def test_detach_disk
176
+ # Creating server
177
+ server = @factory.create
178
+ server.wait_for { ready? }
179
+
180
+ disk_name = "fog-test-1-testservers-test-detach-attachable" # suffix forces disk name to differ from the existing disk
181
+ # Creating disk #{disk_name}
182
+ disk = @disks.create(
183
+ :name => disk_name,
184
+ :source_image => TEST_IMAGE,
185
+ :size_gb => 64
186
+ )
187
+ device_name = "#{disk.name}-device"
188
+
189
+ # Attaching disk #{disk.name} as device #{device_name}
190
+ self_link = "https://www.googleapis.com/compute/v1/projects/#{TEST_PROJECT}/zones/#{TEST_ZONE}/disks/#{disk.name}"
191
+ server.attach_disk(self_link, true, device_name: device_name)
192
+ disk.wait_for { ! users.nil? && users != []}
193
+
194
+ server.reload
195
+ server_attached_disk = server.disks.select{|d| d[:boot] == false}[0]
196
+ assert_equal device_name, server_attached_disk[:device_name]
197
+
198
+ # Detaching (synchronous) disk #{disk.name}
199
+ server.detach_disk(device_name, false)
200
+
201
+ disk.reload
202
+ assert disk.users.nil? || disk.users == []
203
+
204
+ # Re-attaching disk #{disk.name} as device #{device_name}
205
+ server.attach_disk(self_link, true, device_name: device_name)
206
+ disk.wait_for { ! users.nil? && users != []}
207
+
208
+ server.reload
209
+ server_attached_disk = server.disks.select{|d| d[:boot] == false}[0]
210
+ assert_equal device_name, server_attached_disk[:device_name]
211
+
212
+ # Detaching (async) disk #{disk.name}
213
+ server.detach_disk(device_name, true)
214
+
215
+ # Waiting for detachment
216
+ disk.wait_for { users.nil? || users == []}
217
+
218
+ assert disk.users.nil? || disk.users == []
219
+ end
220
+
135
221
  def test_reset_windows_password
136
222
  win_disk = @disks.create(
137
223
  :name => "fog-test-1-testservers-test-reset-windows-password-2",
@@ -4,6 +4,7 @@ require "securerandom"
4
4
  require "base64"
5
5
  require "tempfile"
6
6
  require "net/http"
7
+ require "ostruct"
7
8
 
8
9
  class TestStorageRequests < StorageShared
9
10
  def test_put_object_string
@@ -0,0 +1,26 @@
1
+ require "helpers/test_helper"
2
+
3
+ class UnitTestDisk < Minitest::Test
4
+ def setup
5
+ Fog.mock!
6
+ @client = Fog::Compute.new(provider: "google",
7
+ google_project: "foo")
8
+ end
9
+
10
+ def teardown
11
+ Fog.unmock!
12
+ end
13
+
14
+ def test_new_disk
15
+ disk = Fog::Compute::Google::Disk.new(
16
+ :name => "fog-1",
17
+ :size_gb => 10,
18
+ :zone => "us-central1-a",
19
+ :source_image => "debian-7-wheezy-v20131120"
20
+ )
21
+ assert_equal("fog-1", disk.name, "Fog::Compute::Google::Disk name is incorrect: #{disk.name}")
22
+ assert_equal(10, disk.size_gb, "Fog::Compute::Google::Disk size_gb is incorrect: #{disk.size_gb}")
23
+ assert_equal("us-central1-a", disk.zone, "Fog::Compute::Google::Disk zone is incorrect: #{disk.zone}")
24
+ assert_equal("debian-7-wheezy-v20131120", disk.source_image, "Fog::Compute::Google::Disk source_image is incorrect: #{disk.source_image}")
25
+ end
26
+ 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.23.0
4
+ version: 1.24.0
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: 2023-12-02 00:00:00.000000000 Z
12
+ date: 2024-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog-core
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "<"
19
19
  - !ruby/object:Gem::Version
20
- version: '2.3'
20
+ version: '2.5'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "<"
26
26
  - !ruby/object:Gem::Version
27
- version: '2.3'
27
+ version: '2.5'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: fog-json
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -161,16 +161,22 @@ dependencies:
161
161
  name: google-cloud-env
162
162
  requirement: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - "~>"
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '1.2'
167
+ - - "<"
168
+ - !ruby/object:Gem::Version
169
+ version: '3.0'
167
170
  type: :runtime
168
171
  prerelease: false
169
172
  version_requirements: !ruby/object:Gem::Requirement
170
173
  requirements:
171
- - - "~>"
174
+ - - ">="
172
175
  - !ruby/object:Gem::Version
173
176
  version: '1.2'
177
+ - - "<"
178
+ - !ruby/object:Gem::Version
179
+ version: '3.0'
174
180
  - !ruby/object:Gem::Dependency
175
181
  name: addressable
176
182
  requirement: !ruby/object:Gem::Requirement
@@ -191,14 +197,14 @@ dependencies:
191
197
  requirements:
192
198
  - - '='
193
199
  - !ruby/object:Gem::Version
194
- version: 0.13.0
200
+ version: 0.14.2
195
201
  type: :development
196
202
  prerelease: false
197
203
  version_requirements: !ruby/object:Gem::Requirement
198
204
  requirements:
199
205
  - - '='
200
206
  - !ruby/object:Gem::Version
201
- version: 0.13.0
207
+ version: 0.14.2
202
208
  - !ruby/object:Gem::Dependency
203
209
  name: retriable
204
210
  requirement: !ruby/object:Gem::Requirement
@@ -325,6 +331,7 @@ files:
325
331
  - ".hound.yml"
326
332
  - ".rubocop.yml"
327
333
  - ".ruby-gemset"
334
+ - ".ruby-version"
328
335
  - CHANGELOG.md
329
336
  - CONTRIBUTING.md
330
337
  - CONTRIBUTORS.md
@@ -337,6 +344,7 @@ files:
337
344
  - examples/backend_services.rb
338
345
  - examples/bootstrap.rb
339
346
  - examples/create_instance.rb
347
+ - examples/create_instance_and_attach_disk_later.rb
340
348
  - examples/create_instance_with_attached_disk.rb
341
349
  - examples/dns/project.rb
342
350
  - examples/dns/zones.rb
@@ -851,6 +859,7 @@ files:
851
859
  - test/integration/test_authentication.rb
852
860
  - test/unit/compute/test_common_collections.rb
853
861
  - test/unit/compute/test_common_models.rb
862
+ - test/unit/compute/test_disk.rb
854
863
  - test/unit/compute/test_server.rb
855
864
  - test/unit/dns/test_common_collections.rb
856
865
  - test/unit/monitoring/test_comon_collections.rb
@@ -879,7 +888,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
879
888
  - !ruby/object:Gem::Version
880
889
  version: '0'
881
890
  requirements: []
882
- rubygems_version: 3.3.7
891
+ rubygems_version: 3.4.10
883
892
  signing_key:
884
893
  specification_version: 4
885
894
  summary: Module for the 'fog' gem to support Google.
@@ -970,6 +979,7 @@ test_files:
970
979
  - test/integration/test_authentication.rb
971
980
  - test/unit/compute/test_common_collections.rb
972
981
  - test/unit/compute/test_common_models.rb
982
+ - test/unit/compute/test_disk.rb
973
983
  - test/unit/compute/test_server.rb
974
984
  - test/unit/dns/test_common_collections.rb
975
985
  - test/unit/monitoring/test_comon_collections.rb