Skip to content

Commit

Permalink
Merge pull request #621 from rchekaluk/discard_local_ssd
Browse files Browse the repository at this point in the history
Add support for discard_local_ssd when stopping an instance
  • Loading branch information
Temikus authored Apr 8, 2024
2 parents 914f677 + 3b0f848 commit 08fc5cc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/fog/compute/google/models/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ def start(async = true)
operation
end

def stop(async = true)
def stop(async = true, discard_local_ssd=false)
requires :identity, :zone

data = service.stop_server(identity, zone_name)
data = service.stop_server(identity, zone_name, discard_local_ssd)
operation = Fog::Compute::Google::Operations
.new(:service => service)
.get(data.name, data.zone)
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/compute/google/requests/stop_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def stop_server(_identity, _zone)
end

class Real
def stop_server(identity, zone)
@compute.stop_instance(@project, zone.split("/")[-1], identity)
def stop_server(identity, zone, discard_local_ssd=false)
@compute.stop_instance(@project, zone.split("/")[-1], identity, discard_local_ssd: discard_local_ssd)
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions test/integration/compute/core_compute/test_servers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ def test_start_stop_reboot
assert server.ready?
end

def test_start_stop_discard_local_ssd
server = @factory.create

async = true
discard_local_ssd = true

server.stop(async, discard_local_ssd)
server.wait_for { stopped? }

assert server.stopped?
end

def test_attach_disk
# Creating server
server = @factory.create
Expand Down

0 comments on commit 08fc5cc

Please sign in to comment.